Skip to main content

Deployments

Python

Pypi Publish

Docker Publish

PyPI version shields.io Pypi-format Pypi-status

YTSync

YTSync is a lightweight API, equipped with Telegram Bot to download a playlist and asynchronously transfer it to a remote server via rsync (ssh)

Features

  • Supports both webhooks and long-polling
  • Users can switch between webhooks and long-polling through API
  • Sequential downloads (to prevent requests being throttled/blocked)
  • Cold start (delayed) for the first download with a custom cooldown interval
  • Built-in retry mechanism with an exponential back off factor for remote transfers
  • Automatically deletes [Optional] local files after transferring to a remote server
  • Built-in support to check file presence on the remote server before requesting download/file-transfer

Environment variables

Server Settings
  • host: Hostname to run API server. Defaults to 0.0.0.0 [OR] localhost
  • port: Port number to run the API server. Defaults to 4483
  • tz: IANA time zone identifier. Defaults to server's local timezone
  • log_config: Dict config or filepath for log configuration. Defaults to logging.basicConfig
Telegram Settings
  • bot_token: Telegram bot token. Required for telegram access
  • bot_chat_ids: List of bot ids to allow. Required for telegram access
  • bot_users: List of bot usernames to allow. Required for telegram access
  • poll_interval: Number of seconds between each request to poll. Defaults to 2
  • bot_webhook: Telegram bot webhook URL. [Optional]
  • bot_webhook_ip: Webhook IP address. [Optional]
  • bot_endpoint: API endpoint to serve the webhook. Defaults to /telegram-webhook
  • bot_secret: Secret key to verify webhook requests. [Optional]
  • bot_certificate: Certificate filepath for webhook server (in case of self-signed certificate) [Optional]
API Settings
  • apikey: Key to access via API. Required for API access; defaults to bot_token
yt-dlp Settings [Optional]
  • cookie_file: Path to the cookie file.
  • source_address: IP address for the requesting source.
  • proxy_url: URL of the proxy server.
FileIO Settings
  • data_dir: Directory to store the database. Defaults to data
  • logs_dir: Directory to store logs. Defaults to logs
  • download_dir: Directory to store downloaded files. Defaults to downloads
Concurrency & Tolerance Settings
  • max_transfers: Maximum number of concurrent transfers to perform. Defaults to the number of CPU cores
  • max_retries: Maximum number of retries for rsync and telegram polling. Defaults to 10
  • backoff_factor: Back off factor between each retry attempt. Defaults to 3
  • max_error_threshold: Percentage of individual URLs to verify before downloading the entire playlist. Defaults to 30
  • response_timeout: Maximum number of seconds to wait before timing out the client request. Defaults to 30
Queue Settings
  • delayed_start: Perform a cold start (delayed) for the first download. Defaults to False
  • next_buffer: Number of seconds to simulate time taken for a download. Defaults to 60
  • cooldown_interval: Number of seconds to wait before processing next in queue. Defaults to 300
Remote Settings [Optional]
  • remote_host: Hostname [OR] IP address of the remote server.
  • remote_user: Username to connect to the remote server.
  • remote_path: Directory path on the remote server, to transfer downloaded files to.
  • delete_after_sync: Boolean flag to delete local files after transferring to the remote server.

SSH setup

Allow remote server connection without requiring a password [OR] private key during run-time

ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
ssh-copy-id user@receiver_ip
ssh user@receiver_ip

Docker

Mount the local ~/.ssh volume to allow reading known hosts

docker run \
  -v ~/.ssh/id_ed25519:/root/.ssh/id_ed25519:ro \
  -v ~/.ssh/known_hosts:/root/.ssh/known_hosts:ro \
  ytsync

Linting

pre-commit will ensure linting

Requirement

pip install pre-commit

Usage

pre-commit run --all-files

Pypi Package

pypi-module

https://pypi.org/project/YTSync/

License & copyright

© Vignesh Rao

Licensed under the MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytsync-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file ytsync-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ytsync-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ytsync-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a89f256286b1427254ef975881cb79813be6dfd13a712ab5dbda9ee5d9df064
MD5 e7e63d9338c3f5f88d3717db2e012837
BLAKE2b-256 57cb655a755d629a5a11178b4221fa4e716dcd2390479ecfcb098d8958eb88d4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page