diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 879af891..1733e093 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -726,6 +726,11 @@ class PathFormat(): "jif" : "jpg", "jfi" : "jpg", } + RESTRICT_MAP = { + "auto" : "\\\\|/<>:\"?*" if WINDOWS else "/", + "unix" : "/", + "windows": "\\\\|/<>:\"?*", + } def __init__(self, extractor): filename_fmt = extractor.config("filename", extractor.filename_fmt) @@ -769,13 +774,7 @@ class PathFormat(): 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 = "\\\\|/<>:\"?*" + restrict = self.RESTRICT_MAP.get(restrict, restrict) self.clean_segment = self._build_cleanfunc(restrict, replace) remove = extractor.config("path-remove", "\x00-\x1f\x7f")