From cc1c5b26e3523dd3399eee7f6ccfbbf01683ceb3 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 8 Feb 2025 13:25:41 +0100 Subject: [PATCH] Stop if an invalid track is found in a playlist. xspf: Handle locations starting with file:// --- converter.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/converter.py b/converter.py index 7055417..6d0152e 100755 --- a/converter.py +++ b/converter.py @@ -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 -- 2.47.3