diff --git a/app/chain/download.py b/app/chain/download.py index 161405c0..061b0b6b 100644 --- a/app/chain/download.py +++ b/app/chain/download.py @@ -292,7 +292,7 @@ class DownloadChain(ChainBase): continue files_to_add.append({ "download_hash": _hash, - "downloader": settings.DOWNLOADER, + "downloader": settings.DEFAULT_DOWNLOADER, "fullpath": str(download_dir / _folder_name / file), "savepath": str(download_dir / _folder_name), "filepath": file, diff --git a/app/core/config.py b/app/core/config.py index 7286b0a6..4a1578c8 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -125,7 +125,7 @@ class Settings(BaseSettings): VOCECHAT_API_KEY: str = "" # VoceChat 频道ID VOCECHAT_CHANNEL_ID: str = "" - # 下载器 qbittorrent/transmission + # 下载器 qbittorrent/transmission,启用多个下载器时使用,分隔,只有第一个会被默认使用 DOWNLOADER: str = "qbittorrent" # 下载器监控开关 DOWNLOADER_MONITOR: bool = True @@ -362,6 +362,24 @@ class Settings(BaseSettings): } return {} + @property + def DEFAULT_DOWNLOADER(self): + """ + 默认下载器 + """ + if not self.DOWNLOADER: + return None + return self.DOWNLOADER.split(",")[0] + + @property + def DOWNLOADERS(self): + """ + 下载器列表 + """ + if not self.DOWNLOADER: + return [] + return self.DOWNLOADER.split(",") + def __init__(self, **kwargs): super().__init__(**kwargs) with self.CONFIG_PATH as p: diff --git a/app/modules/qbittorrent/__init__.py b/app/modules/qbittorrent/__init__.py index 1e12b218..a0d07fd7 100644 --- a/app/modules/qbittorrent/__init__.py +++ b/app/modules/qbittorrent/__init__.py @@ -73,8 +73,12 @@ class QbittorrentModule(_ModuleBase): logger.error(f"获取种子名称失败:{e}") return "", 0 + # 不是默认下载器不处理 + if settings.DEFAULT_DOWNLOADER != "qbittorrent": + return None + if not content: - return + return None if isinstance(content, Path) and not content.exists(): return None, f"种子文件不存在:{content}" diff --git a/app/modules/transmission/__init__.py b/app/modules/transmission/__init__.py index 357b6e67..6dfe7fbc 100644 --- a/app/modules/transmission/__init__.py +++ b/app/modules/transmission/__init__.py @@ -73,8 +73,12 @@ class TransmissionModule(_ModuleBase): logger.error(f"获取种子名称失败:{e}") return "", 0 + # 不是默认下载器不处理 + if settings.DEFAULT_DOWNLOADER != "transmission": + return None + if not content: - return + return None if isinstance(content, Path) and not content.exists(): return None, f"种子文件不存在:{content}" diff --git a/app/scheduler.py b/app/scheduler.py index 70b4c04c..044c5534 100644 --- a/app/scheduler.py +++ b/app/scheduler.py @@ -290,6 +290,8 @@ class Scheduler(metaclass=Singleton): """ 更新插件定时服务 """ + if not self._scheduler: + return # 移除该插件的全部服务 self.remove_plugin_job(pid) # 获取插件服务列表 @@ -332,6 +334,8 @@ class Scheduler(metaclass=Singleton): """ 移除插件定时服务 """ + if not self._scheduler: + return with self._lock: # 获取插件名称 plugin_name = PluginManager().get_plugin_attr(pid, "plugin_name") @@ -351,6 +355,8 @@ class Scheduler(metaclass=Singleton): """ 当前所有任务 """ + if not self._scheduler: + return [] with self._lock: # 返回计时任务 schedulers = []