Skip to content

rin-gil/youtube-music-download-bot

Repository files navigation

YouTube Music Download Bot

python version aiogram version asyncpg version environs version static-ffmpeg version matplotlib version numpy version redis version yt-dlp version

Code style: black Code tests Code tests MIT licence

Ru Ua

YouTube Music Download Bot

Bot to download music from YouTube. Working version is available here @YT_upl_Bot

Features

  • Search for music on YouTube
  • Downloading found videos in .mp3 format

Installing Bot

If you want a simple version of the bot, without using Postgres database and without working in webhook mode, go to this branch.

Install the bot with the command in the terminal:

wget https://raw.githubusercontent.com/rin-gil/youtube-music-download-bot/master/infrastructure/deploy.sh && chmod +x deploy.sh && ./deploy.sh

Installing and setup Postgres

Install the Postgres database according to the instructions from the official website: https://www.postgresql.org/download/

The work of the bot is tested on Postgres version 15

Create the database, user, and settings by running the commands in the terminal:

sudo -u postgres psql
CREATE DATABASE db_name;
CREATE USER db_user WITH PASSWORD 'db_password';
\connect db_name;
CREATE SCHEMA db_name AUTHORIZATION db_user;
ALTER ROLE db_user SET client_encoding TO 'utf8';
ALTER ROLE db_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE db_user SET timezone TO 'UTC';
\q

Replace db_name, db_user and db_password in these commands with your data.

Setup and launch

  • Register a new bot with @BotFather and copy the obtained token
  • Insert the bot token and database credentials into the .env file
  • Running the bot through the bot.py file python bot.py

Additional configuration

Example configurations for running the bot in webhook mode or as a systemd service can be found in the infrastructure folder

Restrictions

  • Bot only downloads music (audio file .mp3)
  • Bot does not download live broadcasts
  • The entire playlist is not downloaded, only one item is downloaded
  • Bot does not download clips longer than 15 minutes
  • The title for the audio file is generated from the YouTube video title. Since the title may contain undesirable characters not supported by the file system, all characters except letters, numbers, spaces, '_' and '-' characters are removed from the title, the title length is truncated to 100 characters

Developers

License

YouTubeMusicDownloadBot is licensed under MIT