A big chunk of my course material lived inside Telegram channels: lectures, notes, and PDFs. That is fine until you actually try to study offline. So I built a bulk downloader with Telethon that archives an entire channel in order, with resume support, so I could learn from VLC and a PDF reader instead of an endless scroll.
#The problem: my college ran on Telegram
In India, a huge amount of student material such as coaching lectures, notes, and previous papers gets shared through Telegram channels. Scrolling through months of history, dealing with slow in-app playback, and the constant worry of a channel getting taken down made it painful to rely on. I wanted a clean offline copy I could open in VLC or any reader.
#What it does
It downloads images, audio, video, and documents (PDF, Word, Excel, PowerPoint, ZIP/RAR/7z, text/CSV, and more) from a channel in chronological order, naming each file so the sequence stays intact.
- ▹Works with public channels,
t.melinks, and private invite links - ▹Chronological numbering like
0000000001 - lesson title.mp4 - ▹Caption-based, ASCII-safe filenames that respect Windows path limits
- ▹Resume support: finished files are skipped via a
manifest.json - ▹Multipart segmented downloads for big videos, plus retries, FloodWait handling, and integrity checks
- ▹A live Rich dashboard so you can watch progress in the terminal
Note
#Quick start
You need Python 3.11+ and API credentials from my.telegram.org/apps. Set up a virtual environment and install the requirements:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
copy .env.example .envSet TG_API_ID and TG_API_HASH in .env, then point it at a channel:
python tg_downloader.py https://t.me/your_channel_usernameThe first run asks for your phone number, an OTP, and (if enabled) your two-step password. After that a session file keeps you logged in. Files land under downloads/<Channel Name>/, and re-running the same channel continues right where you left off.
#Squeezing out 10–15 MB/s
Telegram rate-limits aggressive downloaders, so more workers is not always faster. A stable starting config looks like this:
TG_MAX_GLOBAL_DOWNLOADS=2
TG_ENABLE_MULTIPART=true
TG_PART_SIZE_MB=8
TG_MAX_PARALLEL_PARTS=4
TG_REQUEST_SIZE_BYTES=2097152Installing cryptg speeds up encryption a lot. On Windows, the biggest real-world wins came from saving to an SSD, adding Defender exclusions for the project and downloads folders, and using Ethernet over Wi-Fi.
| Setup | Typical speed |
|---|---|
| Basic / HDD / high concurrency | 0.5–2 MB/s |
| Tuned sequential + cryptg | 2–4 MB/s |
| Multipart + SSD + exclusions | 4–10 MB/s |
| Best case (CDN + network) | 10\u201315 MB/s |
#Lessons learned
- ▹Resume-by-manifest is the feature that made it genuinely usable; big channels take hours
- ▹ASCII-safe, length-capped names fixed VLC's “unable to open MRL” errors caused by long paths
- ▹Backing off on FloodWait beats hammering the API and getting throttled harder
Legal & ethical use
If you also study from Telegram, the code is on GitHub. Clone it, drop in your API keys, and point it at your channel.