mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-11 22:50:45 +08:00
Compare commits
3 Commits
39cac1bacb
...
c297bb02d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c297bb02d3 | ||
|
|
f3a6d665cf | ||
|
|
41201653f1 |
@ -96,20 +96,26 @@ class Config:
|
|||||||
PLUGIN_FLAGS = os.environ.get("PLUGIN_FLAGS", "").split(",")
|
PLUGIN_FLAGS = os.environ.get("PLUGIN_FLAGS", "").split(",")
|
||||||
plugins_available = {}
|
plugins_available = {}
|
||||||
task_plugins_config = {}
|
task_plugins_config = {}
|
||||||
|
# 获取所有模块
|
||||||
|
py_ext = [".py", ".pyd"] if sys.platform == "win32" else [".py", ".so"]
|
||||||
all_modules = [
|
all_modules = [
|
||||||
f.replace(".py", "") for f in os.listdir(plugins_dir) if f.endswith(".py")
|
f.replace(ext, "")
|
||||||
|
for f in os.listdir(plugins_dir)
|
||||||
|
for ext in py_ext
|
||||||
|
if f.endswith(ext)
|
||||||
]
|
]
|
||||||
# 调整模块优先级
|
# 调整模块优先级
|
||||||
priority_path = os.path.join(plugins_dir, "_priority.json")
|
priority_path = os.path.join(plugins_dir, "_priority.json")
|
||||||
try:
|
try:
|
||||||
with open(priority_path, encoding="utf-8") as f:
|
with open(priority_path, encoding="utf-8") as f:
|
||||||
priority_modules = json.load(f)
|
priority_modules = json.load(f)
|
||||||
|
except (FileNotFoundError, json.JSONDecodeError):
|
||||||
|
priority_modules = []
|
||||||
if priority_modules:
|
if priority_modules:
|
||||||
all_modules = [
|
all_modules = [
|
||||||
module for module in priority_modules if module in all_modules
|
module for module in priority_modules if module in all_modules
|
||||||
] + [module for module in all_modules if module not in priority_modules]
|
] + [module for module in all_modules if module not in priority_modules]
|
||||||
except (FileNotFoundError, json.JSONDecodeError):
|
# 加载模块
|
||||||
priority_modules = []
|
|
||||||
for module_name in all_modules:
|
for module_name in all_modules:
|
||||||
if f"-{module_name}" in PLUGIN_FLAGS:
|
if f"-{module_name}" in PLUGIN_FLAGS:
|
||||||
continue
|
continue
|
||||||
@ -567,6 +573,8 @@ class Quark:
|
|||||||
"_fetch_sub_dirs": "0",
|
"_fetch_sub_dirs": "0",
|
||||||
"_sort": "file_type:asc,updated_at:desc",
|
"_sort": "file_type:asc,updated_at:desc",
|
||||||
"_fetch_full_path": kwargs.get("fetch_full_path", 0),
|
"_fetch_full_path": kwargs.get("fetch_full_path", 0),
|
||||||
|
"fetch_all_file": 1, # 跟随Web端,作用未知
|
||||||
|
"fetch_risk_file_name": 1, # 如无此参数,违规文件名会被变 ***
|
||||||
}
|
}
|
||||||
response = self._send_request("GET", url, params=querystring).json()
|
response = self._send_request("GET", url, params=querystring).json()
|
||||||
if response["code"] != 0:
|
if response["code"] != 0:
|
||||||
@ -1107,6 +1115,7 @@ def do_save(account, tasklist=[]):
|
|||||||
plugins, CONFIG_DATA["plugins"], task_plugins_config = Config.load_plugins(
|
plugins, CONFIG_DATA["plugins"], task_plugins_config = Config.load_plugins(
|
||||||
CONFIG_DATA.get("plugins", {})
|
CONFIG_DATA.get("plugins", {})
|
||||||
)
|
)
|
||||||
|
print()
|
||||||
print(f"转存账号: {account.nickname}")
|
print(f"转存账号: {account.nickname}")
|
||||||
# 获取全部保存目录fid
|
# 获取全部保存目录fid
|
||||||
account.update_savepath_fid(tasklist)
|
account.update_savepath_fid(tasklist)
|
||||||
@ -1174,6 +1183,13 @@ def do_save(account, tasklist=[]):
|
|||||||
plugin.run(task, account=account, tree=is_new_tree) or task
|
plugin.run(task, account=account, tree=is_new_tree) or task
|
||||||
)
|
)
|
||||||
print()
|
print()
|
||||||
|
print(f"===============插件收尾===============")
|
||||||
|
for plugin_name, plugin in plugins.items():
|
||||||
|
if plugin.is_active and hasattr(plugin, "task_after"):
|
||||||
|
data = plugin.task_after()
|
||||||
|
if data.get("config"):
|
||||||
|
CONFIG_DATA["plugins"][plugin_name] = data["config"]
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user