Skip to content

Commit

Permalink
Add error verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
vitiko98 committed Nov 26, 2021
1 parent 3a24a46 commit e586e7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions qobuz_dl/qopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, email, pwd, app_id, secrets):
}
)
self.base = "https://www.qobuz.com/api.json/0.2/"
self.sec = None
self.auth(email, pwd)
self.cfg_setup()

Expand Down Expand Up @@ -109,9 +110,11 @@ def api_call(self, epoint, **kwargs):
raise InvalidAppIdError("Invalid app id.\n" + RESET)
else:
logger.info(f"{GREEN}Logged: OK")
elif epoint in ["track/getFileUrl", "userLibrary/getAlbumsList"]:
elif epoint in ["track/getFileUrl", "favorite/getUserFavorites"]:
if r.status_code == 400:
raise InvalidAppSecretError("Invalid app secret.\n" + RESET)
raise InvalidAppSecretError(
f"Invalid app secret: {r.json()}.\n" + RESET
)
r.raise_for_status()
return r.json()

Expand Down Expand Up @@ -190,16 +193,17 @@ def get_user_playlists(self, limit):

def test_secret(self, sec):
try:
r = self.api_call("favorite/getUserFavorites", sec=sec)
self.api_call("favorite/getUserFavorites", sec=sec)
return True
except InvalidAppSecretError:
except InvalidAppSecretError as error:
logger.info("Invalid SECRET: %s", error)
return False

def cfg_setup(self):
for secret in self.secrets:
if secret:
if self.test_secret(secret):
self.sec = secret
break
if not hasattr(self, "sec"):
if secret and self.test_secret(secret):
self.sec = secret
break

if self.sec is None:
raise InvalidAppSecretError("Invalid app secret.\n" + RESET)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read_file(fname):

setup(
name=pkg_name,
version="0.9.9.3",
version="0.9.9.4",
author="Vitiko",
author_email="[email protected]",
description="The complete Lossless and Hi-Res music downloader for Qobuz",
Expand Down

0 comments on commit e586e7d

Please sign in to comment.