Skip to content

Commit 47a1823

Browse files
committed
make mixed track backend the default
1 parent cee700c commit 47a1823

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ docker run -d \
4444
-e TELEGRAM_API_HASH="<YOUR_TELEGRAM_API_HASH>" \
4545
-e TRACKS_CACHE_SIZE=20 \
4646
-e TRACKS_DOWNLOAD_WORKERS=2 \
47-
-e TRACKS_BACKEND=spotdl_track_backend.SpotdlTrackBackend \
47+
-e TRACKS_BACKEND=mixed_track_backend.MixedTrackBackend \
4848
-e CLEAN_TRACKS=True \
4949
therepanic/spotify-telegram-sync:latest
5050
```
@@ -64,27 +64,27 @@ docker build -t spotify-telegram-sync:latest .
6464

6565
## Environment variables / configuration
6666

67-
| Variable | Required | Default | Description |
68-
| ------------------------- | :------: | :---------------------------------------: | -------------------------------------------------------------------------------------------------------------------- |
69-
| `SPOTIFY_CLIENT_SECRET` | Yes | - | Spotify app client secret (from [https://developer.spotify.com/dashboard](https://developer.spotify.com/dashboard)). |
70-
| `SPOTIFY_CLIENT_ID` | Yes | - | Spotify app client id. |
71-
| `SPOTIFY_REDIRECT_URI` | Yes | - | Redirect URI registered in Spotify app. |
72-
| `SPOTIFY_SCOPE` | No | `user-read-currently-playing` | Spotify scopes. Only `user-read-currently-playing` is required by default. |
73-
| `SPOTIFY_REFRESH_TOKEN` | No | - | Optional. If you already have a refresh token you can provide it to avoid manual browser login on remote machines. |
74-
| `TELEGRAM_API_ID` | Yes | - | Telegram API ID (create at [https://my.telegram.org/apps](https://my.telegram.org/apps)). |
75-
| `TELEGRAM_API_HASH` | Yes | - | Telegram API hash (from same place). |
76-
| `TRACKS_CACHE_SIZE` | No | `20` | Number of most-recent tracks to keep pinned in Telegram. Older tracks are automatically removed. |
77-
| `TRACKS_DOWNLOAD_WORKERS` | No | `2` | Number of parallel background workers used for delayed audio downloads in mixed mode. |
78-
| `TRACKS_BACKEND` | No | `spotdl_track_backend.SpotdlTrackBackend` | Backend used to fetch/download tracks. |
79-
| `CLEAN_TRACKS` | No | `true` | If `true`, tracks are removed from Telegram when the Spotify session ends. |
67+
| Variable | Required | Default | Description |
68+
| ------------------------- | :------: | :-------------------------------------: | -------------------------------------------------------------------------------------------------------------------- |
69+
| `SPOTIFY_CLIENT_SECRET` | Yes | - | Spotify app client secret (from [https://developer.spotify.com/dashboard](https://developer.spotify.com/dashboard)). |
70+
| `SPOTIFY_CLIENT_ID` | Yes | - | Spotify app client id. |
71+
| `SPOTIFY_REDIRECT_URI` | Yes | - | Redirect URI registered in Spotify app. |
72+
| `SPOTIFY_SCOPE` | No | `user-read-currently-playing` | Spotify scopes. Only `user-read-currently-playing` is required by default. |
73+
| `SPOTIFY_REFRESH_TOKEN` | No | - | Optional. If you already have a refresh token you can provide it to avoid manual browser login on remote machines. |
74+
| `TELEGRAM_API_ID` | Yes | - | Telegram API ID (create at [https://my.telegram.org/apps](https://my.telegram.org/apps)). |
75+
| `TELEGRAM_API_HASH` | Yes | - | Telegram API hash (from same place). |
76+
| `TRACKS_CACHE_SIZE` | No | `20` | Number of most-recent tracks to keep pinned in Telegram. Older tracks are automatically removed. |
77+
| `TRACKS_DOWNLOAD_WORKERS` | No | `2` | Number of parallel background workers used for delayed audio downloads in mixed mode. |
78+
| `TRACKS_BACKEND` | No | `mixed_track_backend.MixedTrackBackend` | Backend used to fetch/download tracks. |
79+
| `CLEAN_TRACKS` | No | `true` | If `true`, tracks are removed from Telegram when the Spotify session ends. |
8080

8181
### Track backends
8282

8383
`TRACKS_BACKEND` controls where track audio and metadata are obtained from. Three backends are supported:
8484

85-
- `spotdl_track_backend.SpotdlTrackBackend` - **default**. Uses `spotdl` logic to locate and download audio for the requested Spotify track.
85+
- `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`.
86+
- `spotdl_track_backend.SpotdlTrackBackend` - **original-only mode**. Uses `spotdl` logic to locate and download audio for the requested Spotify track.
8687
- `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).
87-
- `mixed_track_backend.MixedTrackBackend` - **hybrid mode**. Uploads a zero-duration placeholder immediately and then tries to replace that exact slot later with the original audio from `spotdl`.
8888

8989
### Session volume (Telegram auth)
9090

@@ -121,7 +121,7 @@ If neither is present, the container will walk you through the auth flow on firs
121121
## How it works (high level)
122122

123123
1. The service reads your Spotify playback / currently playing via the Web API (`spotipy`).
124-
2. For tracks that should be shown, the configured backend (default: `spotdl`) prepares a track file or uploadable content.
124+
2. For tracks that should be shown, the configured backend (default: `mixed`) prepares a track file or uploadable content.
125125
3. In mixed mode, the service first uploads a zero-duration placeholder and upgrades it later if the original audio download succeeds.
126126
4. The track is uploaded to your Telegram `Saved Messages` and pinned. When a track falls out of the cache window or is unpinned/removed, the service deletes it from `Saved Messages`.
127127

@@ -134,7 +134,7 @@ This gives the visual effect of "Music on Profiles" - tracks remain visible whil
134134
- **No Telegram session / auth fails**: ensure `session.session` or `tdata` is correctly mounted and readable by the container. Check container logs for Telethon errors.
135135
- **Spotify auth redirect fails**: confirm `SPOTIFY_REDIRECT_URI` exactly matches the redirect in your Spotify app settings.
136136
- **No refresh token in logs**: re-run the `/auth` flow and watch the container logs carefully after completing the browser authorization; the refresh token is printed once.
137-
- **Tracks not uploaded**: check the `TRACKS_BACKEND` configuration and ensure `spotdl` dependencies are present in the image (they are in the default image). Also verify network access.
137+
- **Tracks not uploaded**: check the `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.
138138

139139
---
140140

src/spotify-telegram-sync/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
def load_backend_from_env():
5151
backend_path = (
52-
os.getenv("TRACKS_BACKEND") or "spotdl_track_backend.SpotdlTrackBackend"
52+
os.getenv("TRACKS_BACKEND") or "mixed_track_backend.MixedTrackBackend"
5353
)
5454
full_backend_path = "backend." + backend_path
5555
module_path, class_name = full_backend_path.rsplit(".", 1)

0 commit comments

Comments
 (0)