Skip to content

Commit

Permalink
Merge pull request #236 from quodrum-glas/master-dev
Browse files Browse the repository at this point in the history
Fix Page Recursion into Categories
  • Loading branch information
tehkillerbee authored Feb 28, 2024
2 parents 979e6cc + 26b9797 commit 56e7358
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tidalapi/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def parse(self, json_obj: JsonObj) -> AllCategories:
elif category_type == "ARTIST_HEADER":
result = self.session.parse_artist(json_obj["artist"])
result.bio = json_obj["bio"]
return result
return ItemHeader(result)
elif category_type == "ALBUM_HEADER":
return self.session.parse_album(json_obj["album"])
return ItemHeader(self.session.parse_album(json_obj["album"]))
elif category_type == "HIGHLIGHT_MODULE":
category = ItemList(self.session)
elif category_type == "MIXED_TYPES_LIST":
Expand Down Expand Up @@ -362,6 +362,8 @@ def get(self) -> Union["Artist", "Playlist", "Track", "UserPlaylist", "Video"]:
return self.session.track(self.artifact_id)
elif self.type == "ARTIST":
return self.session.artist(self.artifact_id)
elif self.type == "ALBUM":
return self.session.album(self.artifact_id)
raise NotImplementedError(f"PageItem type {self.type} not implemented")


Expand Down Expand Up @@ -397,3 +399,12 @@ def parse(self, json_obj: JsonObj) -> "LinkList":
self.description = json_obj["description"]

return copy.copy(self)


class ItemHeader(object):
"""Single item in a "category" of the page."""

items: Optional[List[Any]] = None

def __init__(self, item: Any):
self.items = [item]

0 comments on commit 56e7358

Please sign in to comment.