From 0349e16bc24107cd4e1523db4a3d291360447c1c Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Wed, 12 Jun 2024 18:03:21 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=8F=AF=E4=BB=8E=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E8=87=AA=E5=AE=9A=E4=B9=89=20magic?= =?UTF-8?q?=5Fregex=20#21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quark_auto_save.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/quark_auto_save.py b/quark_auto_save.py index 3142734..fa9f9f6 100644 --- a/quark_auto_save.py +++ b/quark_auto_save.py @@ -30,7 +30,7 @@ NOTIFYS = [] GH_PROXY = os.environ.get("GH_PROXY", "https://gh-proxy.com/") -magic_regex = { +MAGIC_REGEX = { "$TV": { "pattern": ".*?(S\\d{1,2}E)?P?(\\d{1,3}).*?\\.(mp4|mkv)", "replace": "\\1\\2.\\3", @@ -41,10 +41,10 @@ magic_regex = { # 魔法正则匹配 def magic_regex_func(pattern, replace): keyword = pattern - if keyword in magic_regex: - pattern = magic_regex[keyword]["pattern"] + if keyword in CONFIG_DATA["magic_regex"]: + pattern = CONFIG_DATA["magic_regex"][keyword]["pattern"] if replace == "": - replace = magic_regex[keyword]["replace"] + replace = CONFIG_DATA["magic_regex"][keyword]["replace"] return pattern, replace @@ -854,6 +854,8 @@ def main(): with open(config_path, "r", encoding="utf-8") as file: CONFIG_DATA = json.load(file) cookie_val = CONFIG_DATA.get("cookie") + if not CONFIG_DATA.get("magic_regex"): + CONFIG_DATA["magic_regex"] = MAGIC_REGEX cookie_form_file = True # 获取cookie cookies = get_cookies(cookie_val)