]> git.poda.fr Git - converter.git/commitdiff
Stop if an invalid track is found in a playlist. xspf: Handle locations starting...
authorJulien <julien@poda.fr>
Sat, 8 Feb 2025 12:25:41 +0000 (13:25 +0100)
committerJulien <julien@poda.fr>
Sat, 8 Feb 2025 12:25:41 +0000 (13:25 +0100)
converter.py

index 7055417c91e859541653ab1920164ed98dff114f..6d0152ee48a71c9de22568e314bdbd54c4a05b16 100755 (executable)
@@ -271,7 +271,7 @@ class Converter:
         libPlaylists: dict[str, LibraryPlaylist] = self._createLibraryPlaylists(convertParams.playlistDir)
 
         if len(libPlaylists) == 0:
-            self._log("No playlist found.")
+            self._log("Error: No playlist found.")
             return
 
         # Existing files in target directory to be removed if not found in playlists.
@@ -323,8 +323,7 @@ class Converter:
                 if not os.path.isfile(trackFilePath):
                     self._log("Error: '" + trackFilePath + "' in playlist '"
                               + playlist.name + "' is not a file.")
-                    stats.errors += 1
-                    continue
+                    return
 
                 # Default task type: copy.
                 taskType: str = "copy"
@@ -337,11 +336,10 @@ class Converter:
                     taskType = "convert"
                 # Do nothing if extension not found in profile.
                 elif not convertProfile.isCopyExtension(targetExt):
-                    self._log("Error: Unsupported track file '"
+                    self._log("Warning: Unsupported track file '"
                               + trackFilePath + "' in playlist '"
                               + playlist.name + "' for profile '"
                               + convertProfile.name + "'.")
-                    stats.errors += 1
                     continue
 
                 targetFileName: str = targetName
@@ -365,7 +363,7 @@ class Converter:
                     if not os.path.isfile(targetFilePath):
                         self._log("Error: Existing target element '"
                                   + targetFilePath + "' is not a valid file.")
-                        stats.errors += 1
+                        return
                     elif self.isFileChanged(trackFilePath, targetFilePath):
                         processedFiles.add(targetFile)
                         stats.tasks += 1
@@ -592,9 +590,13 @@ class Converter:
                 if element is None:
                     continue
 
-                urlDecodedString: str = urllib.parse.unquote(str(element.text))
-                playlist.add(os.path.dirname(urlDecodedString),
-                             os.path.basename(urlDecodedString))
+                decodedString: str = urllib.parse.unquote(str(element.text))
+
+                if decodedString.startswith("file://"):
+                    decodedString = decodedString[7:]
+
+                playlist.add(os.path.dirname(decodedString),
+                             os.path.basename(decodedString))
 
     # Create or update playlist file from a directory.
     def _updatePlaylistFile(self, playlist: list[str], playlistPath: str) -> None:
@@ -633,7 +635,7 @@ class Converter:
         self._runLock.acquire()
 
         if self._running:
-            self._log("Error: This conveter is already running.")
+            self._log("Error: This converter is already running.")
         else:
             self._running = True
             self._stopSignal = False