From 9686a20c2f71e8a3741c7cfc351bb0b4232c7bcd Mon Sep 17 00:00:00 2001 From: thsrite Date: Mon, 28 Oct 2024 11:29:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#2905=20=E8=AE=A2=E9=98=85=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=B8=8D=E8=B5=B0=E8=AE=A2=E9=98=85=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E5=88=86=E8=BE=A8=E7=8E=87=E7=AD=89=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/search.py | 29 ++++++++++++++++++++++++++++- app/chain/subscribe.py | 3 ++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/chain/search.py b/app/chain/search.py index 08046c6c..b5d759ba 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -11,6 +11,7 @@ from app.core.context import Context from app.core.context import MediaInfo, TorrentInfo from app.core.event import eventmanager, Event from app.core.metainfo import MetaInfo +from app.db.models import Subscribe from app.db.systemconfig_oper import SystemConfigOper from app.helper.progress import ProgressHelper from app.helper.sites import SitesHelper @@ -105,7 +106,8 @@ class SearchChain(ChainBase): sites: List[int] = None, rule_groups: List[str] = None, area: str = "title", - custom_words: List[str] = None) -> List[Context]: + custom_words: List[str] = None, + subscribe: Subscribe = None) -> List[Context]: """ 根据媒体信息搜索种子资源,精确匹配,应用过滤规则,同时根据no_exists过滤本地已存在的资源 :param mediainfo: 媒体信息 @@ -231,6 +233,13 @@ class SearchChain(ChainBase): logger.info(f'{mediainfo.title} 通过IMDBID匹配到资源:{torrent.site_name} - {torrent.title}') _match_torrents.append((torrent, torrent_meta)) continue + + # 匹配订阅附加参数 + if subscribe and not self.torrenthelper.filter_torrent(torrent_info=torrent, + filter_params=self.__get_subscribe_params( + subscribe)): + continue + # 比对种子 if self.torrenthelper.match_torrent(mediainfo=mediainfo, torrent_meta=torrent_meta, @@ -270,6 +279,24 @@ class SearchChain(ChainBase): # 返回 return contexts + def __get_subscribe_params(self, subscribe: Subscribe): + """ + 获取订阅默认参数 + """ + # 默认过滤规则 + default_rule = self.systemconfig.get(SystemConfigKey.SubscribeDefaultParams) or {} + return { + "include": subscribe.include or default_rule.get("include"), + "exclude": subscribe.exclude or default_rule.get("exclude"), + "quality": subscribe.quality or default_rule.get("quality"), + "resolution": subscribe.resolution or default_rule.get("resolution"), + "effect": subscribe.effect or default_rule.get("effect"), + "tv_size": default_rule.get("tv_size"), + "movie_size": default_rule.get("movie_size"), + "min_seeders": default_rule.get("min_seeders"), + "min_seeders_time": default_rule.get("min_seeders_time"), + } + def __search_all_sites(self, keywords: List[str], mediainfo: Optional[MediaInfo] = None, sites: List[int] = None, diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index d795d07a..fafdbf9f 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -348,7 +348,8 @@ class SubscribeChain(ChainBase): sites=sites, rule_groups=rule_groups, area="imdbid" if subscribe.search_imdbid else "title", - custom_words=custom_word_list) + custom_words=custom_word_list, + subscribe=subscribe) if not contexts: logger.warn(f'订阅 {subscribe.keyword or subscribe.name} 未搜索到资源') self.finish_subscribe_or_not(subscribe=subscribe, meta=meta,