Skip to content

Commit

Permalink
Playlist: Fix crash if playlist and audio file are on different drives
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Jan 23, 2024
1 parent 0900edb commit 8b690ab
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugins/playlist/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 8b690ab

Please sign in to comment.