Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Page Recursion into Categories #236

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]