diff --git a/headphones/helpers.py b/headphones/helpers.py index 5c3bc3af..438dc7d7 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -179,9 +179,9 @@ def replace_all(text, dic): def replace_illegal_chars(string, type="file"): if type == "file": - string = re.sub('[\?"*:|<>/]', string) + string = re.sub('[\?"*:|<>/]', '_', string) if type == "folder": - string = re.sub('[:?<>"|]', string) + string = re.sub('[:\?<>"|]', '_', string) return string diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index e41fd305..91d2b3a9 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -907,7 +907,7 @@ def renameFiles(albumpath, downloaded_track_list, release): new_file_name = helpers.replace_all(headphones.FILE_FORMAT.strip(), values).replace('/','_') + ext - new_file_name = new_file_name.replace('?','_').replace(':', '_').replace('"','_').replace('*','_').encode(headphones.SYS_ENCODING, 'replace') + new_file_name = helpers.replace_illegal_chars(new_file_name).encode(headphones.SYS_ENCODING, 'replace') if headphones.FILE_UNDERSCORES: new_file_name = new_file_name.replace(' ', '_')