fix filter
This commit is contained in:
parent
c39ccde876
commit
9203c63094
@ -83,13 +83,15 @@ class SearchChain(ChainBase):
|
|||||||
def process(self, mediainfo: MediaInfo,
|
def process(self, mediainfo: MediaInfo,
|
||||||
keyword: str = None,
|
keyword: str = None,
|
||||||
no_exists: Dict[int, Dict[int, NotExistMediaInfo]] = None,
|
no_exists: Dict[int, Dict[int, NotExistMediaInfo]] = None,
|
||||||
sites: List[int] = None) -> List[Context]:
|
sites: List[int] = None,
|
||||||
|
filter_rule: str = None) -> List[Context]:
|
||||||
"""
|
"""
|
||||||
根据媒体信息搜索种子资源,精确匹配,应用过滤规则,同时根据no_exists过滤本地已存在的资源
|
根据媒体信息搜索种子资源,精确匹配,应用过滤规则,同时根据no_exists过滤本地已存在的资源
|
||||||
:param mediainfo: 媒体信息
|
:param mediainfo: 媒体信息
|
||||||
:param keyword: 搜索关键词
|
:param keyword: 搜索关键词
|
||||||
:param no_exists: 缺失的媒体信息
|
:param no_exists: 缺失的媒体信息
|
||||||
:param sites: 站点ID列表,为空时搜索所有站点
|
:param sites: 站点ID列表,为空时搜索所有站点
|
||||||
|
:param filter_rule: 过滤规则,为空是使用默认过滤规则
|
||||||
"""
|
"""
|
||||||
logger.info(f'开始搜索资源,关键词:{keyword or mediainfo.title} ...')
|
logger.info(f'开始搜索资源,关键词:{keyword or mediainfo.title} ...')
|
||||||
# 补充媒体信息
|
# 补充媒体信息
|
||||||
@ -116,9 +118,12 @@ class SearchChain(ChainBase):
|
|||||||
logger.warn(f'{keyword or mediainfo.title} 未搜索到资源')
|
logger.warn(f'{keyword or mediainfo.title} 未搜索到资源')
|
||||||
return []
|
return []
|
||||||
# 过滤种子
|
# 过滤种子
|
||||||
filter_rules = self.systemconfig.get(SystemConfigKey.FilterRules)
|
if filter_rule is None:
|
||||||
logger.info(f'开始过滤资源,当前规则:{filter_rules} ...')
|
# 取默认过滤规则
|
||||||
result: List[TorrentInfo] = self.filter_torrents(rule_string=filter_rules,
|
filter_rule = self.systemconfig.get(SystemConfigKey.FilterRules)
|
||||||
|
if filter_rule:
|
||||||
|
logger.info(f'开始过滤资源,当前规则:{filter_rule} ...')
|
||||||
|
result: List[TorrentInfo] = self.filter_torrents(rule_string=filter_rule,
|
||||||
torrent_list=torrents,
|
torrent_list=torrents,
|
||||||
season_episodes=season_episodes)
|
season_episodes=season_episodes)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
|
@ -241,11 +241,17 @@ class SubscribeChain(ChainBase):
|
|||||||
sites = json.loads(subscribe.sites)
|
sites = json.loads(subscribe.sites)
|
||||||
else:
|
else:
|
||||||
sites = None
|
sites = None
|
||||||
|
# 过滤规则
|
||||||
|
if subscribe.best_version:
|
||||||
|
filter_rule = self.systemconfig.get(SystemConfigKey.FilterRules2)
|
||||||
|
else:
|
||||||
|
filter_rule = self.systemconfig.get(SystemConfigKey.FilterRules)
|
||||||
# 搜索,同时电视剧会过滤掉不需要的剧集
|
# 搜索,同时电视剧会过滤掉不需要的剧集
|
||||||
contexts = self.searchchain.process(mediainfo=mediainfo,
|
contexts = self.searchchain.process(mediainfo=mediainfo,
|
||||||
keyword=subscribe.keyword,
|
keyword=subscribe.keyword,
|
||||||
no_exists=no_exists,
|
no_exists=no_exists,
|
||||||
sites=sites)
|
sites=sites,
|
||||||
|
filter_rule=filter_rule)
|
||||||
if not contexts:
|
if not contexts:
|
||||||
logger.warn(f'订阅 {subscribe.keyword or subscribe.name} 未搜索到资源')
|
logger.warn(f'订阅 {subscribe.keyword or subscribe.name} 未搜索到资源')
|
||||||
if meta.type == MediaType.TV:
|
if meta.type == MediaType.TV:
|
||||||
@ -366,15 +372,6 @@ class SubscribeChain(ChainBase):
|
|||||||
domain = StringUtils.get_url_domain(indexer.get("domain"))
|
domain = StringUtils.get_url_domain(indexer.get("domain"))
|
||||||
torrents: List[TorrentInfo] = self.refresh_torrents(site=indexer)
|
torrents: List[TorrentInfo] = self.refresh_torrents(site=indexer)
|
||||||
if torrents:
|
if torrents:
|
||||||
# 过滤种子
|
|
||||||
result: List[TorrentInfo] = self.filter_torrents(
|
|
||||||
rule_string=self.systemconfig.get(SystemConfigKey.FilterRules),
|
|
||||||
torrent_list=torrents)
|
|
||||||
if result is not None:
|
|
||||||
torrents = result
|
|
||||||
if not torrents:
|
|
||||||
logger.warn(f'{indexer.get("name")} 没有符合过滤条件的种子')
|
|
||||||
continue
|
|
||||||
# 过滤出没有处理过的种子
|
# 过滤出没有处理过的种子
|
||||||
torrents = [torrent for torrent in torrents
|
torrents = [torrent for torrent in torrents
|
||||||
if f'{torrent.title}{torrent.description}'
|
if f'{torrent.title}{torrent.description}'
|
||||||
@ -493,6 +490,17 @@ class SubscribeChain(ChainBase):
|
|||||||
if torrent_mediainfo.tmdb_id != mediainfo.tmdb_id \
|
if torrent_mediainfo.tmdb_id != mediainfo.tmdb_id \
|
||||||
or torrent_mediainfo.type != mediainfo.type:
|
or torrent_mediainfo.type != mediainfo.type:
|
||||||
continue
|
continue
|
||||||
|
# 过滤规则
|
||||||
|
if subscribe.best_version:
|
||||||
|
filter_rule = self.systemconfig.get(SystemConfigKey.FilterRules2)
|
||||||
|
else:
|
||||||
|
filter_rule = self.systemconfig.get(SystemConfigKey.FilterRules)
|
||||||
|
result: List[TorrentInfo] = self.filter_torrents(
|
||||||
|
rule_string=filter_rule,
|
||||||
|
torrent_list=[torrent_info])
|
||||||
|
if result is not None and not result:
|
||||||
|
# 不符合过滤规则
|
||||||
|
continue
|
||||||
# 不在订阅站点范围的不处理
|
# 不在订阅站点范围的不处理
|
||||||
if subscribe.sites:
|
if subscribe.sites:
|
||||||
sub_sites = json.loads(subscribe.sites)
|
sub_sites = json.loads(subscribe.sites)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user