mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 23:30:44 +08:00
✨ 可从配置文件自定义 magic_regex #21
This commit is contained in:
parent
33a05f1cf1
commit
0349e16bc2
@ -30,7 +30,7 @@ NOTIFYS = []
|
|||||||
GH_PROXY = os.environ.get("GH_PROXY", "https://gh-proxy.com/")
|
GH_PROXY = os.environ.get("GH_PROXY", "https://gh-proxy.com/")
|
||||||
|
|
||||||
|
|
||||||
magic_regex = {
|
MAGIC_REGEX = {
|
||||||
"$TV": {
|
"$TV": {
|
||||||
"pattern": ".*?(S\\d{1,2}E)?P?(\\d{1,3}).*?\\.(mp4|mkv)",
|
"pattern": ".*?(S\\d{1,2}E)?P?(\\d{1,3}).*?\\.(mp4|mkv)",
|
||||||
"replace": "\\1\\2.\\3",
|
"replace": "\\1\\2.\\3",
|
||||||
@ -41,10 +41,10 @@ magic_regex = {
|
|||||||
# 魔法正则匹配
|
# 魔法正则匹配
|
||||||
def magic_regex_func(pattern, replace):
|
def magic_regex_func(pattern, replace):
|
||||||
keyword = pattern
|
keyword = pattern
|
||||||
if keyword in magic_regex:
|
if keyword in CONFIG_DATA["magic_regex"]:
|
||||||
pattern = magic_regex[keyword]["pattern"]
|
pattern = CONFIG_DATA["magic_regex"][keyword]["pattern"]
|
||||||
if replace == "":
|
if replace == "":
|
||||||
replace = magic_regex[keyword]["replace"]
|
replace = CONFIG_DATA["magic_regex"][keyword]["replace"]
|
||||||
return pattern, replace
|
return pattern, replace
|
||||||
|
|
||||||
|
|
||||||
@ -854,6 +854,8 @@ def main():
|
|||||||
with open(config_path, "r", encoding="utf-8") as file:
|
with open(config_path, "r", encoding="utf-8") as file:
|
||||||
CONFIG_DATA = json.load(file)
|
CONFIG_DATA = json.load(file)
|
||||||
cookie_val = CONFIG_DATA.get("cookie")
|
cookie_val = CONFIG_DATA.get("cookie")
|
||||||
|
if not CONFIG_DATA.get("magic_regex"):
|
||||||
|
CONFIG_DATA["magic_regex"] = MAGIC_REGEX
|
||||||
cookie_form_file = True
|
cookie_form_file = True
|
||||||
# 获取cookie
|
# 获取cookie
|
||||||
cookies = get_cookies(cookie_val)
|
cookies = get_cookies(cookie_val)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user