/
/
1"""Constants for the Spotify provider."""
2
3from __future__ import annotations
4
5# Configuration Keys
6CONF_CLIENT_ID = "client_id"
7CONF_REFRESH_TOKEN_DEPRECATED = "refresh_token" # Legacy key for migration, will be removed
8CONF_REFRESH_TOKEN_GLOBAL = "refresh_token_global" # Token authenticated with MA's client ID
9CONF_REFRESH_TOKEN_DEV = "refresh_token_dev" # Token authenticated with user's custom client ID
10CONF_SYNC_PODCAST_PROGRESS = "sync_podcast_progress"
11CONF_SYNC_AUDIOBOOK_PROGRESS = "sync_audiobook_progress"
12CONF_LIBRESPOT_CREDENTIALS = "librespot_credentials" # librespot's reusable stored credential
13
14# Librespot playback authorization
15#
16# Spotify's login5 endpoint only accepts a stored credential that was minted with the same
17# client id librespot presents, which is always Spotify's own "keymaster" id. A credential
18# minted with MA's (or a user's) client id is rejected, so the playback credential has to be
19# obtained separately from the Web API tokens.
20KEYMASTER_CLIENT_ID = "65b708073fc0480ea92a077233ca87bd"
21LIBRESPOT_SCOPE = ["streaming"]
22# keymaster accepts loopback redirect URIs only, so the browser flow cannot use MA's hosted
23# callback. Music Assistant serves the loopback target itself, which works when the browser
24# runs on the same host; otherwise the browser lands on a dead URL that the user pastes back.
25LIBRESPOT_REDIRECT_PORT = 5588
26LIBRESPOT_REDIRECT_PATH = "/login"
27LIBRESPOT_REDIRECT_URI = f"http://127.0.0.1:{LIBRESPOT_REDIRECT_PORT}{LIBRESPOT_REDIRECT_PATH}"
28LOOPBACK_WAIT_TIMEOUT = 30 # seconds before offering the manual paste instead
29# name advertised to the Spotify app while pairing; also shown in the setup flow instructions
30PAIRING_DEVICE_NAME = "Music Assistant Pairing"
31PAIRING_TIMEOUT = 300 # seconds the pairing step waits for the user to pick the device
32CHECK_AUTH_TIMEOUT = 30 # seconds
33CREDENTIALS_FILE = "credentials.json"
34
35# OAuth Settings
36SCOPE = [
37 "playlist-read-private",
38 "playlist-read-collaborative",
39 "playlist-modify-public",
40 "playlist-modify-private",
41 "user-follow-modify",
42 "user-follow-read",
43 "user-library-read",
44 "user-library-modify",
45 "user-read-private",
46 "user-read-email",
47 "user-top-read",
48 "app-remote-control",
49 "streaming",
50 "user-read-playback-state",
51 "user-modify-playback-state",
52 "user-read-currently-playing",
53 "user-read-playback-position",
54 "user-read-recently-played",
55]
56
57# Other Constants
58LIKED_SONGS_FAKE_PLAYLIST_ID_PREFIX = "liked_songs"
59