From 8b690ab5c031c4cd613888ec59770a3dca4cefef Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 22 Jan 2024 19:41:41 +0100 Subject: [PATCH] Playlist: Fix crash if playlist and audio file are on different drives --- plugins/playlist/playlist.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/playlist/playlist.py b/plugins/playlist/playlist.py index ae303394..a81ba21c 100644 --- a/plugins/playlist/playlist.py +++ b/plugins/playlist/playlist.py @@ -16,7 +16,7 @@ PLUGIN_DESCRIPTION = """Generate an Extended M3U playlist (.m3u8 file, UTF8 encoded text). Relative pathnames are used where audio files are in the same directory as the playlist, otherwise absolute (full) pathnames are used.""" -PLUGIN_VERSION = "1.2" +PLUGIN_VERSION = "1.2.1" PLUGIN_API_VERSIONS = ["2.0"] PLUGIN_LICENSE = "GPL-2.0-or-later" PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.html" @@ -83,7 +83,10 @@ def callback(self, objs): if track.linked_files: files.append(track.linked_files[0].filename) - current_directory = os.path.commonpath(files) + try: + current_directory = os.path.commonpath(files) + except ValueError: + current_directory = "" # Default playlist filename set as "%albumartist% - %album%.m3u8", # except where "Various Artists" is suppressed @@ -140,7 +143,10 @@ def callback(self, objs): log.debug("{}: audio_filename: {}, selected dir: {}".format( PLUGIN_NAME, audio_filename, os.path.dirname(filename))) - audio_filename = os.path.relpath(audio_filename, os.path.dirname(filename)) + try: + audio_filename = os.path.relpath(audio_filename, os.path.dirname(filename)) + except ValueError: + pass entry.add(str(audio_filename)) playlist.write()