From d6f6df715eb0a5c08cec955f8d90b033a881a714 Mon Sep 17 00:00:00 2001 From: Cropse Date: Sat, 23 Nov 2024 02:19:26 +0800 Subject: [PATCH 1/2] Update helpers.py Fix empty or banned track from recommanded track --- custom_components/spotcast/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/spotcast/helpers.py b/custom_components/spotcast/helpers.py index 649e67ea..1ffe8e7d 100644 --- a/custom_components/spotcast/helpers.py +++ b/custom_components/spotcast/helpers.py @@ -349,7 +349,7 @@ def search_tracks( def add_tracks_to_queue( spotify_client: spotipy.Spotify, tracks: list = [], limit: int = 20 ): - filtered = list(filter(lambda x: x["type"] == "track", tracks)) + filtered = list(filter(lambda x: x and x["type"] == "track", tracks)) if len(filtered) == 0: _LOGGER.debug("Cannot add ZERO tracks to the queue!") From e3bb6f2ce829bff313858eff71b368552b53f97d Mon Sep 17 00:00:00 2001 From: Cropse Date: Wed, 27 Nov 2024 01:14:11 +0800 Subject: [PATCH 2/2] Update custom_components/spotcast/helpers.py --- custom_components/spotcast/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/spotcast/helpers.py b/custom_components/spotcast/helpers.py index 1ffe8e7d..d34d7670 100644 --- a/custom_components/spotcast/helpers.py +++ b/custom_components/spotcast/helpers.py @@ -349,7 +349,7 @@ def search_tracks( def add_tracks_to_queue( spotify_client: spotipy.Spotify, tracks: list = [], limit: int = 20 ): - filtered = list(filter(lambda x: x and x["type"] == "track", tracks)) + filtered = list(filter(lambda x: isinstance(x, dict) and x.get("type") == "track", tracks)) if len(filtered) == 0: _LOGGER.debug("Cannot add ZERO tracks to the queue!")