Telegramusic
Python Telegram Bot to download music from Deezer and YouTube (Docker, Heroku)
Install / Use
/learn @kernoeb/TelegramusicREADME
Disclaimer
:warning: For educational purposes only (or for free music) Please don't use this for illegal stuff. It's against Deezer's terms of service.
Translations
Your native language is not in the langs.json file ? Just make a pull request or send me a message !
Usage
- Get an
arlcookie on Deezer forDEEZER_TOKEN( see this repo) - Create a bot on Telegram and grab a token with Bot Father (
TELEGRAM_TOKEN) - Activate
Inline Modeon BotFather for the bot you just created
Search for music in inline mode :
@xxxxxxx_bot (album|track) <search>


or send a Deezer / YouTube / SoundCloud link
Configuration
Docker
Prerequisites
- Docker (Linux installation and Linux post-installation steps)
- Docker compose (should be included in the Docker installation)
Create a token.env file with the following content, replacing the values with your own tokens :
DEEZER_TOKEN=abcdefghijklmnoxxxxxxxxxxxx
TELEGRAM_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ
BOT_LANG=fr
Run
./update.sh
Or manually :
git pull && docker-compose up -d --build
Local usage
- Add
DEEZER_TOKENandTELEGRAM_TOKENas variable environment - python3.13 -m pip install -r requirements.txt
- python3.13 main.py
You should use a
venvto avoid conflicts with your system python packages
Compressed files (zip)
You can send a zip file with multiple tracks inside, the bot will send you a zip file with all the tracks downloaded and the cover.
In the token.env file, add the following line :
FORMAT=zip
If the zip file is too big (more than 50MB), the bot will split the zip file into multiple parts.
Download URL
You can also make the bot move a file to a specific directory and send you the download link.
In the token.env file, add the following line :
FORMAT=zip
COPY_FILES_PATH=/path/to/your/directory
FILE_LINK_TEMPLATE=https://yourdomain.com/download/{0}
The {0} will be replaced by the file name.
I recommend using a reverse proxy to serve the files, like Nginx or Caddy.
If you use Docker, you can mount a volume to the container and set the COPY_FILES_PATH to /files, like this :
volumes:
- /path/to/your/directory:/files
Allow FLAC format
If you have Deezer premium, you can allow the bot to download FLAC files by adding the following line in the token.env
file :
ENABLE_FLAC=1
Do not send album art
The default behavior is to send album cover and liks to the album and song. If you do not want to send it, set the SEND_ALBUM_COVER to true.
SEND_ALBUM_COVER=true
Troubleshooting
"Sign in to confirm you’re not a bot. This helps protect our community. Learn more." Please note that your account may be banned if you use this feature.
Add a cookies.txt in ./local_resources.
To generate this file, please see : https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp.
You don't need to restart the bot, it will automatically reload the cookies when downloading a YouTube video.
Example configuration
# Global configuration
BOT_LANG=en
# Tokens
DEEZER_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TELEGRAM_TOKEN=1234567890:ABCDEFghijklmnopqrstuvwxyz012345678
# Specific configuration
COPY_FILES_PATH=/files
FILE_LINK_TEMPLATE=https://example.com/dl/{0}
FORMAT=zip
Debugging
docker logs telegramusic 2>/dev/null | grep "USER_DEBUG"
grep "USER_DEBUG" # All user activities
grep "USER_DEBUG.*user_id=123456789" # Activities for specific user ID
grep "USER_DEBUG.*username=john" # Activities for specific username
grep "USER_DEBUG.*Error" # All user-related errors
