From 74344702165c1ef11b5491ec831baaa150c1fbfd Mon Sep 17 00:00:00 2001 From: KitDaCatsun <45962810+KitDaCatsun@users.noreply.github.com> Date: Mon, 25 Jul 2022 10:17:04 +0100 Subject: [PATCH] Made errors in __post__ throw after 3 attempts `range(3)` gives `0, 1, 2` so `index >= 3` would never be reached. Assuming intended behavior was to throw if an error occurs on the third try and ignore errors on the first and second --- TIDALDL-PY/tidal_dl/tidal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TIDALDL-PY/tidal_dl/tidal.py b/TIDALDL-PY/tidal_dl/tidal.py index 98ee229..105e4ae 100644 --- a/TIDALDL-PY/tidal_dl/tidal.py +++ b/TIDALDL-PY/tidal_dl/tidal.py @@ -28,6 +28,7 @@ class TidalAPI(object): 'clientSecret': 'vRAdA108tlvkJpTsGZS8rGZ7xTlbJ0qaZ2K9saEzsgY='} def __get__(self, path, params={}, urlpre='https://api.tidalhifi.com/v1/'): + header = {} header = {'authorization': f'Bearer {self.key.accessToken}'} params['countryCode'] = self.key.countryCode errmsg = "Get operation err!" @@ -86,12 +87,12 @@ class TidalAPI(object): return ret def __post__(self, path, data, auth=None, urlpre='https://auth.tidal.com/v1/oauth2'): - for index in range(0, 3): + for index in range(3): try: result = requests.post(urlpre+path, data=data, auth=auth, verify=False).json() return result except Exception as e: - if index >= 3: + if index == 2: raise e def getDeviceCode(self) -> str: