/
/
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
13CONF_ACCOUNT_ID = "account_id" # Spotify user id this instance serves (one instance per account)
14
15# Librespot playback authorization
16#
17# Spotify's login5 endpoint only accepts a stored credential that was minted with the same
18# client id librespot presents, which is always Spotify's own "keymaster" id. A credential
19# minted with MA's (or a user's) client id is rejected, so the playback credential has to be
20# obtained separately from the Web API tokens.
21KEYMASTER_CLIENT_ID = "65b708073fc0480ea92a077233ca87bd"
22LIBRESPOT_SCOPE = ["streaming"]
23# keymaster accepts loopback redirect URIs only, so the browser flow cannot use MA's hosted
24# callback. Music Assistant serves the loopback target itself, which works when the browser
25# runs on the same host; otherwise the browser lands on a dead URL that the user pastes back.
26LIBRESPOT_REDIRECT_PORT = 5588
27LIBRESPOT_REDIRECT_PATH = "/login"
28LIBRESPOT_REDIRECT_URI = f"http://127.0.0.1:{LIBRESPOT_REDIRECT_PORT}{LIBRESPOT_REDIRECT_PATH}"
29LOOPBACK_WAIT_TIMEOUT = 30 # seconds before offering the manual paste instead
30# name advertised to the Spotify app while pairing; also shown in the setup flow instructions
31PAIRING_DEVICE_NAME = "Music Assistant Pairing"
32PAIRING_TIMEOUT = 300 # seconds the pairing step waits for the user to pick the device
33CHECK_AUTH_TIMEOUT = 30 # seconds
34CREDENTIALS_FILE = "credentials.json"
35
36# OAuth Settings
37SCOPE = [
38 "playlist-read-private",
39 "playlist-read-collaborative",
40 "playlist-modify-public",
41 "playlist-modify-private",
42 "user-follow-modify",
43 "user-follow-read",
44 "user-library-read",
45 "user-library-modify",
46 "user-read-private",
47 "user-read-email",
48 "user-top-read",
49 "app-remote-control",
50 "streaming",
51 "user-read-playback-state",
52 "user-modify-playback-state",
53 "user-read-currently-playing",
54 "user-read-playback-position",
55 "user-read-recently-played",
56]
57
58# Other Constants
59LIKED_SONGS_FAKE_PLAYLIST_ID_PREFIX = "liked_songs"
60