diff --git a/src/spotifyaio/models.py b/src/spotifyaio/models.py index 8fce915e..49591181 100644 --- a/src/spotifyaio/models.py +++ b/src/spotifyaio/models.py @@ -419,6 +419,12 @@ class PlaylistResponse(DataClassORJSONMixin): previous_list: str | None = field(metadata=field_options(alias="previous")) total: int + @classmethod + def __pre_deserialize__(cls, d: dict[str, Any]) -> dict[str, Any]: + """Pre deserialize hook.""" + items = [item for item in d["items"] if item is not None] + return {**d, "items": items} + @dataclass class FeaturedPlaylistResponse(DataClassORJSONMixin): diff --git a/tests/fixtures/current_user_playlist_1.json b/tests/fixtures/current_user_playlist_1.json index aedcda1d..af55f1b9 100644 --- a/tests/fixtures/current_user_playlist_1.json +++ b/tests/fixtures/current_user_playlist_1.json @@ -1,6 +1,7 @@ { "href": "https://api.spotify.com/v1/users/1112264649/playlists?offset=0&limit=20", "items": [ + null, { "collaborative": false, "description": "",