diff options
Diffstat (limited to 'tidal_dl_ng/config.py')
| -rw-r--r-- | tidal_dl_ng/config.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tidal_dl_ng/config.py b/tidal_dl_ng/config.py index aa36cf6..ccf6766 100644 --- a/tidal_dl_ng/config.py +++ b/tidal_dl_ng/config.py @@ -101,6 +101,11 @@ class Tidal(BaseConfig, metaclass=SingletonMeta): self.cls_model = ModelToken tidal_config: tidalapi.Config = tidalapi.Config(item_limit=10000) self.session = tidalapi.Session(tidal_config) + # The default tidalapi OAuth client does not have lossless / hi-res + # streaming entitlements. Use the Android Atmos client for the main + # session; it supports lossless stereo as well as Dolby Atmos. + self.session.config.client_id = ATMOS_CLIENT_ID + self.session.config.client_secret = ATMOS_CLIENT_SECRET self.original_client_id = self.session.config.client_id self.original_client_secret = self.session.config.client_secret # Lock to ensure session-switching is thread-safe. @@ -114,8 +119,6 @@ class Tidal(BaseConfig, metaclass=SingletonMeta): # session re-authentication when the session is already in the # correct mode (Atmos or Normal). self.is_atmos_session = False - # self.session.config.client_id = "km8T1xS355y7dd3H" - # self.session.config.client_secret = "vcmeGW1OuZ0fWYMCSZ6vNvSLJlT3XEpW0ambgYt5ZuI=" self.file_path = path_file_token() self.token_from_storage = self.read(self.file_path) @@ -146,6 +149,15 @@ class Tidal(BaseConfig, metaclass=SingletonMeta): self.data.expiry_time, is_pkce=do_pkce, ) + + if result and self.data.refresh_token: + # Existing tokens were issued for the previous default client + # which lacks lossless entitlements. Refresh the token so it + # is bound to the current (lossless-capable) client. + result = self.session.token_refresh(self.data.refresh_token) + + if result: + self.token_persist() except Exception: result = False # Remove token file. Probably corrupt or invalid. |
