From 93d4df29a6f24fb532dc9c2119fe1609b423bec4 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 8 Apr 2014 12:52:14 -0700 Subject: [PATCH] More bugs in replace_illegal_chars --- headphones/helpers.py | 4 ++-- headphones/postprocessor.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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(' ', '_')