refactor 'path-restrict' parsing

This commit is contained in:
Mike Fährmann
2021-01-09 02:33:42 +01:00
parent aac00a2024
commit 5818c928c4

View File

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