From 5b85de9d5ea50d24594ccb877b6a59955eb3325f Mon Sep 17 00:00:00 2001 From: honue Date: Fri, 18 Apr 2025 19:10:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(TrackerEditor):=20tr=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=A0=E5=8E=BB=E8=80=81tracker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +++-- plugins/trackereditor/__init__.py | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 4a23aaf..42d95be 100644 --- a/package.json +++ b/package.json @@ -738,14 +738,15 @@ }, "TrackerEditor": { "name": "Tracker替换", - "description": "批量替换种子tracker,支持周期性巡检(如为TR,仅支持4.0以上版本)。", + "description": "批量替换修改种子tracker。", "labels": "做种", - "version": "1.7", + "version": "1.8", "icon": "trackereditor_A.png", "author": "honue", "level": 1, "v2": true, "history": { + "v1.8": "修复老版本tr修改出错问题,优化log输出", "v1.7": "支持多个tracker替换配置" } }, diff --git a/plugins/trackereditor/__init__.py b/plugins/trackereditor/__init__.py index 740496a..b42a412 100644 --- a/plugins/trackereditor/__init__.py +++ b/plugins/trackereditor/__init__.py @@ -15,11 +15,11 @@ class TrackerEditor(_PluginBase): # 插件名称 plugin_name = "Tracker替换" # 插件描述 - plugin_desc = "批量替换种子tracker,支持周期性巡检(如为TR,仅支持4.0以上版本)" + plugin_desc = "批量替换修改种子tracker" # 插件图标 plugin_icon = "trackereditor_A.png" # 插件版本 - plugin_version = "1.7" + plugin_version = "1.8" # 插件作者 plugin_author = "honue" # 作者主页 @@ -73,7 +73,7 @@ class TrackerEditor(_PluginBase): tracker_dict[tracker_config.split('|')[0]] = tracker_config.split('|')[1] else: logger.error(f"配置行错误: {tracker_config}") - logger.info(f"{'*' * 30}TrackerEditor: 开始执行Tracker替换{'*' * 30}") + logger.info(f"【TrackerEditor】: 开始执行Tracker替换") torrent_total_cnt: int = 0 torrent_update_cnt: int = 0 if self._downloader_type == "qbittorrent": @@ -89,7 +89,7 @@ class TrackerEditor(_PluginBase): if target_domain in tracker.url: original_url = tracker.url new_url = tracker.url.replace(target_domain, tracker_dict[target_domain]) - logger.info(f"{original_url} 替换为\n {new_url}") + logger.info(f"{original_url[:20]}... 替换为 {new_url[:20]}...") torrent.edit_tracker(orig_url=original_url, new_url=new_url) torrent_update_cnt += 1 @@ -105,13 +105,16 @@ class TrackerEditor(_PluginBase): for torrent in torrent_list: new_tracker_list = [] for tracker in torrent.tracker_list: + tracker_replaced = False for target_domain in tracker_dict.keys(): if target_domain in tracker: new_url = tracker.replace(target_domain, tracker_dict[target_domain]) new_tracker_list.append(new_url) - logger.info(f"{tracker} 替换为\n {new_url}") + logger.info(f"{tracker[:20]}... 替换为 {new_url[:20]}...") torrent_update_cnt += 1 - else: + tracker_replaced = True + break + if not tracker_replaced: new_tracker_list.append(tracker) if int(tr_version[0]) >= 4: # 版本大于等于4.x @@ -126,7 +129,7 @@ class TrackerEditor(_PluginBase): break if torrent_update_cnt == 0: logger.info(f"tracker修改条数为0") - logger.info(f"{'*' * 30}TrackerEditor: Tracker替换完成{'*' * 30}") + logger.info(f"【TrackerEditor】: Tracker替换完成") if (self._run_con_enable and self._notify) or (self._onlyonce and self._notify): title = '【Tracker替换】' msg = f'''扫描下载器{self._downloader_type}\n总的种子数: {torrent_total_cnt}\n已修改种子数: {torrent_update_cnt}''' @@ -172,7 +175,7 @@ class TrackerEditor(_PluginBase): 'component': 'VSwitch', 'props': { 'model': 'run_con_enable', - 'label': '启用周期性巡检 (注: 请开启时,务必填写cron表达式)', + 'label': '定时执行', } } ] @@ -390,8 +393,7 @@ class TrackerEditor(_PluginBase): 'props': { 'type': 'info', 'variant': 'tonal', - 'text': '周期性巡检时指的是允许设置间隔一段进行巡检下载器中的种子Tracker' + '\n' - '当匹配到等待替换的tracker时,进行替换,其中cron表达式是5位,例如:* * * * * 指的是每过一分钟轮训一次', + 'text': '支持qb,tr仅支持4.0以上版本' + '\n', 'style': 'white-space: pre-line;' } } @@ -425,11 +427,11 @@ class TrackerEditor(_PluginBase): def get_service(self) -> List[Dict[str, Any]]: if self._run_con_enable and self._run_con: - logger.info(f"{'*' * 30}TrackerEditor: 注册公共调度服务{'*' * 30}") + logger.info(f"【TrackerEditor】: 注册定时任务") return [ { "id": "TrackerChangeRun", - "name": "启用周期性Tracker替换", + "name": "定时Tracker替换", "trigger": CronTrigger.from_crontab(self._run_con), "func": self.task, "kwargs": {}