Ignore a guid containing spaces in podcasts parsing (#2238)
authorFabian Munkes <105975993+fmunkes@users.noreply.github.com>
Mon, 23 Jun 2025 10:27:31 +0000 (12:27 +0200)
committerGitHub <noreply@github.com>
Mon, 23 Jun 2025 10:27:31 +0000 (12:27 +0200)
music_assistant/helpers/podcast_parsers.py
music_assistant/providers/gpodder/__init__.py
music_assistant/providers/itunes_podcasts/__init__.py

index 1f141498cb88fd2beb902f0ed034ce49f9f5938f..d471cd201e43447623a970ea028623c326cca12d 100644 (file)
@@ -83,6 +83,13 @@ def get_stream_url_and_guid_from_episode(*, episode: dict[str, Any]) -> tuple[st
         raise ValueError("Episode enclosure is missing")
     if stream_url := episode_enclosures[0].get("url"):
         guid = episode.get("guid")
+        if guid is not None:
+            # The media's item_id is {prov_podcast_id} {guid_or_stream_url}
+            # see parse_podcast_episode.
+            # However, the guid must not contain a space, otherwise it is invalid.
+            # We cannot check, if it is a proper guid (uuid.UUID4(...)), as some podcast feeds
+            # do not follow the standard.
+            guid = None if len(guid.split(" ")) > 1 else guid
         return stream_url, guid
     raise ValueError("Stream URL is missing.")
 
@@ -120,7 +127,8 @@ def parse_podcast_episode(
     except ValueError:
         # we are missing the episode enclosure or stream information
         return None
-    guid_or_stream_url = guid if guid is not None else stream_url
+    # We treat a guid as invalid if contains a space.
+    guid_or_stream_url = guid if guid is not None and len(guid.split(" ")) == 1 else stream_url
 
     # Default episode id. A guid is preferred as identification.
     episode_id = f"{prov_podcast_id} {guid_or_stream_url}" if mass_item_id is None else mass_item_id
index 7c964f6792b4a07d1d9bf88d3212c12e0126ebf9..8d1112ef0613ab70064048b35e581017dce6f8a8 100644 (file)
@@ -612,7 +612,12 @@ class GPodder(MusicProvider):
             if len(episode_enclosures) < 1:
                 raise MediaNotFoundError
             stream_url: str | None = episode_enclosures[0].get("url", None)
-            if guid_or_stream_url == episode.get("guid", stream_url):
+            guid = episode.get("guid")
+            if guid is not None and len(guid.split(" ")) == 1:
+                _guid_or_stream_url_compare = guid
+            else:
+                _guid_or_stream_url_compare = stream_url
+            if guid_or_stream_url == _guid_or_stream_url_compare:
                 return stream_url
         return None
 
index a258a901afd1fac9aa907dea079b4fe53578d234..ce0a3f243a56a60cf7893928750937a424d25094 100644 (file)
@@ -275,7 +275,12 @@ class ITunesPodcastsProvider(MusicProvider):
             if len(episode_enclosures) < 1:
                 raise MediaNotFoundError
             stream_url: str | None = episode_enclosures[0].get("url", None)
-            if guid_or_stream_url == episode.get("guid", stream_url):
+            guid = episode.get("guid")
+            if guid is not None and len(guid.split(" ")) == 1:
+                _guid_or_stream_url_compare = guid
+            else:
+                _guid_or_stream_url_compare = stream_url
+            if guid_or_stream_url == _guid_or_stream_url_compare:
                 return stream_url
         return None