Skip to content
Can Kurt edited this page Jun 16, 2024 · 2 revisions

Setup


Table of contents


Preliminary steps

  1. Get a telegram bot key.
  2. (optional) Get a youtube api key. See search command

Running

1. Docker

  1. Install Docker. docker docs
sudo apt update
sudo apt install docker.io -y
  1. Run the container with your bot key. telegram_youtube_downloader docker image
sudo docker run -d --name telegram_youtube_downloader --restart unless-stopped -e TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY> cccaaannn/telegram_youtube_downloader:latest

Optional flags

  • To run bot with search feature
-e YOUTUBE_API_KEY=<YOUTUBE_API_KEY>
  • Mapping config folder to a volume for setting custom configurations.
-v /home/can/configs:/telegram_youtube_downloader/telegram_youtube_downloader/configs
  • Mapping logs to a volume.
-v /home/can/logs:/telegram_youtube_downloader/logs
  • Example with all flags
sudo docker run -d --name telegram_youtube_downloader --restart unless-stopped \
-e TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY> \
-e YOUTUBE_API_KEY=<YOUTUBE_API_KEY> \
-v <YOUR_CONFIGS_PATH>/configs:/telegram_youtube_downloader/telegram_youtube_downloader/configs \
-v <YOUR_LOGS_PATH>/logs:/telegram_youtube_downloader/logs \
cccaaannn/telegram_youtube_downloader:latest

2. Ubuntu

  • Tested with Ubuntu 24 - Python 3.12
  1. Install ffmpeg
sudo apt update
sudo apt upgrade -y
sudo apt install ffmpeg -y
  1. Install python and virtualenv
sudo apt install python3 -y
sudo apt install python3-pip -y

sudo apt install python3-virtualenv -y
  1. Add your bot key to environment. Also check the alternative ways to pass keys.
export TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY>
source ~/.bashrc
  • (optional) To run bot with search feature
export YOUTUBE_API_KEY=<YOUTUBE_API_KEY>
source ~/.bashrc
  1. 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 venv
source venv/bin/activate

# Install requirements
pip install -r requirements.txt

# Run
python telegram_youtube_downloader

3. Windows

  • Tested with Windows 10 - Python 3.12
  1. Download ffmpeg from ffmpeg.org.
    • Add ffmpeg to path, or add the binary path to telegram_youtube_downloader\configs\config.yaml. See configurations.
  2. Install python from python.org.
  3. Install requirements.
pip install -r requirements.txt
  1. Run on cmd/terminal. Also check Alternative ways to pass keys.
python telegram_youtube_downloader -k <TELEGRAM_BOT_KEY>
  • (optional) To run bot with search feature
python telegram_youtube_downloader -k <TELEGRAM_BOT_KEY>,<YOUTUBE_API_KEY>


Search command

  • /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

Alternative ways to pass keys

  1. 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
  1. With file
    • First line has to be <TELEGRAM_BOT_KEY>.
    • To use /search, <YOUTUBE_API_KEY> should be on the second line.
python telegram_youtube_downloader -f <FILE_PATH_FOR_KEYS>
  1. Directly
python telegram_youtube_downloader -k <TELEGRAM_BOT_KEY>
python telegram_youtube_downloader -k <TELEGRAM_BOT_KEY>,<YOUTUBE_API_KEY>