diff --git a/unshackle/core/utilities.py b/unshackle/core/utilities.py index 0c3b435..2936d20 100644 --- a/unshackle/core/utilities.py +++ b/unshackle/core/utilities.py @@ -129,6 +129,8 @@ def sanitize_filename(filename: str, spacer: str = ".") -> str: # optionally replace non-ASCII characters with ASCII equivalents if not config.unicode_filenames: filename = unidecode(filename) + filename = re.sub(r"\[\(+", "[", filename) + filename = re.sub(r"\)+\]", "]", filename) # remove or replace further characters as needed filename = "".join(c for c in filename if unicodedata.category(c) != "Mn") # hidden characters @@ -136,7 +138,7 @@ def sanitize_filename(filename: str, spacer: str = ".") -> str: if spacer == ".": filename = re.sub(r" - ", spacer, filename) # title separators to spacer (avoids .-. pattern) filename = re.sub(r"[:; ]", spacer, filename) # structural chars to (spacer) - filename = re.sub(r"[\\*!?¿,'\"" "()<>|$#~]", "", filename) # not filename safe chars + filename = re.sub(r"[\\*!?¿,'\"" "<>|$#~]", "", filename) # not filename safe chars filename = re.sub(rf"[{spacer}]{{2,}}", spacer, filename) # remove extra neighbouring (spacer)s return filename