From 7e612541a4bcc33eb9c654a614e33655cc678387 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Wed, 27 Nov 2024 01:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=8F=92=E4=BB=B6=20aria2=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9A=82=E5=81=9C=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加暂停选项,可仅添加任务不下载 - 优化任务选项读取逻辑 --- plugins/aria2.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/aria2.py b/plugins/aria2.py index c01b4ee..e1774bb 100644 --- a/plugins/aria2.py +++ b/plugins/aria2.py @@ -10,7 +10,8 @@ class Aria2: "dir": "/Downloads", # 下载目录,需要Aria2有权限访问 } default_task_config = { - "auto_download": False, # 是否开启自动下载 + "auto_download": False, # 是否自动添加下载任务 + "pause": False, # 添加任务后为暂停状态,不自动开始(手动下载) } is_active = False rpc_url = None @@ -29,9 +30,11 @@ class Aria2: self.is_active = True def run(self, task, **kwargs): - if task_config := task.get("addition", {}).get(self.plugin_name, {}): - if not task_config.get("auto_download"): - return + task_config = task.get("addition", {}).get( + self.plugin_name, self.default_task_config + ) + if not task_config.get("auto_download"): + return if (tree := kwargs.get("tree")) and (account := kwargs.get("account")): for node in tree.all_nodes_itr(): if not node.data.get("is_dir", True): @@ -52,6 +55,7 @@ class Aria2: ], "out": os.path.basename(save_path), "dir": os.path.dirname(save_path), + "pause": task_config.get("pause"), }, ] self.add_uri(aria2_params)