def get_value(self, key: str) -> ConfigValueType:
"""Return config value for given key."""
config_value = self.values[key]
- if config_value.type == ConfigEntryType.SECURE_STRING:
+ if config_value.type == ConfigEntryType.SECURE_STRING and config_value.value:
assert isinstance(config_value.value, str)
assert DECRYPT_CALLBACK is not None
return DECRYPT_CALLBACK(config_value.value)
from music_assistant.server import MusicAssistant
from music_assistant.server.models import ProviderInstanceType
+CONF_CLIENT_ID = "client_id"
CACHE_DIR = gettempdir()
LIKED_SONGS_FAKE_PLAYLIST_ID_PREFIX = "liked_songs"
label="Password",
required=True,
),
+ ConfigEntry(
+ key=CONF_CLIENT_ID,
+ type=ConfigEntryType.SECURE_STRING,
+ label="Client ID",
+ description="By default, a generic client ID is used which is heavy rate limited. "
+ "It is advised that you create your own Spotify Developer account and use "
+ "that client ID here to speedup performance.",
+ required=False,
+ ),
)
"""Handle async initialization of the provider."""
self._cache_dir = CACHE_DIR
self._ap_workaround = False
- # try to get a token, raise if that fails
self._cache_dir = os.path.join(CACHE_DIR, self.instance_id)
+ if self.config.get_value(CONF_CLIENT_ID):
+ # loosen the throttler a bit when a custom client id is used
+ self.throttler.rate_limit = 45
+ self.throttler.period = 30
# try login which will raise if it fails
await self.login()
"-O",
"-t",
"--client-id",
- app_var(2),
+ self.config.get_value(CONF_CLIENT_ID) or app_var(2),
"--scope",
scope,
"-c",