implement a 'path-replace' option (#662, #755)

pull/866/head
Mike Fährmann 4 years ago
parent 15c3d29062
commit ddc253cf9a
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -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 <extractor.*.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-restrict>`__
=========== =====
extractor.*.path-remove
-----------------------
=========== =====

@ -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",

@ -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

Loading…
Cancel
Save