From e001b9498135affe466388018f53fabf5e745737 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:26:10 +0800 Subject: [PATCH 1/2] feat(BrushFlow): support auto skip for NexusPHP --- plugins.v2/brushflow/__init__.py | 51 ++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/plugins.v2/brushflow/__init__.py b/plugins.v2/brushflow/__init__.py index 1c602dd..83edc9f 100644 --- a/plugins.v2/brushflow/__init__.py +++ b/plugins.v2/brushflow/__init__.py @@ -6,7 +6,7 @@ import threading import time from datetime import datetime, timedelta from typing import Any, List, Dict, Tuple, Optional, Union, Set -from urllib.parse import urlparse, parse_qs, unquote +from urllib.parse import urlparse, parse_qs, unquote, parse_qsl, urlencode, urlunparse import pytz from app.helper.sites import SitesHelper @@ -1943,7 +1943,7 @@ class BrushFlow(_PluginBase): """ siteinfo = self.site_oper.get(siteid) if not siteinfo: - logger.warn(f"站点不存在:{siteid}") + logger.warning(f"站点不存在:{siteid}") return True logger.info(f"开始获取站点 {siteinfo.name} 的新种子 ...") @@ -1995,7 +1995,7 @@ class BrushFlow(_PluginBase): # 添加下载任务 hash_string = self.__download(torrent=torrent) if not hash_string: - logger.warn(f"{torrent.title} 添加刷流任务失败!") + logger.warning(f"{torrent.title} 添加刷流任务失败!") continue # 触发刷流下载时间并保存任务信息 @@ -2222,7 +2222,7 @@ class BrushFlow(_PluginBase): """ if not passed: if not torrent: - logger.warn(f"没有通过前置刷流条件校验,原因:{reason}") + logger.warning(f"没有通过前置刷流条件校验,原因:{reason}") else: logger.debug(f"种子没有通过刷流条件校验,原因:{reason} 种子:{torrent.title}|{torrent.description}") @@ -2247,7 +2247,7 @@ class BrushFlow(_PluginBase): downloader = self.downloader seeding_torrents, error = downloader.get_torrents() if error: - logger.warn("连接下载器出错,将在下个时间周期重试") + logger.warning("连接下载器出错,将在下个时间周期重试") return seeding_torrents_dict = {self.__get_hash(torrent): torrent for torrent in seeding_torrents} @@ -3006,6 +3006,30 @@ class BrushFlow(_PluginBase): return data return None + def __reset_download_url(self, torrent_url, site_id): + """ + 处理下载地址 + """ + try: + # 检查 torrent_url 是否为有效的下载 URL,并且 site 是 NexusPHP + if not torrent_url or torrent_url.startswith("magnet") or not self.__is_nexusphp(site_id): + return torrent_url + + # 解析 URL + parsed_url = urlparse(torrent_url) + + # 如果 URL 中已有查询参数,使用 urlencode 进行拼接 + query_params = dict(parse_qsl(parsed_url.query)) + query_params["letdown"] = "1" + + # 重新构造带有新参数的 URL + new_query = urlencode(query_params) + new_url = urlunparse(parsed_url._replace(query=new_query)) + return new_url + except Exception as e: + logger.error(f"Error while resetting downloader URL for torrent: {torrent_url}. Error: {str(e)}") + return torrent_url + def __download(self, torrent: TorrentInfo) -> Optional[str]: """ 添加下载任务 @@ -3039,6 +3063,7 @@ class BrushFlow(_PluginBase): logger.error(f"获取下载链接失败:{torrent.title}") return None + torrent_content = self.__reset_download_url(torrent_url=torrent_content, site_id=torrent.site) downloader = self.downloader if not downloader: return None @@ -3467,7 +3492,7 @@ class BrushFlow(_PluginBase): torrents = downloader.get_downloading_torrents(tags=brush_config.brush_tag) if torrents is None: - logger.warn("获取下载数量失败,可能是下载器连接发生异常") + logger.warning("获取下载数量失败,可能是下载器连接发生异常") return 0 return len(torrents) @@ -3813,3 +3838,17 @@ class BrushFlow(_PluginBase): # 当找不到对应的站点信息时,返回一个默认值 return 0, domain + + def __is_nexusphp(self, site_id): + """ + 是否NexusPHP站点 + """ + indexers = self.sites_helper.get_indexers() + if not indexers: + return False + + site = next((item for item in indexers if item.get("id") == site_id), None) + if not site: + return False + + return site.get("schema", "").startswith("Nexus") From 961c425edddf4cdbd31d9e8aeed1fc363ae7e8b7 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:27:33 +0800 Subject: [PATCH 2/2] feat(BrushFlow): v4.0 --- package.v2.json | 6 +++--- plugins.v2/brushflow/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.v2.json b/package.v2.json index 0fd8c0a..6392ad9 100644 --- a/package.v2.json +++ b/package.v2.json @@ -19,13 +19,13 @@ "name": "站点刷流", "description": "自动托管刷流,将会提高对应站点的访问频率。", "labels": "刷流,仪表板", - "version": "3.9.2", + "version": "4.0", "icon": "brush.jpg", "author": "jxxghp,InfinityPacer", "level": 2, "history": { - "v3.9": "MoviePilot V2 版本站点刷流插件", - "v3.9.1": "修复兼容性问题" + "v4.0": "NexusPHP 站点支持自动跳过下载提示页", + "v3.9": "MoviePilot V2 版本站点刷流插件" } }, "AutoSignIn": { diff --git a/plugins.v2/brushflow/__init__.py b/plugins.v2/brushflow/__init__.py index 83edc9f..1e45f6c 100644 --- a/plugins.v2/brushflow/__init__.py +++ b/plugins.v2/brushflow/__init__.py @@ -246,7 +246,7 @@ class BrushFlow(_PluginBase): # 插件图标 plugin_icon = "brush.jpg" # 插件版本 - plugin_version = "3.9.2" + plugin_version = "4.0" # 插件作者 plugin_author = "jxxghp,InfinityPacer" # 作者主页