mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-11 14:40:44 +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(",")
|
||||
plugins_available = {}
|
||||
task_plugins_config = {}
|
||||
# 获取所有模块
|
||||
py_ext = [".py", ".pyd"] if sys.platform == "win32" else [".py", ".so"]
|
||||
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")
|
||||
try:
|
||||
with open(priority_path, encoding="utf-8") as f:
|
||||
priority_modules = json.load(f)
|
||||
if priority_modules:
|
||||
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]
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
priority_modules = []
|
||||
if priority_modules:
|
||||
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]
|
||||
# 加载模块
|
||||
for module_name in all_modules:
|
||||
if f"-{module_name}" in PLUGIN_FLAGS:
|
||||
continue
|
||||
@ -567,6 +573,8 @@ class Quark:
|
||||
"_fetch_sub_dirs": "0",
|
||||
"_sort": "file_type:asc,updated_at:desc",
|
||||
"_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()
|
||||
if response["code"] != 0:
|
||||
@ -1107,6 +1115,7 @@ def do_save(account, tasklist=[]):
|
||||
plugins, CONFIG_DATA["plugins"], task_plugins_config = Config.load_plugins(
|
||||
CONFIG_DATA.get("plugins", {})
|
||||
)
|
||||
print()
|
||||
print(f"转存账号: {account.nickname}")
|
||||
# 获取全部保存目录fid
|
||||
account.update_savepath_fid(tasklist)
|
||||
@ -1173,6 +1182,13 @@ def do_save(account, tasklist=[]):
|
||||
task = (
|
||||
plugin.run(task, account=account, tree=is_new_tree) or task
|
||||
)
|
||||
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()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user