Fix: parsing of pls (radio) streams
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 17 Feb 2025 09:19:48 +0000 (10:19 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 17 Feb 2025 09:19:48 +0000 (10:19 +0100)
music_assistant/helpers/playlists.py

index 3c1244568e063196341bc9c8d2589f6a114105d8..f639d26f10d99420acba41755a280b0960a4a4a8 100644 (file)
@@ -110,7 +110,7 @@ def parse_m3u(m3u_data: str) -> list[PlaylistItem]:
 
 def parse_pls(pls_data: str) -> list[PlaylistItem]:
     """Parse (only) filenames/urls from pls playlist file."""
-    pls_parser = configparser.ConfigParser()
+    pls_parser = configparser.ConfigParser(strict=False)
     try:
         pls_parser.read_string(pls_data, "playlist")
     except configparser.Error as err:
@@ -169,10 +169,10 @@ async def fetch_playlist(
     ) or "#EXT-X-STREAM-INF:" in playlist_data:
         raise IsHLSPlaylist
 
-    if urlparse(url).path.endswith((".m3u", ".m3u8")):
-        playlist = parse_m3u(playlist_data)
-    else:
+    if urlparse(url).path.endswith("pls") or "[playlist]" in playlist_data:
         playlist = parse_pls(playlist_data)
+    else:
+        playlist = parse_m3u(playlist_data)
 
     if not playlist:
         msg = f"Empty playlist {url}"