From 26b9797ec0e39447664247a304380afca48e06c1 Mon Sep 17 00:00:00 2001 From: quodrumglas Date: Tue, 13 Feb 2024 09:49:03 +0000 Subject: [PATCH] Fix Page Recursion into Categories --- tidalapi/page.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tidalapi/page.py b/tidalapi/page.py index 6a046b1..5914d6f 100644 --- a/tidalapi/page.py +++ b/tidalapi/page.py @@ -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": @@ -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") @@ -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]