diff --git a/docs/configuration.rst b/docs/configuration.rst index fc7db234..b385585d 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -135,9 +135,10 @@ Type ``string`` or ``object`` Default ``"auto"`` Example | ``"/!? (){}"`` | ``{" ": "_", "/": "-", "|": "-", ":": "-", "*": "+"}`` -Description | String of characters to be replaced with underscores (``_``) - | or an object mapping specific characters to others - | in generated path segment names. +Description | A string of characters to be replaced with the value of + `path-replace `__ + | or an object mapping invalid/unwanted characters to their replacements + | for generated path segment names. Special values: @@ -151,6 +152,16 @@ Description | String of characters to be replaced with underscores (``_``) =========== ===== +extractor.*.path-replace +------------------------ +=========== ===== +Type ``string`` +Default ``"_"`` +Description The replacement character(s) for + `path-restrict `__ +=========== ===== + + extractor.*.path-remove ----------------------- =========== ===== diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 8290a23d..1f312982 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -10,6 +10,7 @@ "skip": true, "sleep": 0, "path-restrict": "auto", + "path-replace": "_", "path-remove": "\\u0000-\\u001f\\u007f", "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0", diff --git a/gallery_dl/util.py b/gallery_dl/util.py index f74f1518..85b871b7 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -725,16 +725,17 @@ class PathFormat(): self.basedirectory = basedir restrict = extractor.config("path-restrict", "auto") + replace = extractor.config("path-replace", "_") + if restrict == "auto": restrict = "\\\\|/<>:\"?*" if WINDOWS else "/" elif restrict == "unix": restrict = "/" elif restrict == "windows": restrict = "\\\\|/<>:\"?*" + self.clean_segment = self._build_cleanfunc(restrict, replace) remove = extractor.config("path-remove", "\x00-\x1f\x7f") - - self.clean_segment = self._build_cleanfunc(restrict, "_") self.clean_path = self._build_cleanfunc(remove, "") @staticmethod