How xrontrix10/telegram-leecher works
Project Type & Purpose
• This is a Pyrogram-based Telegram Bot designed to run inside a Google Colab notebook.
• It automates downloading files/folders from a variety of sources (direct links, Google Drive, Telegram, YouTube, etc.), optionally converts or zips them, then uploads them to Telegram chats or Google Drive.
File Structure & Architectural Patterns
• Top-level entrypoints:
• main.py – likely parses command-line or notebook arguments and launches the bot.
• colab_leecher/__main__.py – makes the package executable (python ‑m colab_leecher).
• Subpackages:
• downloader/ – a “download strategy” layer with one module per source (aria2, gdrive, mega, telegram, terabox, ytdl) and manager.py to pick the right strategy.
• uploader/ – handles uploads (currently Telegram).
• utility/ – cross-cutting services (converters, zipping/splitting, task_manager, handler for commands, shared variables).
• No persistent database; uses in-memory or file-system staging within the Colab container.
Key Technologies & External Services
• Python, Pyrogram (Telegram Bot API), google-drive API (via pydrive or direct HTTP), aria2 RPC, youtube-dl, file-system libraries, zip/split utils.
• Colab runtime environment as a Docker-like container.
• External hosts: Google Drive, Telegram servers, third-party file hosts.
a. Entry Point
• Notebook / main.py / __main__.py
• Initializes Pyrogram Bot client and command handler
b. Command & Task Handler
• utility/handler.py – maps incoming Telegram bot commands to tasks
• utility/task_manager.py – schedules and tracks download/upload tasks
c. Download Manager
• downloader/manager.py – inspects link type and dispatches to one of:
– aria2.py
– gdrive.py
– mega.py
– telegram.py
– terabox.py
– ytdl.py
d. Utilities
• utility/converters.py – video conversions (mp4/mkv)
• utility/helper.py – zipping, splitting, thumbnail generation
• utility/variables.py – configuration constants
e. Upload Module
• uploader/telegram.py – sends files to Telegram chats
• (Optionally in future: uploader/gdrive.py)
f. External Services & Storage
• Local Colab file system (staging area)
• Google Drive API
• Telegram Bot API & File servers
• Third-party file hosts (YouTube, direct links, etc.)
Data Flow & Interactions
1. User sends a Telegram command → Pyrogram Bot
2. Handler parses command → Task Manager
3. Task Manager invokes Download Manager → selects appropriate downloader module → fetches file(s) → writes to local Colab storage
4. After download completes → Utility modules (conversion, zipping, thumbnail) process files
5. Processed file handed to Uploader → forwarded to Telegram or Google Drive
6. Bot sends completion status or errors back to the user
Architectural Patterns & Principles
• Strategy Pattern in downloader modules
• Single Responsibility: each module does one thing (download, convert, upload, handle commands)
• Layered structure: Entry → Handler → Manager → Workers → External
• Pluggable extensibility: adding a new downloader is as simple as creating a new module + updating manager.py