Replace windows separators in m3u (#1471)
authorMelvyn Harbour <melharbour@gmail.com>
Mon, 8 Jul 2024 12:58:48 +0000 (13:58 +0100)
committerGitHub <noreply@github.com>
Mon, 8 Jul 2024 12:58:48 +0000 (14:58 +0200)
music_assistant/server/helpers/playlists.py

index 62a7a8fa5bbffd9d9d7ca61115332d958b7e5ff2..05442da740dfa13594cdd20379d829f934edca30 100644 (file)
@@ -86,12 +86,15 @@ def parse_m3u(m3u_data: str) -> list[PlaylistItem]:
             # Ignore other extensions
             continue
         elif len(line) != 0:
-            if "%20" in line:
+            filepath = line
+            if "%20" in filepath:
                 # apparently VLC manages to encode spaces in filenames
-                line = line.replace("%20", " ")  # noqa: PLW2901
+                filepath = filepath.replace("%20", " ")
+            # replace Windows directory separators
+            filepath = filepath.replace("\\", "/")
             playlist.append(
                 PlaylistItem(
-                    path=line, length=length, title=title, stream_info=stream_info, key=key
+                    path=filepath, length=length, title=title, stream_info=stream_info, key=key
                 )
             )
             # reset the song variables so it doesn't use the same EXTINF more than once