This is a Telegram bot that allows users to download videos from X (formerly Twitter) by sending a video URL. The bot processes the video and sends it back to the user while ensuring it remains under 50MB.
✅ Detects and processes X (Twitter) video URLs
✅ Downloads videos using yt-dlp
✅ Compresses videos larger than 50MB using FFmpeg
✅ Sends videos directly to the user on Telegram
✅ Handles errors and logs issues
-
Clone the repository
git clone https://github.com/iraqitechs/xdownloader.git cd x-video-downloader-bot
-
Create a
.env
file with your Telegram bot token:TELEGRAM_BOT_TOKEN=your_bot_token_here LOG_LEVEL=INFO
-
Install dependencies
pip install -r requirements.txt
-
Ensure
FFmpeg
is installed- On Ubuntu/Debian:
sudo apt install ffmpeg
- On Mac (Homebrew):
brew install ffmpeg
- On Windows: Download FFmpeg
- On Ubuntu/Debian:
-
Run the bot
python bot.py
-
Send a Twitter (X) video URL to the bot on Telegram.
The bot will download and send back the video.
- The bot detects if a URL is from X (Twitter).
- If valid, it downloads the video using
yt-dlp
. - If the file is larger than 50MB, it gets compressed to 480p.
- The bot then sends the video to the user.
- Temporary files are cleaned up after processing.
- If the bot fails to download, it informs the user.
- If the video exceeds Telegram's size limit, it gets compressed.
- Logs are saved for debugging.
Feel free to open issues or contribute improvements!
This project is licensed under the MIT License.