https://github.com/kernoeb/Telegramusic
Python Telegram Bot to download music from Deezer and YouTube (Docker, Heroku)
https://github.com/kernoeb/Telegramusic
bot deezer deezer-api docker flac heroku mp3 python python3 soundcloud telegram telegram-bot youtube youtube-dl zip
Last synced: 11 months ago
JSON representation
Python Telegram Bot to download music from Deezer and YouTube (Docker, Heroku)
- Host: GitHub
- URL: https://github.com/kernoeb/Telegramusic
- Owner: kernoeb
- License: mpl-2.0
- Created: 2020-09-27T08:46:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-07-08T17:50:45.000Z (11 months ago)
- Last Synced: 2025-07-08T18:57:51.848Z (11 months ago)
- Topics: bot, deezer, deezer-api, docker, flac, heroku, mp3, python, python3, soundcloud, telegram, telegram-bot, youtube, youtube-dl, zip
- Language: Python
- Homepage:
- Size: 137 KB
- Stars: 86
- Watchers: 6
- Forks: 54
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Telegramusic
A Telegram bot to download music from Deezer, YouTube and SoundCloud
## 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 `arl` cookie on Deezer for `DEEZER_TOKEN` (
see [this repo](https://github.com/nathom/streamrip/wiki/Finding-Your-Deezer-ARL-Cookie))
- Create a bot on Telegram and grab a token with [Bot Father](https://t.me/botfather) (`TELEGRAM_TOKEN`)
- Activate `Inline Mode` on BotFather for the bot you just created
---
Search for music in `inline mode` :
```
@xxxxxxx_bot (album|track)
```


## or send a Deezer / YouTube / SoundCloud link
## Configuration
### Docker
#### Prerequisites
- Docker ([Linux installation](https://docs.docker.com/engine/install/ubuntu/)
and [Linux post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/))
- 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
```bash
./update.sh
```
> Or manually : `git pull && docker-compose up -d --build`
### Local usage
- Add `DEEZER_TOKEN` and `TELEGRAM_TOKEN` as variable environment
- python3.13 -m pip install -r requirements.txt
- python3.13 main.py
> You should use a `venv` to 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 :
```yaml
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 : .
You don't need to restart the bot, it will automatically reload the cookies when downloading a YouTube video.
### Example configuration
```dotenv
# 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"
```bash
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
```