From b7d084148d9e0b1436f660ef4fc4cf6e1598d67b Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Thu, 15 Aug 2024 17:49:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(BrushFlow):=20=E8=8E=B7=E5=8F=96=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=95=B0=E9=87=8F=E8=B0=83=E6=95=B4=E4=B8=BA=E4=BB=85?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=88=B7=E6=B5=81=E6=A0=87=E7=AD=BE=E7=A7=8D?= =?UTF-8?q?=E5=AD=90=EF=BC=8C=E5=B9=B6=E5=AE=B9=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/brushflow/__init__.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index 656a013..74151ab 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -3641,12 +3641,21 @@ class BrushFlow(_PluginBase): """ 获取正在下载的任务数量 """ - brush_config = self.__get_brush_config() - downloader = self.__get_downloader(brush_config.downloader) - if not downloader: + try: + brush_config = self.__get_brush_config() + downloader = self.__get_downloader(brush_config.downloader) + if not downloader: + return 0 + + torrents = downloader.get_downloading_torrents(tags=brush_config.brush_tag) + if torrents is None: + logger.warn("获取下载数量失败,可能是下载器连接发生异常") + return 0 + + return len(torrents) + except Exception as e: + logger.error(f"获取下载数量发生异常: {e}") return 0 - torrents = downloader.get_downloading_torrents() - return len(torrents) or 0 @staticmethod def __get_pubminutes(pubdate: str) -> float: