Skip to content

Commit 8e64a4c

Browse files
authored
Filter out unavailable playlists (#420)
1 parent bd7b57e commit 8e64a4c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/spotifyaio/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ class PlaylistResponse(DataClassORJSONMixin):
419419
previous_list: str | None = field(metadata=field_options(alias="previous"))
420420
total: int
421421

422+
@classmethod
423+
def __pre_deserialize__(cls, d: dict[str, Any]) -> dict[str, Any]:
424+
"""Pre deserialize hook."""
425+
items = [item for item in d["items"] if item is not None]
426+
return {**d, "items": items}
427+
422428

423429
@dataclass
424430
class FeaturedPlaylistResponse(DataClassORJSONMixin):

tests/fixtures/current_user_playlist_1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"href": "https://api.spotify.com/v1/users/1112264649/playlists?offset=0&limit=20",
33
"items": [
4+
null,
45
{
56
"collaborative": false,
67
"description": "",

0 commit comments

Comments
 (0)