A Telegram bot that downloads YouTube Shorts and Instagram Reels using yt_dlp.
Project description
📥 Telegram yt-dlp Interface Bot
A simple and lightweight Telegram bot that provides an interface to the yt-dlp Python module, enabling users to download YouTube Shorts and Instagram Reels directly within Telegram.
🚀 Features
- 🎥 Download YouTube Shorts by simply sending a link
- 📸 Download Instagram Reels from share links
- 🧠 Built using Python and yt-dlp.
- 🤖 Clean Telegram Bot interface for ease of use
🛠 Requirements
- Python 3.8+
- Telegram Bot Token from @BotFather
📦 Installation
-
Clone the repository
git clone https://github.com/yourusername/telegram-media-downloader.git cd telegram-media-downloader
-
Create a virtual environment (optional but recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install .
or simply
pip install -r requirements.txt
-
Configuration (environmente variables) Create a .env file in the root directory with the following required environment variable:
TELEGRAM_BOT_TOKEN="<your_bot_token_here>"
The
TELEGRAM_BOT_TOKENis used to specify the Telegram Bot Token for the bot.Optionally, you may also specify a
CHAT_IDSenvironment variable and aBOT_PASSWORDenvironment variable:TELEGRAM_BOT_TOKEN="<your_bot_token_here>" BOT_PASSWORD="<bot_password_here>" CHAT_IDS="000000001,000000002,000000003" BOT_USER_ID="0123456789"
The
BOT_PASSWORDis an optional password that, when specified, will prevent the bot from responding to links from chats that haven't been authenticated.To authenticate a chat, use the
/auth <bot_password>command in the Telegram chat.The
CHAT_IDSenvironment variable enables you to "pre-authenticate" some Telegram group chats/private message chats that will work immediately, without having to first use the bot's/auth <bot_password>command.The
BOT_USER_IDenvironment variable is used to inform the bot of its own Telegram user ID. This is used so that the bot can detect when it has been added to a new Telegram group chat. This initiates a countdown timer. If the chat is not authenticated using the/authcommand before the timer expires, then the bot will leave the group chat. This is performed so that the bot is not overwhelmed by messages from unauthenticated group chats.Note: these arguments can also be passed as command line arguments. For a description of the available command line arguments, execute the following:
python -m telegram_media_downloader_bot --help
-
Optional Configuration You may set the
ADMIN_USER_IDto your Telegram user ID to enable access to various admin-only commands.
▶️ Usage
Start the bot with:
python -m telegram_media_downloader_bot
Then, open Telegram, find your bot, and send a YouTube Shorts or Instagram Reels link. The bot will reply with the downloadable video.
User Commands
/download <URL>: Download the media at the specified URL and reply with the attached video. Works for Instagram reels and YouTube shorts./metrics: Send a message with the total number of downloads performed by the bot./auth <password>: Authenticate the chat in which the command was sent./auth <chat_id> <password>: Authenticate the specified chat (not the chat in which the command was sent).
Inline Commands
You may also perform inline downloads. You must first execute the /start command in a private chat with the bot. Once that is complete, you can simply type @<BotUsername> <URL> in any chat. The bot will download the video, send it to you privately so that the video is available with a unique ID on Telegram's servers, and then display a pop-up button that allows you to send that video to the currently-active Telegram chat. The message sent to you privately will be automatically removed after a few seconds.
This enables you to convert, download, and send reels and shorts without having to send the link at all.
Admin Commands
The following commands are only available to the admin user (i.e., the user whose Telegram ID is specified via the ADMIN_USER_ID environment variable).
/exit: If executed by the admin user (who can be specified via theADMIN_USER_IDenvironment variable), then the bot server will terminate/exit./clear_auth: Clear all authenticated users and group chats, then re-authenticate the configured "pre-authenticated" chat IDs.
📁 Project Structure
telegram-media-downloader/
├── telegram_media_downloader_bot/ # Main Python module.
├── __init__.py # Module declaration.
├── __main__.py # Entrypoint.
├── bot.py # Main Telegram bot logic.
├── requirements.txt # Python dependencies.
├── pyproject.toml # Module configuration file.
├── .gitignore # .gitignore file.
├── .env # Bot configuration (not tracked).
├── sample-env # Sample bot configuration file.
└── README.md # This file.
✅ Supported URLs
https://www.youtube.com/shorts/<video_id>https://www.instagram.com/reel/<reel_id>https://www.instagram.com/p/<reel_id>https://www.youtu.be/shorts/<reel_id>
🔒 Disclaimer
This project is intended strictly for educational purposes and serves as a demonstration of how to interact with APIs, handle media downloads programmatically, and build Telegram bots.
Downloading videos, audio, or other content from platforms like YouTube or Instagram may violate their Terms of Service (ToS). This bot is not affiliated with or endorsed by these platforms.
Do not download, distribute, or modify copyrighted material without explicit permission from the rightful owner. Unauthorized use may result in legal consequences. Always seek legal alternatives (e.g., YouTube Premium, official download options) to support content creators.
See YouTube's Terms of Service and Copyright Center for clarity. Likewise, see Instagram's Terms of Use and Copyright Center.
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegram_media_downloader-0.2.1.tar.gz.
File metadata
- Download URL: telegram_media_downloader-0.2.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07966c613780ca934fcdb330c93d20ae92083d7943f50082c62b5563f105d299
|
|
| MD5 |
6d83119c9cb22fce9573d1437266f3c2
|
|
| BLAKE2b-256 |
7c44e9815a7ded0df14f0ed95780033cd918b73311213186eba4c27ea738dd7a
|
Provenance
The following attestation bundles were made for telegram_media_downloader-0.2.1.tar.gz:
Publisher:
python-publish.yml on Scusemua/telegram-media-downloader-bot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_media_downloader-0.2.1.tar.gz -
Subject digest:
07966c613780ca934fcdb330c93d20ae92083d7943f50082c62b5563f105d299 - Sigstore transparency entry: 197424297
- Sigstore integration time:
-
Permalink:
Scusemua/telegram-media-downloader-bot@01c2f8b09c156e294133e803e2da840ed76836cf -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Scusemua
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@01c2f8b09c156e294133e803e2da840ed76836cf -
Trigger Event:
release
-
Statement type:
File details
Details for the file telegram_media_downloader-0.2.1-py3-none-any.whl.
File metadata
- Download URL: telegram_media_downloader-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c95b3842296b3f4b1923d90ec65511f976ec7a16c994d7fbbffeb566693a66ab
|
|
| MD5 |
6122af35b875f3f00fa26d0fbb9faf43
|
|
| BLAKE2b-256 |
0ed02c7fa72be32988401a95172b30c835787cb51fbcf6129359fbbb2e1b6bd5
|
Provenance
The following attestation bundles were made for telegram_media_downloader-0.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on Scusemua/telegram-media-downloader-bot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_media_downloader-0.2.1-py3-none-any.whl -
Subject digest:
c95b3842296b3f4b1923d90ec65511f976ec7a16c994d7fbbffeb566693a66ab - Sigstore transparency entry: 197424302
- Sigstore integration time:
-
Permalink:
Scusemua/telegram-media-downloader-bot@01c2f8b09c156e294133e803e2da840ed76836cf -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Scusemua
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@01c2f8b09c156e294133e803e2da840ed76836cf -
Trigger Event:
release
-
Statement type: