Repository navigation
scdlbot is rewritten from scratch. The new bot is one asyncio process with a download queue, yt-dlp downloads from every site, and SQLite keeps settings, the queue and stats.
It has been running @scdlbot since October 2026:
about 16,000 downloads a day for about 49,000 monthly users, on a server with 2 vCPUs and 4 GB of RAM.
For users
- No more hangs. The bot answers right away however busy it is: downloads wait in a queue, and the ⏳ message shows your place in it.
Downloads cut off by a restart start again by themselves. - Three modes for messages without a command (/settings):
- Auto-download all (was Download).
- Auto-download + ask about video: new, and the default in private chats. Everything downloads right away,
except YouTube links, which ask 🎵 Audio or 🎬 Video. Chats on Auto-download all were switched to it once;
/settings switches them back. - Ask before downloading (was Ask): the default in groups. ⬇️ Download / ❌ for links, 🎵 / 🎬 / ❌ for YouTube.
- YouTube videos as video (480p) with the 🎬 button or
/video <links>. YouTube Shorts always come as video (720p). - Instagram: reels, posts with photos and videos (carousels as albums), and stories.
Twitter / X: videos, GIFs, photos and text-only tweets. TikTok: videos.
Captions name the author (with a link to the profile) and include the post's text. - Audio keeps its original format (m4a or mp3, no re-encoding), with tags and cover art. Anything else becomes mp3,
and the new Always MP3 setting converts everything. - Albums and playlists go out as Telegram albums of up to 10 tracks while the rest download, up to 50 tracks a link,
with a note when there were more. - Bigger files: up to 1000 MB. On a bot without a local Bot API server, files bigger than Telegram's limit are split into parts.
- Videos play on iPhones: VP9 and HEVC videos are re-encoded to h264 (up to 30 minutes long), and every video is sent
with its size and duration, so iOS no longer squeezes Instagram videos into a square. - Videos without sound: when a site mutes a video in the server's country (licensed music on Instagram), the bot gets it
from another country. When it's muted everywhere, the caption says so. /dlas a reply to a message with links (or a reply that mentions the bot) downloads those links,
e.g. links sent while the bot was offline. Short links liket.coare expanded.- Clearer errors: private or deleted, not available in the bot's country, age-restricted, DRM-protected (SoundCloud Go+),
live streams, too large, the site limiting downloads, and more. - Clean links in captions, without share tracking (
?si=,?igsh=, TikTok'su_code). Every file also carries
an invisible link to its source, so Telegram can show it in link previews of the same URL. - /privacy: the privacy policy and disclaimer.
For people running their own bot
The configuration is mostly compatible, but read .env.sample:
- Python 3.14 or 3.15, ffmpeg and deno (or node) in
PATH. Install from PyPI (pip install scdlbot) or from git, then run it
with the systemd unit (deploy/scdlbot.service,Type=notifywith a watchdog) or theDockerfile.
The README explains the server it needs and how to install everything. - Settings live in a SQLite database (
DB_PATH). Settings from the old pickle file (CHAT_STORAGE) aren't carried over. - New settings:
DB_PATH,JOBS_RETENTION_DAYSWORKERSandYOUTUBE_WORKERS(a separate pool for YouTube, whose downloads run deno),JOB_TIMEOUT,MAX_QUEUE,MAX_USER_JOBSMAX_PLAYLIST_ITEMS,MAX_REENCODE_DURATION,FFMPEG_THREADS,YTDLP_ARGSROUTES_FILE,COOKIES_REFRESH,ROUTE_EXCLUSIONNORMALIZE_URLS,HIDDEN_SOURCE_LINKS,PRIVACY_POLICY_URLDROP_PENDING_UPDATES,ALERT_*,SENTRY_DSN
- Changed defaults:
DL_TIMEOUTis 35 minutes per file (was 5 minutes), andJOB_TIMEOUTis 40 minutes per link.MAX_CONVERT_FILE_SIZEis 1000 MB with a local Bot API server and 350 MB without one. It now limits every download.
- No longer used (ignored):
BIN_PATH,CHECK_URL_TIMEOUT,COMMON_CONNECTION_TIMEOUT,SYSLOG_ADDRESS,HOSTNAME,
SC_AUTH_TOKEN,CHAT_STORAGE. - Routes (
deploy/routes.sample.toml):- Each route is a proxy or a source IP, with its own cookies, and each site can have its own list of routes, taken in turn.
- A download a site blocks is tried once more through another route.
- A route a site keeps blocking is left out for a while, and the owner is told.
- Login routes, with an account's cookies, take only the downloads that need an account (Instagram stories, age-restricted reels).
systemctl reload scdlbotreloads the file without a restart.- Without the file,
PROXIES,SOURCE_IPSandCOOKIES_FILEstill work. Cookies from a URL or a Firefox profile are refreshed in the background.
- For the owner (
TG_BOT_OWNER_CHAT_ID):- /stats shows active users, the queue, downloads and files by kind for the last 24 hours and 7 days, top sites and app languages.
- A message when a site starts failing and when it recovers.
- Unexpected errors, at most one message a minute, and to Sentry or GlitchTip if
SENTRY_DSNis set.
- Prometheus metrics: jobs by site, kind, status and route; download errors; queue and workers; files and bytes sent
by site and kind; route attempts and retries; active users by period and app language. scdlbot fetch [--route NAME] URLdownloads one link exactly like the bot, without Telegram, to debug a site or a route.- Tools:
tools/instagram_cookies.pymakes cookies.txt files
for Instagram accounts;tools/reachable.pychecks
which users the bot can still message.
Under the hood
- Telegram handlers never wait for downloads. The old bot froze when every update slot waited for a busy download process.
- Every download is a
python -m yt_dlpsubprocess in its own process group:- It's killed with its ffmpeg and deno children on timeout.
- Its exact command is logged.
- It prints a line for each finished file, so files go out while the rest download.
- One shared Telegram connection with a rate limiter, so floods no longer hit Telegram's limits. With a local Bot API server, files are sent straight from disk.
- SQLite (WAL) keeps the chat settings, the queue, pending questions and stats. Per-download rows are deleted after
JOBS_RETENTION_DAYS; daily totals are kept. - A systemd watchdog tied to download progress restarts the bot if it ever gets stuck. When memory runs out, the kernel kills a download, not the bot.
- Dependencies: python-telegram-bot 22, yt-dlp, aiosqlite, prometheus-client, sentry-sdk. scdl, bandcamp-dl, pebble, requests,
plumbum, ffmpeg-python, mutagen, boltons and others are gone. - poetry with standard
[project]metadata, ruff, pytest (156 tests), mise tasks.
CI publishes a release to PyPI and GitHub when its version tag is pushed.
Removed
- The Link mode and
/link. They had been broken for a while. - scdl and bandcamp-dl: yt-dlp downloads SoundCloud and Bandcamp.
- Heroku, Render and Dokku files, syslog/Papertrail logging, the reStructuredText docs (the README is the documentation, also on
Read the Docs), flake8/tox and other old tooling.