π YouTubeDLBot is a powerful Telegram bot designed for downloading YouTube videos and audio with a smooth user experience. π₯ Built with stability and speed in mind, it leverages modern technologies like Pyrogram, aiohttp, and workers for efficient performance. βοΈ The bot supports video quality selection, high-quality audio downloads, and error handling for seamless YouTube content access. β¨
- βοΈ Video Quality Selection: Choose from 1080p, 720p, 480p, 360p, or 144p using interactive buttons. π
- π₯ Audio Quality Options: Download audio with 256kbps or 128kbps bitrate for high-quality sound. βοΈ
- π Progress Bar: Real-time progress bar for a smooth downloading experience. β¨
- π Message Editing: Updates messages dynamically for a polished user interface. π
- βοΈ Pyrogram Stability: Built with Pyrogram for reliable Telegram bot functionality. π
- π₯ Asynchronous Requests: Uses aiohttp for fast, non-blocking HTTP requests. βοΈ
- π Worker Clients: Enhances download speed with multiple client workers. β¨
- π Error Handling with Cookies: Manages YouTube download errors using a cookies file to bypass sign-in requirements. π
/start
- Start the bot π/yt
- Download a YouTube video π₯/video
- Download a YouTube video βοΈ/song
- Download a YouTube song π/stats
- View total bot users and groups π/send
- Broadcast messages with premium emojis β¨/broadcast
- Broadcast messages with normal emojis π/logs
- Retrieve bot logs for error troubleshooting βοΈ/restart
- Restart the bot π/speedtest
- Test your VPS speed π₯
π₯ To avoid errors related to YouTube sign-in requirements, the bot uses a cookie file for seamless content access. Follow these steps to set it up: β¨
- π Create a Dedicated Chrome Profile:
- Create a new Chrome profile for managing your bot's cookies to keep things organized. βοΈ
- π₯ Install a Cookie Management Extension:
- Use "Cookie Editor" or a similar extension to manage cookies. π
- βοΈ Export Cookies from YouTube:
- Log into YouTube in your new browser profile. π
- Use the cookie extension to export cookies in Netscape format. β¨
- π Save the Cookies File:
- Save the exported cookies as
ItsSmartToolBot.txt
in theYouTubeDLBot/cookies
directory of your project. π
- Save the exported cookies as
- π₯ Cookie Expiry:
- If you encounter download issues, refresh your cookies by exporting a new
ItsSmartToolBot.txt
file. βοΈ
- If you encounter download issues, refresh your cookies by exporting a new
- π Cookie Depletion:
- Avoid frequent bot restarts and excessive YouTube requests to prevent early cookie expiry. β¨
π This setup ensures efficient access to YouTube content without sign-in or bot protection errors. π
You can deploy YouTubeDLBot using one of the following methods: βοΈ
git clone https://github.com/TheSmartDevs/YouTubeDLBot
cd YouTubeDLBot
docker compose up --build --remove-orphans
git clone https://github.com/TheSmartDevs/YouTubeDLBot
cd YouTubeDLBot
pip3 install -r requirements.txt
python3 main.py
git clone https://github.com/TheSmartDevs/YouTubeDLBot
cd YouTubeDLBot
pip3 install -r requirements.txt
screen python3 main.py
π₯ The bot requires certain environment variables to function correctly. You can configure these in one of two ways: βοΈ
- π Using a
.env
File: Create a.env
file in the project root directory and set the variables there. π - π Editing
config.py
: Directly modify the default values in theconfig.py
file located in the project directory. β¨
API_ID
: Your Telegram API ID (e.g., Your API_ID Here). βοΈAPI_HASH
: Your Telegram API Hash (e.g., Your API_HASH Here). βοΈBOT_TOKEN
: The Telegram bot token obtained from BotFather (e.g., Your BOT_TOKEN Here). πOWNER_IDS
: Comma-separated Telegram user IDs of bot owners (e.g., Your OWNER_IDS Here). πMONGO_URL
: MongoDB connection URL for storing bot data (e.g., Your MONGO_URL Here). β¨YT_COOKIES_PATH
: Path to the YouTube cookies file (e.g.,./cookies/ItsSmartToolBot.txt
). π₯
COMMAND_PREFIX
: Prefixes for bot commands (e.g., Your COMMAND_PREFIX Here). βοΈMAX_VIDEO_SIZE
: Maximum video size in bytes (e.g., Your MAX_VIDEO_SIZE Here). πUPDATE_CHANNEL_URL
: Telegram channel for bot updates (e.g., Your UPDATE_CHANNEL_URL Here). πDEVELOPER_USER_ID
: Telegram user ID of the primary developer (e.g., Your DEVELOPER_USER_ID Here). β¨START_MSG_PHOTO
: URL of the photo displayed in the start message (e.g., Your START_MSG_PHOTO Here). π₯
# Bot Configuration
API_ID=Your API_ID Here
API_HASH=Your API_HASH Here
BOT_TOKEN=Your BOT_TOKEN Here
OWNER_IDS=Your OWNER_IDS Here
MONGO_URL=Your MONGO_URL Here
# Constants
COMMAND_PREFIX=Your COMMAND_PREFIX Here
YT_COOKIES_PATH=./cookies/ItsSmartToolBot.txt
MAX_VIDEO_SIZE=Your MAX_VIDEO_SIZE Here
UPDATE_CHANNEL_URL=Your UPDATE_CHANNEL_URL Here
DEVELOPER_USER_ID=Your DEVELOPER_USER_ID Here
START_MSG_PHOTO=Your START_MSG_PHOTO Here
π Alternatively, you can edit the config.py
file directly to set the default values for the variables. βοΈ The file uses environment variables if available, but falls back to the defaults specified in config.py
if the .env
file is not present or specific variables are unset. π₯ Open config.py
and modify the default values in the get_env_or_default
function calls to match your configuration. π
Example config.py
Snippet:
API_ID = get_env_or_default("API_ID", Your API_ID Here, int)
API_HASH = get_env_or_default("API_HASH", "Your API_HASH Here")
BOT_TOKEN = get_env_or_default("BOT_TOKEN", "Your BOT_TOKEN Here")
- Python 3.8+ βοΈ
- Docker (for Docker deployment) βοΈ
- Dependencies listed in
requirements.txt
π - A valid
ItsSmartToolBot.txt
file inYouTubeDLBot/cookies
for YouTube access π
Abir Arafat Chawdhruy β¨
π₯ Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. π To report an issue, contact @ISmartDevs on Telegram. π