diff --git a/app/run.py b/app/run.py index 27f23fe..90c49d1 100644 --- a/app/run.py +++ b/app/run.py @@ -135,7 +135,9 @@ def update(): def run_script_now(): if not is_login(): return "未登录" - command = [python_path, script_path, config_path] + payload = request.json + task_index = str(payload.get("task_index", "")) + command = [python_path, script_path, config_path, task_index] def generate_output(): process = subprocess.Popen( diff --git a/app/templates/index.html b/app/templates/index.html index c20f36b..b5ac3fd 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -131,7 +131,8 @@

任务#

- + +
@@ -153,12 +154,6 @@ -
- -
- -
-
@@ -173,6 +168,12 @@
+
+ +
+ +
+
@@ -211,8 +212,8 @@
- 运行 - 回顶 + + 退出
@@ -301,14 +302,18 @@ // cookie兼容 if (typeof response.data.cookie === 'string') response.data.cookie = [response.data.cookie]; - // 星期运行兼容 + // 添加星期预设 response.data.tasklist = response.data.tasklist.map(task => { if (!task.hasOwnProperty('runweek')) { task.runweek = [1, 2, 3, 4, 5, 6, 7]; } return task; }); - // 存所有任务父目录 + // 添加emby预设 + if (!response.data.hasOwnProperty('emby')) { + response.data.emby = { ...this.emby }; + } + // 获取所有任务父目录 response.data.tasklist.forEach(item => { parentDir = this.getParentDirectory(item.savepath) if (!this.taskDirs.includes(parentDir)) @@ -366,15 +371,17 @@ clearData(target) { this[target] = ""; }, - runScriptNow() { + runScriptNow(task_index = "") { $('#logModal').modal('toggle') this.run_log = '
请耐心等待脚本全部执行完毕...' - axios.post('/run_script_now') + axios.post('/run_script_now', { + task_index: task_index, + }) .then(response => { this.run_log = response.data; }) .catch(error => { - this.run_log = "错误:\n" + error + this.run_log = "错误:\n" + error; console.error('Error:', error); }); }, diff --git a/quark_auto_save.py b/quark_auto_save.py index f23e359..a070df0 100644 --- a/quark_auto_save.py +++ b/quark_auto_save.py @@ -771,14 +771,12 @@ def do_sign(account): print() -def do_save(account): +def do_save(account, tasklist=[]): emby = Emby( CONFIG_DATA.get("emby", {}).get("url", ""), CONFIG_DATA.get("emby", {}).get("apikey", ""), ) print(f"转存账号: {account.nickname}") - # 任务列表 - tasklist = CONFIG_DATA.get("tasklist", []) # 获取全部保存目录fid account.update_savepath_fid(tasklist) @@ -837,6 +835,7 @@ def main(): print() # 读取启动参数 config_path = sys.argv[1] if len(sys.argv) > 1 else "quark_config.json" + task_index = int(sys.argv[2]) if len(sys.argv) > 2 and sys.argv[2].isdigit() else "" # 检查本地文件是否存在,如果不存在就下载 if not os.path.exists(config_path): if os.environ.get("QUARK_COOKIE"): @@ -865,13 +864,21 @@ def main(): accounts = [Quark(cookie, index) for index, cookie in enumerate(cookies)] # 签到 print(f"===============签到任务===============") - for account in accounts: - do_sign(account) + if type(task_index) is int: + do_sign(accounts[0]) + else: + for account in accounts: + do_sign(account) print() # 转存 if accounts[0].is_active and cookie_form_file: print(f"===============转存任务===============") - do_save(accounts[0]) + # 任务列表 + tasklist = CONFIG_DATA.get("tasklist", []) + if type(task_index) is int: + do_save(accounts[0], [tasklist[task_index]]) + else: + do_save(accounts[0], tasklist) print() # 通知 if NOTIFYS: