Sync currently playing Spotify track to Telegram
330
Sync your Spotify listening state into Telegram Music on Profiles - upload and pin tracks to your Telegram
Saved Messagesso anyone who sees your profile can see what you're sharing.
tdata folder (desktop Telegram data).
(left: Spotify, right: Telegram - shows how the sync flows)
Run the image from Docker Hub (recommended):
docker run -d \
--name spotify-telegram-sync \
-p 7000:7000 \
-v /root/session.session:/app/session.session \
-e SPOTIFY_CLIENT_SECRET="<YOUR_SPOTIFY_CLIENT_SECRET>" \
-e SPOTIFY_CLIENT_ID="<YOUR_SPOTIFY_CLIENT_ID>" \
-e SPOTIFY_REDIRECT_URI="http://127.0.0.1:7000/callback" \
-e SPOTIFY_SCOPE="user-read-currently-playing" \
-e SPOTIFY_REFRESH_TOKEN="<OPTIONAL_REFRESH_TOKEN>" \
-e TELEGRAM_API_ID="<YOUR_TELEGRAM_API_ID>" \
-e TELEGRAM_API_HASH="<YOUR_TELEGRAM_API_HASH>" \
-e TRACKS_CACHE_SIZE=20 \
-e TRACKS_DOWNLOAD_WORKERS=2 \
-e TRACKS_BACKEND=mixed_track_backend.MixedTrackBackend \
-e CLEAN_TRACKS=True \
therepanic/spotify-telegram-sync:latest
Note
The command above uses placeholders. Do **not** commit or publish your actual `SPOTIFY_CLIENT_SECRET`, `SPOTIFY_CLIENT_ID`, `TELEGRAM_API_HASH`, or refresh tokens. Store sensitive values securely.
If you prefer to build locally:
# from project root
docker build -t spotify-telegram-sync:latest .
# then run the same docker run command (replace image name)
| Variable | Required | Default | Description |
|---|---|---|---|
SPOTIFY_CLIENT_SECRET | Yes | - | Spotify app client secret (from https://developer.spotify.com/dashboard). |
SPOTIFY_CLIENT_ID | Yes | - | Spotify app client id. |
SPOTIFY_REDIRECT_URI | Yes | - | Redirect URI registered in Spotify app. |
SPOTIFY_SCOPE | No | user-read-currently-playing | Spotify scopes. Only user-read-currently-playing is required by default. |
SPOTIFY_REFRESH_TOKEN | No | - | Optional. If you already have a refresh token you can provide it to avoid manual browser login on remote machines. |
TELEGRAM_API_ID | Yes | - | Telegram API ID (create at https://my.telegram.org/apps). |
TELEGRAM_API_HASH | Yes | - | Telegram API hash (from same place). |
TRACKS_CACHE_SIZE | No | 20 | Number of most-recent tracks to keep pinned in Telegram. Older tracks are automatically removed. |
TRACKS_DOWNLOAD_WORKERS | No | 2 | Number of parallel background workers used for delayed audio downloads in mixed mode. |
TRACKS_BACKEND | No | mixed_track_backend.MixedTrackBackend | Backend used to fetch/download tracks. |
CLEAN_TRACKS | No | true | If true, tracks are removed from Telegram when the Spotify session ends. |
TRACKS_BACKEND controls where track audio and metadata are obtained from. Three backends are supported:
mixed_track_backend.MixedTrackBackend - default. Uploads a zero-duration placeholder immediately and then tries to replace that exact slot later with the original audio from spotdl.spotdl_track_backend.SpotdlTrackBackend - original-only mode. Uses spotdl logic to locate and download audio for the requested Spotify track.zero_track_backend.ZeroTrackBackend - fallback. If no backend can find/download the actual audio, this backend uploads a message to Telegram containing the track metadata and cover art but no audio (the uploaded track will have 0 seconds duration).You must provide a Telegram session. Two supported ways:
Telethon session file (recommended):
-v /root/session.session:/app/session.session
tdata folder from your Desktop Telegram installation (Opentele will convert it to a Telethon session automatically):
-v /root/tdata:/app/tdata
If neither is present, the container will walk you through the auth flow on first run (it depends on Telethon/opentele capabilities).
CLIENT_ID, CLIENT_SECRET and set a REDIRECT_URI (e.g. http://127.0.0.1:7000/callback).API_ID and API_HASH.http://<HOST>:7000/auth in your browser and follow the Spotify authorization flow.refresh_token (if you need one to run headlessly, copy it from the logs and set SPOTIFY_REFRESH_TOKEN in your run command on the remote machine).Important
If you already have a valid refresh token you can skip the web flow and set `SPOTIFY_REFRESH_TOKEN` before starting.
spotipy).mixed) prepares a track file or uploadable content.Saved Messages and pinned. When a track falls out of the cache window or is unpinned/removed, the service deletes it from Saved Messages.This gives the visual effect of "Music on Profiles" - tracks remain visible while they are inside the configured cache window.
session.session or tdata is correctly mounted and readable by the container. Check container logs for Telethon errors.SPOTIFY_REDIRECT_URI exactly matches the redirect in your Spotify app settings./auth flow and watch the container logs carefully after completing the browser authorization; the refresh token is printed once.TRACKS_BACKEND configuration and ensure spotdl dependencies are present in the image (they are required for the default mixed mode and for spotdl-only mode). Also verify network access.Contributions are welcome. Open an issue or a pull request with a clear description of the change. If you add backends or make changes to defaults, please update this README.
This project is Unlicensed.
Content type
Image
Digest
sha256:a7e40d5c0…
Size
487.8 MB
Last updated
5 months ago
docker pull therepanic/spotify-telegram-sync