Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tehkillerbee committed Sep 5, 2024
1 parent 12f8266 commit ebe820a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 8 additions & 10 deletions tidalapi/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def request(
self.latest_err_response = request
if request.content:
resp = request.json()
log.debug("Request response: '%s'", resp['errors'][0]['detail'])
log.debug("Request response: '%s'", resp["errors"][0]["detail"])
if request.status_code and request.status_code == 404:
raise ObjectNotFound
elif request.status_code and request.status_code == 429:
Expand All @@ -165,23 +165,21 @@ def request(
return request

def get_latest_err_response(self) -> dict:
"""Get the latest request Response that resulted in an Exception
:return: The request Response that resulted in the Exception, returned as a dict
An empty dict will be returned, if no response was returned
"""
"""Get the latest request Response that resulted in an Exception :return: The
request Response that resulted in the Exception, returned as a dict An empty
dict will be returned, if no response was returned."""
if self.latest_err_response.content:
return self.latest_err_response.json()
else:
return {}

def get_latest_err_response_str(self) -> str:
"""Get the latest request response message as a string
:return: The contents of the (detailed) error response Response, returned as a string
An empty str will be returned, if no response was returned
"""
"""Get the latest request response message as a string :return: The contents of
the (detailed) error response Response, returned as a string An empty str will
be returned, if no response was returned."""
if self.latest_err_response.content:
resp = self.latest_err_response.json()
return resp['errors'][0]['detail']
return resp["errors"][0]["detail"]
else:
return ""

Expand Down
14 changes: 8 additions & 6 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,13 @@ def get_tracks_by_isrc(self, isrc: str) -> list[media.Track]:
An empty list will be returned if no tracks matches the ISRC
"""
try:
params = {
"filter[isrc]": isrc,
}
res = self.request.request(
"GET",
"tracks",
params={
"filter[isrc]": isrc,
},
params=params,
base_url=self.config.openapi_v2_location,
).json()
if res["data"]:
Expand All @@ -899,12 +900,13 @@ def get_albums_by_barcode(self, barcode: str) -> list[album.Album]:
An empty list will be returned if no tracks matches the ISRC
"""
try:
params = {
"filter[barcodeId]": barcode,
}
res = self.request.request(
"GET",
"albums",
params={
"filter[barcodeId]": barcode,
},
params=params,
base_url=self.config.openapi_v2_location,
).json()
if res["data"]:
Expand Down

0 comments on commit ebe820a

Please sign in to comment.