mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 23:30:44 +08:00
Merge 78581b15a7 into dbc965c6fe
This commit is contained in:
commit
a4b0a7f220
@ -163,7 +163,7 @@ class MagicRename:
|
|||||||
"{YEAR}": [r"(?<!\d)(18|19|20)\d{2}(?!\d)"],
|
"{YEAR}": [r"(?<!\d)(18|19|20)\d{2}(?!\d)"],
|
||||||
"{S}": [r"(?<=[Ss])\d{1,2}(?=[EeXx])", r"(?<=[Ss])\d{1,2}"],
|
"{S}": [r"(?<=[Ss])\d{1,2}(?=[EeXx])", r"(?<=[Ss])\d{1,2}"],
|
||||||
"{SXX}": [r"[Ss]\d{1,2}(?=[EeXx])", r"[Ss]\d{1,2}"],
|
"{SXX}": [r"[Ss]\d{1,2}(?=[EeXx])", r"[Ss]\d{1,2}"],
|
||||||
"{E}": [
|
"{E+}": [
|
||||||
r"(?<=[Ss]\d\d[Ee])\d{1,3}",
|
r"(?<=[Ss]\d\d[Ee])\d{1,3}",
|
||||||
r"(?<=[Ee])\d{1,3}",
|
r"(?<=[Ee])\d{1,3}",
|
||||||
r"(?<=[Ee][Pp])\d{1,3}",
|
r"(?<=[Ee][Pp])\d{1,3}",
|
||||||
@ -223,7 +223,7 @@ class MagicRename:
|
|||||||
return file_name
|
return file_name
|
||||||
# 预处理替换变量
|
# 预处理替换变量
|
||||||
for key, p_list in self.magic_variable.items():
|
for key, p_list in self.magic_variable.items():
|
||||||
if key in replace:
|
if match_key := re.search(key, replace):
|
||||||
# 正则类替换变量
|
# 正则类替换变量
|
||||||
if p_list and isinstance(p_list, list):
|
if p_list and isinstance(p_list, list):
|
||||||
for p in p_list:
|
for p in p_list:
|
||||||
@ -239,7 +239,10 @@ class MagicRename:
|
|||||||
value = (
|
value = (
|
||||||
str(datetime.now().year)[: (8 - len(value))] + value
|
str(datetime.now().year)[: (8 - len(value))] + value
|
||||||
)
|
)
|
||||||
replace = replace.replace(key, value)
|
# 集数零填充处理
|
||||||
|
elif key == "{E+}":
|
||||||
|
value = value.lstrip("0").zfill(match_key.group().count("E"))
|
||||||
|
replace = re.sub(key, value, replace)
|
||||||
break
|
break
|
||||||
# 非正则类替换变量
|
# 非正则类替换变量
|
||||||
if key == "{TASKNAME}":
|
if key == "{TASKNAME}":
|
||||||
@ -250,7 +253,7 @@ class MagicRename:
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# 清理未匹配的 magic_variable key
|
# 清理未匹配的 magic_variable key
|
||||||
replace = replace.replace(key, "")
|
replace = re.sub(key, "", replace)
|
||||||
if pattern and replace:
|
if pattern and replace:
|
||||||
file_name = re.sub(pattern, replace, file_name)
|
file_name = re.sub(pattern, replace, file_name)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user