diff --git a/docs/configuration.rst b/docs/configuration.rst index 13e8628c..fc7db234 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -131,11 +131,13 @@ Description Use an extractor's current target directory as extractor.*.path-restrict ------------------------- =========== ===== -Type ``string`` +Type ``string`` or ``object`` Default ``"auto"`` -Example ``"/!? (){}"`` -Description Set of characters to replace with underscores (``_``) - in generated path segment names. +Example | ``"/!? (){}"`` + | ``{" ": "_", "/": "-", "|": "-", ":": "-", "*": "+"}`` +Description | String of characters to be replaced with underscores (``_``) + | or an object mapping specific characters to others + | in generated path segment names. Special values: @@ -144,7 +146,7 @@ Description Set of characters to replace with underscores (``_``) * ``"unix"``: ``"/"`` * ``"windows"``: ``"\\\\|/<>:\"?*"`` - Note: In a set with 2 or more characters, ``[]^-\`` need to be + Note: In a string with 2 or more characters, ``[]^-\`` need to be escaped with backslashes, e.g. ``"\\[\\]"`` =========== ===== @@ -156,7 +158,7 @@ Type ``string`` Default ``"\u0000-\u001f\u007f"`` (ASCII control characters) Description Set of characters to remove from generated path names. - Note: In a set with 2 or more characters, ``[]^-\`` need to be + Note: In a string with 2 or more characters, ``[]^-\`` need to be escaped with backslashes, e.g. ``"\\[\\]"`` =========== ===== diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 076ee5cc..dd3b9426 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -690,6 +690,9 @@ class PathFormat(): def _build_cleanfunc(chars, repl): if not chars: return lambda x: x + elif isinstance(chars, dict): + def func(x, table=str.maketrans(chars)): + return x.translate(table) elif len(chars) == 1: def func(x, c=chars, r=repl): return x.replace(c, r)