From bed7f191f683bb7e333ee7dc4487784ee99c47ae Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Mon, 20 May 2024 23:30:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81QB=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=A7=8D=E5=AD=90=E6=97=B6=E5=BC=BA=E5=88=B6=E6=B1=87=E6=8A=A5?= =?UTF-8?q?Tracker=EF=BC=8C=E7=AB=99=E7=82=B9=E7=8B=AC=E7=AB=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A2=9E=E5=8A=A0=E3=80=8C=E7=AB=99=E7=82=B9=E5=85=A8?= =?UTF-8?q?=E5=B1=80H&R=E3=80=8D=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- plugins/brushflow/__init__.py | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8fa30ac..71760a3 100644 --- a/package.json +++ b/package.json @@ -315,11 +315,12 @@ "name": "站点刷流", "description": "自动托管刷流,将会提高对应站点的访问频率。", "labels": "刷流", - "version": "3.2", + "version": "3.3", "icon": "brush.jpg", "author": "jxxghp,InfinityPacer", "level": 2, "history": { + "v3.3": "支持QB删除种子时强制汇报Tracker,站点独立配置增加「站点全局H&R」配置项", "v3.2": "支持推送QB种子时启用「先下载首尾文件块」选项", "v3.1": "支持仪表板显示站点刷流数据,需要主程序升级v1.8.7+版本", "v3.0": "优化不同站点刷流到相同种子的逻辑,修复数据页滚动闪烁,部分日志优化", diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index 74a1c7a..e41bea4 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -77,6 +77,7 @@ class BrushConfig: self.qb_category = config.get("qb_category") self.auto_qb_category = config.get("auto_qb_category", False) self.qb_first_last_piece = config.get("qb_first_last_piece", False) + self.site_hr_active = config.get("site_hr_active", False) self.brush_tag = "刷流" # 站点独立配置 @@ -121,6 +122,7 @@ class BrushConfig: "qb_category", "auto_qb_category", "qb_first_last_piece", + "site_hr_active" # 当新增支持字段时,仅在此处添加字段名 } try: @@ -188,7 +190,8 @@ class BrushConfig: "proxy_delete": false, "qb_category": "刷流", "auto_qb_category": true, - "qb_first_last_piece": true + "qb_first_last_piece": true, + "site_hr_active": true }]""" return desc + config @@ -254,7 +257,7 @@ class BrushFlow(_PluginBase): # 插件图标 plugin_icon = "brush.jpg" # 插件版本 - plugin_version = "3.2" + plugin_version = "3.3" # 插件作者 plugin_author = "jxxghp,InfinityPacer" # 作者主页 @@ -2048,6 +2051,12 @@ class BrushFlow(_PluginBase): brush_config = self.__get_brush_config(sitename=siteinfo.name) + if brush_config.site_hr_active: + logger.info(f"站点 {siteinfo.name} 已开启全站H&R选项,所有种子设置为H&R种子") + # 由于缓存原因,这里不能直接改torrents,在后续加入任务中调整 + # for torrent in torrents: + # torrent.hit_and_run = True + # 排除包含订阅的种子 if brush_config.except_subscribe: torrents = self.__filter_torrents_contains_subscribe(torrents=torrents, subscribe_titles=subscribe_titles) @@ -2109,7 +2118,7 @@ class BrushFlow(_PluginBase): "freedate": torrent.freedate, "uploadvolumefactor": torrent.uploadvolumefactor, "downloadvolumefactor": torrent.downloadvolumefactor, - "hit_and_run": torrent.hit_and_run, + "hit_and_run": torrent.hit_and_run or brush_config.site_hr_active, "volume_factor": torrent.volume_factor, "freedate_diff": torrent.freedate_diff, # "labels": torrent.labels, @@ -2382,6 +2391,10 @@ class BrushFlow(_PluginBase): need_delete_hashes.extend(not_proxy_delete_hashes) if need_delete_hashes: + # 如果是QB,则重新汇报Tracker + if brush_config.downloader == "qbittorrent": + self.__qb_torrents_reannounce(torrent_hashes=need_delete_hashes) + # 删除种子 if downloader.delete_torrents(ids=need_delete_hashes, delete_file=True): for torrent_hash in need_delete_hashes: torrent_tasks[torrent_hash]["deleted"] = True @@ -3280,6 +3293,20 @@ class BrushFlow(_PluginBase): logger.error(f"添加种子出错:{str(err)}") return False + def __qb_torrents_reannounce(self, torrent_hashes: List[str]): + """强制重新汇报""" + if not self.qb.qbc: + return + + if not torrent_hashes: + return + + try: + # 重新汇报 + self.qb.qbc.torrents_reannounce(torrent_hashes=torrent_hashes) + except Exception as err: + logger.error(f"强制重新汇报失败:{str(err)}") + def __get_hash(self, torrent: Any): """ 获取种子hash