Skip to content

Commit cea6bab

Browse files
committed
Only return warning if page itemtype (v2) is not implemented (Fixes: #362)
1 parent cc5b0f8 commit cea6bab

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

tidalapi/page.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919

2020
import copy
21+
import logging
2122
from dataclasses import dataclass
2223
from typing import (
2324
TYPE_CHECKING,
@@ -65,6 +66,8 @@
6566

6667
AllCategoriesV2 = Union[PageCategoriesV2]
6768

69+
log = logging.getLogger(__name__)
70+
6871

6972
class Page:
7073
"""
@@ -337,13 +340,16 @@ def __init__(self, session: "Session"):
337340
self.items: List[Any] = []
338341

339342
def parse(self, json_obj: "JsonObj"):
340-
self.items = [self.get_item(item) for item in json_obj["items"]]
343+
self.items = [
344+
self.get_item(item) for item in json_obj["items"] if item is not None
345+
]
341346
return self
342347

343348
def get_item(self, json_obj: "JsonObj") -> Any:
344349
item_type = json_obj.get("type")
345350
if item_type not in self.item_types:
346-
raise NotImplementedError(f"Item type '{item_type}' not implemented")
351+
log.warning(f"Item type '{item_type}' not implemented")
352+
return None
347353

348354
return self.item_types[item_type](json_obj["data"])
349355

tidalapi/user.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,9 @@ def get_artists_count(
594594
self,
595595
) -> int:
596596
"""Get the total number of artists in the user's collection.
597-
This performs a minimal API request (limit=1) to fetch metadata about
598-
the artists without retrieving all of them. The API response contains
597+
598+
This performs a minimal API request (limit=1) to fetch metadata about the
599+
artists without retrieving all of them. The API response contains
599600
'totalNumberOfItems', which represents the total items (artists) available.
600601
:return: The number of items available.
601602
"""
@@ -652,9 +653,10 @@ def get_albums_count(
652653
self,
653654
) -> int:
654655
"""Get the total number of albums in the user's collection.
655-
This performs a minimal API request (limit=1) to fetch metadata about
656-
the albums without retrieving all of them. The API response contains
657-
'totalNumberOfItems', which represents the total items (albums) available.
656+
657+
This performs a minimal API request (limit=1) to fetch metadata about the albums
658+
without retrieving all of them. The API response contains 'totalNumberOfItems',
659+
which represents the total items (albums) available.
658660
:return: The number of items available.
659661
"""
660662
params = {"limit": 1, "offset": 0}
@@ -766,8 +768,9 @@ def playlist_folders(
766768

767769
def get_playlists_count(self) -> int:
768770
"""Get the total number of playlists in the user's root collection.
769-
This performs a minimal API request (limit=1) to fetch metadata about
770-
the playlists without retrieving all of them. The API response contains
771+
772+
This performs a minimal API request (limit=1) to fetch metadata about the
773+
playlists without retrieving all of them. The API response contains
771774
'totalNumberOfItems', which represents the total playlists available.
772775
:return: The number of items available.
773776
"""
@@ -831,9 +834,10 @@ def get_tracks_count(
831834
self,
832835
) -> int:
833836
"""Get the total number of tracks in the user's collection.
834-
This performs a minimal API request (limit=1) to fetch metadata about
835-
the tracks without retrieving all of them. The API response contains
836-
'totalNumberOfItems', which represents the total items (tracks) available.
837+
838+
This performs a minimal API request (limit=1) to fetch metadata about the tracks
839+
without retrieving all of them. The API response contains 'totalNumberOfItems',
840+
which represents the total items (tracks) available.
837841
:return: The number of items available.
838842
"""
839843
params = {"limit": 1, "offset": 0}

0 commit comments

Comments
 (0)