From 366f59623a3e714a57a0152d2a39eed56de8728c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 7 Sep 2023 23:00:51 +0800 Subject: [PATCH] fix --- app/modules/qbittorrent/qbittorrent.py | 6 ++- app/modules/transmission/transmission.py | 55 ++++++++++++++++++++++++ app/plugins/brushflow/__init__.py | 16 +++++-- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/app/modules/qbittorrent/qbittorrent.py b/app/modules/qbittorrent/qbittorrent.py index ba385d0c..072c0a87 100644 --- a/app/modules/qbittorrent/qbittorrent.py +++ b/app/modules/qbittorrent/qbittorrent.py @@ -186,7 +186,8 @@ class Qbittorrent(metaclass=Singleton): download_dir: str = None, tag: Union[str, list] = None, category: str = None, - cookie=None + cookie=None, + **kwargs ) -> bool: """ 添加种子 @@ -238,7 +239,8 @@ class Qbittorrent(metaclass=Singleton): use_auto_torrent_management=is_auto, is_sequential_download=True, cookie=cookie, - category=category) + category=category, + **kwargs) return True if qbc_ret and str(qbc_ret).find("Ok") != -1 else False except Exception as err: logger.error(f"添加种子出错:{err}") diff --git a/app/modules/transmission/transmission.py b/app/modules/transmission/transmission.py index 38deeafe..81370509 100644 --- a/app/modules/transmission/transmission.py +++ b/app/modules/transmission/transmission.py @@ -288,3 +288,58 @@ class Transmission(metaclass=Singleton): except Exception as err: logger.error(f"添加Tracker出错:{err}") return False + + def change_torrent(self, + hash_string: str, + upload_limit=None, + download_limit=None, + ratio_limit=None, + seeding_time_limit=None): + """ + 设置种子 + :param hash_string: ID + :param upload_limit: 上传限速 Kb/s + :param download_limit: 下载限速 Kb/s + :param ratio_limit: 分享率限制 + :param seeding_time_limit: 做种时间限制 + :return: bool + """ + if not hash_string: + return False + if upload_limit: + uploadLimited = True + uploadLimit = int(upload_limit) + else: + uploadLimited = False + uploadLimit = 0 + if download_limit: + downloadLimited = True + downloadLimit = int(download_limit) + else: + downloadLimited = False + downloadLimit = 0 + if ratio_limit: + seedRatioMode = 1 + seedRatioLimit = round(float(ratio_limit), 2) + else: + seedRatioMode = 2 + seedRatioLimit = 0 + if seeding_time_limit: + seedIdleMode = 1 + seedIdleLimit = int(seeding_time_limit) + else: + seedIdleMode = 2 + seedIdleLimit = 0 + try: + self.trc.change_torrent(ids=hash_string, + uploadLimited=uploadLimited, + uploadLimit=uploadLimit, + downloadLimited=downloadLimited, + downloadLimit=downloadLimit, + seedRatioMode=seedRatioMode, + seedRatioLimit=seedRatioLimit, + seedIdleMode=seedIdleMode, + seedIdleLimit=seedIdleLimit) + except Exception as err: + logger.error(f"设置种子出错:{err}") + return False diff --git a/app/plugins/brushflow/__init__.py b/app/plugins/brushflow/__init__.py index 0b831e1f..2f49a7e6 100644 --- a/app/plugins/brushflow/__init__.py +++ b/app/plugins/brushflow/__init__.py @@ -850,8 +850,12 @@ class BrushFlow(_PluginBase): continue # 保存任务信息 task_info[hash_string] = { - "site_name": torrent.site_name, - "size": torrent.size + "site": siteinfo.id, + "site_name": siteinfo.name, + "title": torrent.title, + "size": torrent.size, + "pubdate": torrent.pubdate, + "state": "Y" } # 发送消息 self.__send_add_message(torrent) @@ -988,7 +992,9 @@ class BrushFlow(_PluginBase): state = self.qb.add_torrent(content=torrent.enclosure, download_dir=self._save_path or None, cookie=torrent.site_cookie, - tag=["已整理", "刷流", tag]) + tag=["已整理", "刷流", tag], + upload_limit=self._up_speed or None, + download_limit=self._dl_speed or None) if not state: return None else: @@ -1009,6 +1015,10 @@ class BrushFlow(_PluginBase): if not torrent: return None else: + if self._up_speed or self._dl_speed: + self.tr.change_torrent(hash_string=torrent.hashString, + upload_limit=self._up_speed, + download_limit=self._dl_speed) return torrent.hashString return None