From ee8753d5610272d2fda8caa953a4b4629ac55504 Mon Sep 17 00:00:00 2001 From: tdeerenberg <113618658+tdeerenberg@users.noreply.github.com> Date: Sat, 28 Jan 2023 18:30:06 +0100 Subject: [PATCH] Error prevention: invalid separator --- src/musort.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/musort.py b/src/musort.py index b818baa..5cefa31 100755 --- a/src/musort.py +++ b/src/musort.py @@ -92,6 +92,9 @@ class Music: def set_separator(self, sep): """Sets the separator for naming the audio files (ex. 01-songname.mp3 or 01.songname.flac)""" + if sep in ['\\', '/', '|', '*', '<', '>', '"', '?']: + sep = "_" + logging.warning("Given separator contains invalid filename symbols, defaulting to .") self.separator = sep def set_format(self, val): @@ -130,7 +133,7 @@ class Music: """Replacing forbidden path characters in UNIX and Windows with underscores""" for forbidden_character in ['\\', '/', '|', '*', '<', '>', '"', '?']: if forbidden_character in rename: - logging.warning(f"Track '{track.artist}' - '{track.title}': found the forbidden path character ({forbidden_character}) in the new file name, replaced symbol with underscore") + logging.warning(f"Track contains forbidden path character ({forbidden_character}) in the new file name, replaced symbol with _") rename = rename.replace(forbidden_character, "_") """Get the absolute path and rename the audio file"""