mirror of
https://github.com/tdeerenberg/Musort.git
synced 2025-07-16 00:54:19 +00:00
Error prevention: invalid separator
This commit is contained in:
@ -92,6 +92,9 @@ class Music:
|
|||||||
def set_separator(self, sep):
|
def set_separator(self, sep):
|
||||||
"""Sets the separator for naming the audio files
|
"""Sets the separator for naming the audio files
|
||||||
(ex. 01-songname.mp3 or 01.songname.flac)"""
|
(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
|
self.separator = sep
|
||||||
|
|
||||||
def set_format(self, val):
|
def set_format(self, val):
|
||||||
@ -130,7 +133,7 @@ class Music:
|
|||||||
"""Replacing forbidden path characters in UNIX and Windows with underscores"""
|
"""Replacing forbidden path characters in UNIX and Windows with underscores"""
|
||||||
for forbidden_character in ['\\', '/', '|', '*', '<', '>', '"', '?']:
|
for forbidden_character in ['\\', '/', '|', '*', '<', '>', '"', '?']:
|
||||||
if forbidden_character in rename:
|
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, "_")
|
rename = rename.replace(forbidden_character, "_")
|
||||||
|
|
||||||
"""Get the absolute path and rename the audio file"""
|
"""Get the absolute path and rename the audio file"""
|
||||||
|
Reference in New Issue
Block a user