✨ PKCE / OAuth login will be chosen on the fly, depending on the desired audio quality of the track to speed up non HIRES_LOSSLESS downloads. Quality for tracks in download queue can be chosen individually. Fixes #73

This commit is contained in:
Robert Honz
2024-04-21 15:58:31 +02:00
parent 1224e42689
commit f9862e0646
6 changed files with 73 additions and 16 deletions
+8 -2
View File
@@ -86,6 +86,7 @@ class Tidal(BaseConfig, metaclass=SingletonMeta):
session: tidalapi.Session
token_from_storage: bool = False
settings: Settings
is_pkce: bool
def __init__(self, settings: Settings = None):
self.cls_model = ModelToken
@@ -110,9 +111,13 @@ class Tidal(BaseConfig, metaclass=SingletonMeta):
return True
def login_token(self) -> bool:
def login_token(self, do_pkce: bool = True) -> bool:
result = False
# Do not login via PKCE, if HiRes LOSSLESS is not set as global audio quality.
if self.session.audio_quality != tidalapi.media.Quality.hi_res_lossless:
do_pkce = False
if self.token_from_storage:
try:
result = self.session.load_oauth_session(
@@ -120,8 +125,9 @@ class Tidal(BaseConfig, metaclass=SingletonMeta):
self.data.access_token,
self.data.refresh_token,
self.data.expiry_time,
is_pkce=True,
is_pkce=do_pkce,
)
self.is_pkce = do_pkce
except HTTPError:
result = False