mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 19:15:25 +01:00
Remove needless '?' from endpoints
This commit is contained in:
parent
515022b60f
commit
6aa3f5fb0f
@ -33,28 +33,28 @@ class Client:
|
|||||||
self.cfg_setup()
|
self.cfg_setup()
|
||||||
|
|
||||||
def api_call(self, epoint, **kwargs):
|
def api_call(self, epoint, **kwargs):
|
||||||
if epoint == "user/login?":
|
if epoint == "user/login":
|
||||||
params = {
|
params = {
|
||||||
"email": kwargs["email"],
|
"email": kwargs["email"],
|
||||||
"password": kwargs["pwd"],
|
"password": kwargs["pwd"],
|
||||||
"app_id": self.id,
|
"app_id": self.id,
|
||||||
}
|
}
|
||||||
elif epoint == "track/get?":
|
elif epoint == "track/get":
|
||||||
params = {"track_id": kwargs["id"]}
|
params = {"track_id": kwargs["id"]}
|
||||||
elif epoint == "album/get?":
|
elif epoint == "album/get":
|
||||||
params = {"album_id": kwargs["id"]}
|
params = {"album_id": kwargs["id"]}
|
||||||
elif epoint == "track/search?":
|
elif epoint == "track/search":
|
||||||
params = {"query": kwargs["query"], "limit": kwargs["limit"]}
|
params = {"query": kwargs["query"], "limit": kwargs["limit"]}
|
||||||
elif epoint == "album/search?":
|
elif epoint == "album/search":
|
||||||
params = {"query": kwargs["query"], "limit": kwargs["limit"]}
|
params = {"query": kwargs["query"], "limit": kwargs["limit"]}
|
||||||
elif epoint == "playlist/get?":
|
elif epoint == "playlist/get":
|
||||||
params = {
|
params = {
|
||||||
"extra": "tracks",
|
"extra": "tracks",
|
||||||
"playlist_id": kwargs["id"],
|
"playlist_id": kwargs["id"],
|
||||||
"limit": 500,
|
"limit": 500,
|
||||||
"offset": kwargs["offset"],
|
"offset": kwargs["offset"],
|
||||||
}
|
}
|
||||||
elif epoint == "artist/get?":
|
elif epoint == "artist/get":
|
||||||
params = {
|
params = {
|
||||||
"app_id": self.id,
|
"app_id": self.id,
|
||||||
"artist_id": kwargs["id"],
|
"artist_id": kwargs["id"],
|
||||||
@ -62,14 +62,14 @@ class Client:
|
|||||||
"offset": kwargs["offset"],
|
"offset": kwargs["offset"],
|
||||||
"extra": "albums",
|
"extra": "albums",
|
||||||
}
|
}
|
||||||
elif epoint == "label/get?":
|
elif epoint == "label/get":
|
||||||
params = {
|
params = {
|
||||||
"label_id": kwargs["id"],
|
"label_id": kwargs["id"],
|
||||||
"limit": 500,
|
"limit": 500,
|
||||||
"offset": kwargs["offset"],
|
"offset": kwargs["offset"],
|
||||||
"extra": "albums",
|
"extra": "albums",
|
||||||
}
|
}
|
||||||
elif epoint == "userLibrary/getAlbumsList?":
|
elif epoint == "userLibrary/getAlbumsList":
|
||||||
unix = time.time()
|
unix = time.time()
|
||||||
r_sig = "userLibrarygetAlbumsList" + str(unix) + kwargs["sec"]
|
r_sig = "userLibrarygetAlbumsList" + str(unix) + kwargs["sec"]
|
||||||
r_sig_hashed = hashlib.md5(r_sig.encode("utf-8")).hexdigest()
|
r_sig_hashed = hashlib.md5(r_sig.encode("utf-8")).hexdigest()
|
||||||
@ -79,7 +79,7 @@ class Client:
|
|||||||
"request_ts": unix,
|
"request_ts": unix,
|
||||||
"request_sig": r_sig_hashed,
|
"request_sig": r_sig_hashed,
|
||||||
}
|
}
|
||||||
elif epoint == "track/getFileUrl?":
|
elif epoint == "track/getFileUrl":
|
||||||
unix = time.time()
|
unix = time.time()
|
||||||
track_id = kwargs["id"]
|
track_id = kwargs["id"]
|
||||||
fmt_id = kwargs["fmt_id"]
|
fmt_id = kwargs["fmt_id"]
|
||||||
@ -96,21 +96,21 @@ class Client:
|
|||||||
}
|
}
|
||||||
r = self.session.get(self.base + epoint, params=params)
|
r = self.session.get(self.base + epoint, params=params)
|
||||||
# Do ref header.
|
# Do ref header.
|
||||||
if epoint == "user/login?":
|
if epoint == "user/login":
|
||||||
if r.status_code == 401:
|
if r.status_code == 401:
|
||||||
raise AuthenticationError("Invalid credentials.")
|
raise AuthenticationError("Invalid credentials.")
|
||||||
elif r.status_code == 400:
|
elif r.status_code == 400:
|
||||||
raise InvalidAppIdError("Invalid app id.")
|
raise InvalidAppIdError("Invalid app id.")
|
||||||
else:
|
else:
|
||||||
print("Logged: OK")
|
print("Logged: OK")
|
||||||
elif epoint in ["track/getFileUrl?", "userLibrary/getAlbumsList?"]:
|
elif epoint in ["track/getFileUrl", "userLibrary/getAlbumsList"]:
|
||||||
if r.status_code == 400:
|
if r.status_code == 400:
|
||||||
raise InvalidAppSecretError("Invalid app secret.")
|
raise InvalidAppSecretError("Invalid app secret.")
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
def auth(self, email, pwd):
|
def auth(self, email, pwd):
|
||||||
usr_info = self.api_call("user/login?", email=email, pwd=pwd)
|
usr_info = self.api_call("user/login", email=email, pwd=pwd)
|
||||||
if not usr_info["user"]["credential"]["parameters"]:
|
if not usr_info["user"]["credential"]["parameters"]:
|
||||||
raise IneligibleError("Free accounts are not eligible to download tracks.")
|
raise IneligibleError("Free accounts are not eligible to download tracks.")
|
||||||
self.uat = usr_info["user_auth_token"]
|
self.uat = usr_info["user_auth_token"]
|
||||||
@ -135,32 +135,32 @@ class Client:
|
|||||||
offset += 500
|
offset += 500
|
||||||
|
|
||||||
def get_album_meta(self, id):
|
def get_album_meta(self, id):
|
||||||
return self.api_call("album/get?", id=id)
|
return self.api_call("album/get", id=id)
|
||||||
|
|
||||||
def get_track_meta(self, id):
|
def get_track_meta(self, id):
|
||||||
return self.api_call("track/get?", id=id)
|
return self.api_call("track/get", id=id)
|
||||||
|
|
||||||
def get_track_url(self, id, fmt_id):
|
def get_track_url(self, id, fmt_id):
|
||||||
return self.api_call("track/getFileUrl?", id=id, fmt_id=fmt_id)
|
return self.api_call("track/getFileUrl", id=id, fmt_id=fmt_id)
|
||||||
|
|
||||||
def get_artist_meta(self, id):
|
def get_artist_meta(self, id):
|
||||||
return self.multi_meta("artist/get?", "albums_count", id, None)
|
return self.multi_meta("artist/get", "albums_count", id, None)
|
||||||
|
|
||||||
def get_plist_meta(self, id):
|
def get_plist_meta(self, id):
|
||||||
return self.multi_meta("playlist/get?", "tracks_count", id, None)
|
return self.multi_meta("playlist/get", "tracks_count", id, None)
|
||||||
|
|
||||||
def get_label_meta(self, id):
|
def get_label_meta(self, id):
|
||||||
return self.multi_meta("label/get?", "albums_count", id, None)
|
return self.multi_meta("label/get", "albums_count", id, None)
|
||||||
|
|
||||||
def search_albums(self, query, limit):
|
def search_albums(self, query, limit):
|
||||||
return self.api_call("album/search?", query=query, limit=limit)
|
return self.api_call("album/search", query=query, limit=limit)
|
||||||
|
|
||||||
def search_tracks(self, query, limit):
|
def search_tracks(self, query, limit):
|
||||||
return self.api_call("track/search?", query=query, limit=limit)
|
return self.api_call("track/search", query=query, limit=limit)
|
||||||
|
|
||||||
def test_secret(self, sec):
|
def test_secret(self, sec):
|
||||||
try:
|
try:
|
||||||
r = self.api_call("userLibrary/getAlbumsList?", sec=sec)
|
r = self.api_call("userLibrary/getAlbumsList", sec=sec)
|
||||||
return True
|
return True
|
||||||
except InvalidAppSecretError:
|
except InvalidAppSecretError:
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user