Multithreaded Telegram bot that downloads YouTube videos, you can run it with single command.
/about
/help
/formats
/audio
<youtube link> or/a
<youtube link>/video
<youtube link> or/v
1080p <youtube link>/search
<query> or/s
<query>
- Get a telegram bot key.
- (optional) Get a youtube api key. See search command
- Install Docker. docker docs
sudo apt update
sudo apt install docker.io -y
- Run the container with your bot key. docker image
sudo docker run -d --name telegram_youtube_downloader -e TELEGRAM_BOT_KEY=<YOUR_BOT_KEY> cccaaannn/telegram_youtube_downloader:latest
- (optional) To run bot with search feature
sudo docker run -d --name telegram_youtube_downloader -e TELEGRAM_BOT_KEY=<YOUR_BOT_KEY> -e YOUTUBE_API_KEY=<YOUR_API_KEY> cccaaannn/telegram_youtube_downloader:latest
- (optional) Also you can map logs to a volume.
sudo docker run -d --name telegram_youtube_downloader -e TELEGRAM_BOT_KEY=<YOUR_BOT_KEY> -e YOUTUBE_API_KEY=<YOUR_API_KEY> -v /home/can/logs:/telegram_youtube_downloader/logs cccaaannn/telegram_youtube_downloader:latest
- Get a telegram bot key.
- (optional) Get a youtube api key. See search command
- Install ffmpeg
sudo apt update
sudo apt upgrade -y
sudo apt install ffmpeg -y
- Install python and virtualenv
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt install python3.7 -y
sudo apt install python3-virtualenv -y
- Add your bot key to environment. Also check the alternative ways to pass keys.
export TELEGRAM_BOT_KEY=<YOUR_BOT_KEY>
source /etc/environment
- (optional) To run bot with search feature
export YOUTUBE_API_KEY=<YOUR_API_KEY>
source /etc/environment
- Install the repository and run the bot
# Install repository
git clone https://github.com/cccaaannn/telegram_youtube_downloader.git
cd telegram_youtube_downloader
# Create virtualenv
virtualenv -p /usr/bin/python3.7 venv
source venv/bin/activate
# Install requirements
pip install -r requirements.txt
# Run
python telegram_youtube_downloader
- Get a telegram bot key.
- (optional) Get a youtube api key. See search command
- Download ffmpeg from ffmpeg.org.
- Add
ffmpeg
to environment or add the path totelegram_youtube_downloader\configs\config.yaml
. configurations. - Install python from python.org.
- Install requirements.
pip install -r requirements.txt
- Run on cmd/terminal. Also check alternative ways to pass keys.
python telegram_youtube_downloader -k <YOUR_BOT_KEY>
- (optional) To run bot with search feature
python telegram_youtube_downloader -k <YOUR_BOT_KEY>,<YOUR_API_KEY>
/search
is an optional feature, and requires a youtube api key.- With search enabled you can make youtube searches and download from search results that listed as a button menu.
- You can get the key from console.developers.google.com
- With environment (Default)
TELEGRAM_BOT_KEY
key must be present on environment variables.- To use
/search
,YOUTUBE_API_KEY
key must be present on environment variables.
python telegram_youtube_downloader
- With file
- First line has to be <YOUR_BOT_KEY>.
- To use
/search
, <YOUR_API_KEY> should be on the second line.
python telegram_youtube_downloader -f <FILE_PATH_FOR_KEYS>
- Directly
python telegram_youtube_downloader -k <YOUR_BOT_KEY>
python telegram_youtube_downloader -k <YOUR_BOT_KEY>,<YOUR_API_KEY>
Configuration file telegram_youtube_downloader\configs\config.yaml
.
logger_options:
log_path: logs # Can be abs path
log_level: 20 # info
youtube_downloader_options:
preferred_video_format: mp4
preferred_audio_codec: mp3
default_video_quality: 720p
max_video_duration_seconds: 1200 # 20 min
max_audio_duration_seconds: 7200 # 2 hours
max_file_size: 45M # Telegram bots can send up to 50M
ffmpeg_location: null # null will try to get from env as ffmpeg
telegram_bot_options:
text_timeout_seconds: 30
video_timeout_seconds: 300 # 5 min
audio_timeout_seconds: 300 # 5 min
youtube_search_options:
max_results: 5 # Limit search results with 5