summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/config.py
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-04-21 15:58:31 +0200
committerRobert Honz <exislow+github@gmail.com>2024-04-21 15:58:31 +0200
commitf9862e0646032628923dc696afb0fe04884eddfb (patch)
tree266a029363b050998eb2227d59cdde68f3db80f7 /tidal_dl_ng/config.py
parent1224e42689e27fb75b5a4a742ac37f66e1c6eb07 (diff)
downloadtidal-dl-ng-f9862e0646032628923dc696afb0fe04884eddfb.tar.gz
✨ 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
Diffstat (limited to 'tidal_dl_ng/config.py')
-rw-r--r--tidal_dl_ng/config.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tidal_dl_ng/config.py b/tidal_dl_ng/config.py
index 7258c8f..7b86f1c 100644
--- a/tidal_dl_ng/config.py
+++ b/tidal_dl_ng/config.py
@@ -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