diff --git a/package.json b/package.json index 33b78e9..23c25da 100644 --- a/package.json +++ b/package.json @@ -298,11 +298,12 @@ "name": "站点刷流", "description": "自动托管刷流,将会提高对应站点的访问频率。", "labels": "刷流", - "version": "2.9", + "version": "3.0", "icon": "brush.jpg", "author": "jxxghp,InfinityPacer", "level": 2, "history": { + "v3.0": "优化不同站点刷流到相同种子的逻辑,修复数据页滚动闪烁,部分日志优化", "v2.9": "优化动态删除消息推送,优化配置页UI显示及部分配置项,支持配置种子分类以及开启自动分类管理,取消单独适配站点时区逻辑,可通过配置项「pubtime」自行适配", "v2.8": "优化UI显示以及提升性能", "v2.7": "动态删除种子规则调整(请注意查阅插件文档),站点独立配置样式优化、日志优化,修复部分配置项无法配置小数的问题,修复部分场景可能导致重复下载的问题", diff --git a/plugins/brushflow/__init__.py b/plugins/brushflow/__init__.py index 555aee0..57ae976 100644 --- a/plugins/brushflow/__init__.py +++ b/plugins/brushflow/__init__.py @@ -10,6 +10,9 @@ from typing import Any, List, Dict, Tuple, Optional, Union, Set from urllib.parse import urlparse, parse_qs, unquote import pytz +from app.helper.sites import SitesHelper +from apscheduler.schedulers.background import BackgroundScheduler + from app import schemas from app.chain.torrents import TorrentsChain from app.core.config import settings @@ -17,7 +20,6 @@ from app.core.context import MediaInfo from app.core.metainfo import MetaInfo from app.db.site_oper import SiteOper from app.db.subscribe_oper import SubscribeOper -from app.helper.sites import SitesHelper from app.log import logger from app.modules.qbittorrent import Qbittorrent from app.modules.transmission import Transmission @@ -25,7 +27,6 @@ from app.plugins import _PluginBase from app.schemas import NotificationType, TorrentInfo, MediaType from app.utils.http import RequestUtils from app.utils.string import StringUtils -from apscheduler.schedulers.background import BackgroundScheduler lock = threading.Lock() @@ -146,9 +147,10 @@ class BrushConfig: @staticmethod def get_demo_site_config() -> str: - desc = ("// 以下为配置示例,请参考:https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/README.md 进行配置\n" - "// 如与全局保持一致的配置项,请勿在站点配置中配置\n" - "// 注意无关内容需使用 // 注释\n") + desc = ( + "// 以下为配置示例,请参考:https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/plugins/brushflowlowfreq/README.md 进行配置\n" + "// 如与全局保持一致的配置项,请勿在站点配置中配置\n" + "// 注意无关内容需使用 // 注释\n") config = """[{ "sitename": "站点1", "seed_time": 96, @@ -249,7 +251,7 @@ class BrushFlow(_PluginBase): # 插件图标 plugin_icon = "brush.jpg" # 插件版本 - plugin_version = "2.9" + plugin_version = "3.0" # 插件作者 plugin_author = "jxxghp,InfinityPacer" # 作者主页 @@ -1239,7 +1241,7 @@ class BrushFlow(_PluginBase): "component": "VSwitch", "props": { "model": "dialog_closed", - "label": "设置站点" + "label": "打开站点配置窗口" } } ] @@ -1342,15 +1344,20 @@ class BrushFlow(_PluginBase): 'content': [ { 'component': 'span', - 'text': '部分配置项以及细节请参考:' + 'text': '注意:详细配置说明以及刷流规则请参考:' }, { 'component': 'a', 'props': { - 'href': 'https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/README.md', + 'href': 'https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/plugins/brushflowlowfreq/README.md', 'target': '_blank' }, - 'text': 'https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/README.md' + 'content': [ + { + 'component': 'u', + 'text': 'README' + } + ] } ] } @@ -1449,10 +1456,15 @@ class BrushFlow(_PluginBase): { 'component': 'a', 'props': { - 'href': 'https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/README.md', + 'href': 'https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/plugins/brushflowlowfreq/README.md', 'target': '_blank' }, - 'text': 'https://github.com/InfinityPacer/MoviePilot-Plugins/blob/main/README.md' + 'content': [ + { + 'component': 'u', + 'text': 'README' + } + ] } ] } @@ -1551,6 +1563,11 @@ class BrushFlow(_PluginBase): return [ { 'component': 'VRow', + 'props': { + 'style': { + 'overflow': 'hidden', + } + }, 'content': [ # 总上传量 { @@ -2149,6 +2166,12 @@ class BrushFlow(_PluginBase): torrent_tasks.values()): return False, "重复种子" + # 不同站点如果遇到相同种子,判断前一个种子是否已经在做种,否则排除处理 + if torrent.title: + if any(torrent.site_name != f"{task.get('site_name')}" and torrent.title == f"{task.get('title')}" + and not task.get("seed_time") for task in torrent_tasks.values()): + return False, "其他站点存在尚未下载完成的相同种子" + # 促销条件 if brush_config.freeleech and torrent.downloadvolumefactor != 0: return False, "非免费种子" @@ -2286,15 +2309,15 @@ class BrushFlow(_PluginBase): # 如果配置了动态删除以及删种阈值,则根据动态删种进行分组处理 if brush_config.proxy_delete and brush_config.delete_size_range: logger.info("已开启动态删种,按系统默认动态删种条件开始检查任务") - proxy_delete_hashs = self.__delete_torrent_for_proxy(torrents=check_torrents, - torrent_tasks=torrent_tasks) or [] - need_delete_hashes.extend(proxy_delete_hashs) + proxy_delete_hashes = self.__delete_torrent_for_proxy(torrents=check_torrents, + torrent_tasks=torrent_tasks) or [] + need_delete_hashes.extend(proxy_delete_hashes) # 否则均认为是没有开启动态删种 else: logger.info("没有开启动态删种,按用户设置删种条件开始检查任务") - not_proxy_delete_hashs = self.__delete_torrent_for_evaluate_conditions(torrents=check_torrents, - torrent_tasks=torrent_tasks) or [] - need_delete_hashes.extend(not_proxy_delete_hashs) + not_proxy_delete_hashes = self.__delete_torrent_for_evaluate_conditions(torrents=check_torrents, + torrent_tasks=torrent_tasks) or [] + need_delete_hashes.extend(not_proxy_delete_hashes) if need_delete_hashes: if downloader.delete_torrents(ids=need_delete_hashes, delete_file=True): @@ -2493,7 +2516,7 @@ class BrushFlow(_PluginBase): 根据条件删除种子并获取已删除列表 """ brush_config = self.__get_brush_config() - delete_hashs = [] + delete_hashes = [] for torrent in torrents: torrent_hash = self.__get_hash(torrent) @@ -2512,8 +2535,8 @@ class BrushFlow(_PluginBase): torrent_info=torrent_info, torrent_task=torrent_task) if should_delete: - delete_hashs.append(torrent_hash) - reason = "触发动态删除," + reason if proxy_delete else reason + delete_hashes.append(torrent_hash) + reason = "触发动态删除阈值," + reason if proxy_delete else reason self.__send_delete_message(site_name=site_name, torrent_title=torrent_title, torrent_desc=torrent_desc, reason=reason) logger.info(f"站点:{site_name},{reason},删除种子:{torrent_title}|{torrent_desc}") @@ -2521,7 +2544,7 @@ class BrushFlow(_PluginBase): if brush_config.log_more: logger.info(f"站点:{site_name},{reason},不删除种子:{torrent_title}|{torrent_desc}") - return delete_hashs + return delete_hashes def __delete_torrent_for_evaluate_proxy_pre_conditions(self, torrents: List[Any], torrent_tasks: Dict[str, dict]) -> List: @@ -2529,7 +2552,7 @@ class BrushFlow(_PluginBase): 根据动态删除前置条件排除H&R种子后删除种子并获取已删除列表 """ brush_config = self.__get_brush_config() - delete_hashs = [] + delete_hashes = [] for torrent in torrents: torrent_hash = self.__get_hash(torrent) @@ -2552,7 +2575,7 @@ class BrushFlow(_PluginBase): should_delete, reason = self.__evaluate_proxy_pre_conditions_for_delete(site_name=site_name, torrent_info=torrent_info) if should_delete: - delete_hashs.append(torrent_hash) + delete_hashes.append(torrent_hash) self.__send_delete_message(site_name=site_name, torrent_title=torrent_title, torrent_desc=torrent_desc, reason=reason) logger.info(f"站点:{site_name},{reason},删除种子:{torrent_title}|{torrent_desc}") @@ -2560,7 +2583,7 @@ class BrushFlow(_PluginBase): if brush_config.log_more: logger.info(f"站点:{site_name},{reason},不删除种子:{torrent_title}|{torrent_desc}") - return delete_hashs + return delete_hashes def __delete_torrent_for_proxy(self, torrents: List[Any], torrent_tasks: Dict[str, dict]) -> List: """ @@ -3557,7 +3580,7 @@ class BrushFlow(_PluginBase): now = datetime.now() return (now - pubdate).total_seconds() // 60 except Exception as e: - print(str(e)) + logger.error(f"发布时间 {pubdate} 获取分钟失败,错误详情: {e}") return 0 @staticmethod