refactor 'path-restrict' parsing
This commit is contained in:
@@ -726,6 +726,11 @@ class PathFormat():
|
|||||||
"jif" : "jpg",
|
"jif" : "jpg",
|
||||||
"jfi" : "jpg",
|
"jfi" : "jpg",
|
||||||
}
|
}
|
||||||
|
RESTRICT_MAP = {
|
||||||
|
"auto" : "\\\\|/<>:\"?*" if WINDOWS else "/",
|
||||||
|
"unix" : "/",
|
||||||
|
"windows": "\\\\|/<>:\"?*",
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, extractor):
|
def __init__(self, extractor):
|
||||||
filename_fmt = extractor.config("filename", extractor.filename_fmt)
|
filename_fmt = extractor.config("filename", extractor.filename_fmt)
|
||||||
@@ -769,13 +774,7 @@ class PathFormat():
|
|||||||
|
|
||||||
restrict = extractor.config("path-restrict", "auto")
|
restrict = extractor.config("path-restrict", "auto")
|
||||||
replace = extractor.config("path-replace", "_")
|
replace = extractor.config("path-replace", "_")
|
||||||
|
restrict = self.RESTRICT_MAP.get(restrict, restrict)
|
||||||
if restrict == "auto":
|
|
||||||
restrict = "\\\\|/<>:\"?*" if WINDOWS else "/"
|
|
||||||
elif restrict == "unix":
|
|
||||||
restrict = "/"
|
|
||||||
elif restrict == "windows":
|
|
||||||
restrict = "\\\\|/<>:\"?*"
|
|
||||||
self.clean_segment = self._build_cleanfunc(restrict, replace)
|
self.clean_segment = self._build_cleanfunc(restrict, replace)
|
||||||
|
|
||||||
remove = extractor.config("path-remove", "\x00-\x1f\x7f")
|
remove = extractor.config("path-remove", "\x00-\x1f\x7f")
|
||||||
|
|||||||
Reference in New Issue
Block a user