Soundcloud: Fallback to the track details for missing entries in playlists (#2063)
authorRob Sonke <rob@tigrou.nl>
Thu, 27 Mar 2025 11:40:23 +0000 (12:40 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Mar 2025 11:40:23 +0000 (12:40 +0100)
music_assistant/providers/soundcloud/__init__.py

index e0363ed9918608f0954e6db3e17eadafc3c665fc..c3dfaedcf29a821b8341583e4bfd2fc540316b53 100644 (file)
@@ -264,11 +264,15 @@ class SoundcloudMusicProvider(MusicProvider):
         for index, item in enumerate(playlist_obj["tracks"], 1):
             try:
                 # Skip some ugly "tracks" entries, example:
-                # {'id': 123, 'kind': 'track', 'monetization_model': 'NOT_APPLICABLE',
-                # 'policy': 'ALLOW'}
+                # {'id': 123, 'kind': 'track', 'monetization_model': 'NOT_APPLICABLE'}
                 if "title" in item:
                     if track := await self._parse_track(item, index):
                         result.append(track)
+                # But also try to get the track details if the track is not in the playlist
+                else:
+                    track_details = await self._soundcloud.get_track_details(item["id"])
+                    if track := await self._parse_track(track_details[0], index):
+                        result.append(track)
             except (KeyError, TypeError, InvalidDataError, IndexError) as error:
                 self.logger.debug("Parse track failed: %s", item, exc_info=error)
                 continue