mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix 订阅匹配
This commit is contained in:
+129
-132
@@ -647,153 +647,150 @@ class SubscribeChain(ChainBase):
|
|||||||
if domains and domain not in domains:
|
if domains and domain not in domains:
|
||||||
continue
|
continue
|
||||||
logger.debug(f'开始匹配站点:{domain},共缓存了 {len(contexts)} 个种子...')
|
logger.debug(f'开始匹配站点:{domain},共缓存了 {len(contexts)} 个种子...')
|
||||||
try:
|
for context in contexts:
|
||||||
for context in contexts:
|
if global_vars.is_system_stopped:
|
||||||
if global_vars.is_system_stopped:
|
break
|
||||||
break
|
# 提取信息
|
||||||
# 提取信息
|
_context = copy.copy(context)
|
||||||
_context = copy.copy(context)
|
torrent_meta = _context.meta_info
|
||||||
torrent_meta = _context.meta_info
|
torrent_mediainfo = _context.media_info
|
||||||
torrent_mediainfo = _context.media_info
|
torrent_info = _context.torrent_info
|
||||||
torrent_info = _context.torrent_info
|
|
||||||
|
|
||||||
# 不在订阅站点范围的不处理
|
# 不在订阅站点范围的不处理
|
||||||
sub_sites = self.get_sub_sites(subscribe)
|
sub_sites = self.get_sub_sites(subscribe)
|
||||||
if sub_sites and torrent_info.site not in sub_sites:
|
if sub_sites and torrent_info.site not in sub_sites:
|
||||||
logger.debug(f"{torrent_info.site_name} - {torrent_info.title} 不符合订阅站点要求")
|
logger.debug(f"{torrent_info.site_name} - {torrent_info.title} 不符合订阅站点要求")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 有自定义识别词时,需要判断是否需要重新识别
|
# 有自定义识别词时,需要判断是否需要重新识别
|
||||||
if custom_words_list:
|
if custom_words_list:
|
||||||
# 使用org_string,应用一次后理论上不能再次应用
|
# 使用org_string,应用一次后理论上不能再次应用
|
||||||
_, apply_words = wordsmatcher.prepare(torrent_meta.org_string,
|
_, apply_words = wordsmatcher.prepare(torrent_meta.org_string,
|
||||||
custom_words=custom_words_list)
|
custom_words=custom_words_list)
|
||||||
if apply_words:
|
if apply_words:
|
||||||
logger.info(
|
|
||||||
f'{torrent_info.site_name} - {torrent_info.title} 因订阅存在自定义识别词,重新识别元数据...')
|
|
||||||
# 重新识别元数据
|
|
||||||
torrent_meta = MetaInfo(title=torrent_info.title, subtitle=torrent_info.description,
|
|
||||||
custom_words=custom_words_list)
|
|
||||||
# 更新元数据缓存
|
|
||||||
_context.meta_info = torrent_meta
|
|
||||||
# 重新识别媒体信息
|
|
||||||
torrent_mediainfo = self.recognize_media(meta=torrent_meta,
|
|
||||||
episode_group=subscribe.episode_group)
|
|
||||||
if torrent_mediainfo:
|
|
||||||
# 清理多余信息
|
|
||||||
torrent_mediainfo.clear()
|
|
||||||
# 更新种子缓存
|
|
||||||
_context.media_info = torrent_mediainfo
|
|
||||||
|
|
||||||
# 如果仍然没有识别到媒体信息,尝试标题匹配
|
|
||||||
if not torrent_mediainfo or (not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f'{torrent_info.site_name} - {torrent_info.title} 重新识别失败,尝试通过标题匹配...')
|
f'{torrent_info.site_name} - {torrent_info.title} 因订阅存在自定义识别词,重新识别元数据...')
|
||||||
if torrenthelper.match_torrent(mediainfo=mediainfo,
|
# 重新识别元数据
|
||||||
torrent_meta=torrent_meta,
|
torrent_meta = MetaInfo(title=torrent_info.title, subtitle=torrent_info.description,
|
||||||
torrent=torrent_info):
|
custom_words=custom_words_list)
|
||||||
# 匹配成功
|
# 更新元数据缓存
|
||||||
logger.info(
|
_context.meta_info = torrent_meta
|
||||||
f'{mediainfo.title_year} 通过标题匹配到可选资源:{torrent_info.site_name} - {torrent_info.title}')
|
# 重新识别媒体信息
|
||||||
torrent_mediainfo = mediainfo
|
torrent_mediainfo = self.recognize_media(meta=torrent_meta,
|
||||||
|
episode_group=subscribe.episode_group)
|
||||||
|
if torrent_mediainfo:
|
||||||
|
# 清理多余信息
|
||||||
|
torrent_mediainfo.clear()
|
||||||
# 更新种子缓存
|
# 更新种子缓存
|
||||||
_context.media_info = mediainfo
|
_context.media_info = torrent_mediainfo
|
||||||
else:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# 直接比对媒体信息
|
# 如果仍然没有识别到媒体信息,尝试标题匹配
|
||||||
if torrent_mediainfo and (torrent_mediainfo.tmdb_id or torrent_mediainfo.douban_id):
|
if not torrent_mediainfo or (
|
||||||
if torrent_mediainfo.type != mediainfo.type:
|
not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id):
|
||||||
continue
|
logger.info(
|
||||||
if torrent_mediainfo.tmdb_id \
|
f'{torrent_info.site_name} - {torrent_info.title} 重新识别失败,尝试通过标题匹配...')
|
||||||
and torrent_mediainfo.tmdb_id != mediainfo.tmdb_id:
|
if torrenthelper.match_torrent(mediainfo=mediainfo,
|
||||||
continue
|
torrent_meta=torrent_meta,
|
||||||
if torrent_mediainfo.douban_id \
|
torrent=torrent_info):
|
||||||
and torrent_mediainfo.douban_id != mediainfo.douban_id:
|
# 匹配成功
|
||||||
continue
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f'{mediainfo.title_year} 通过媒体信ID匹配到可选资源:{torrent_info.site_name} - {torrent_info.title}')
|
f'{mediainfo.title_year} 通过标题匹配到可选资源:{torrent_info.site_name} - {torrent_info.title}')
|
||||||
|
torrent_mediainfo = mediainfo
|
||||||
|
# 更新种子缓存
|
||||||
|
_context.media_info = mediainfo
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 如果是电视剧
|
# 直接比对媒体信息
|
||||||
if torrent_mediainfo.type == MediaType.TV:
|
if torrent_mediainfo and (torrent_mediainfo.tmdb_id or torrent_mediainfo.douban_id):
|
||||||
# 有多季的不要
|
if torrent_mediainfo.type != mediainfo.type:
|
||||||
if len(torrent_meta.season_list) > 1:
|
continue
|
||||||
logger.debug(f'{torrent_info.title} 有多季,不处理')
|
if torrent_mediainfo.tmdb_id \
|
||||||
continue
|
and torrent_mediainfo.tmdb_id != mediainfo.tmdb_id:
|
||||||
# 比对季
|
continue
|
||||||
if torrent_meta.begin_season:
|
if torrent_mediainfo.douban_id \
|
||||||
if meta.begin_season != torrent_meta.begin_season:
|
and torrent_mediainfo.douban_id != mediainfo.douban_id:
|
||||||
logger.debug(f'{torrent_info.title} 季不匹配')
|
continue
|
||||||
continue
|
logger.info(
|
||||||
elif meta.begin_season != 1:
|
f'{mediainfo.title_year} 通过媒体信ID匹配到可选资源:{torrent_info.site_name} - {torrent_info.title}')
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 如果是电视剧
|
||||||
|
if torrent_mediainfo.type == MediaType.TV:
|
||||||
|
# 有多季的不要
|
||||||
|
if len(torrent_meta.season_list) > 1:
|
||||||
|
logger.debug(f'{torrent_info.title} 有多季,不处理')
|
||||||
|
continue
|
||||||
|
# 比对季
|
||||||
|
if torrent_meta.begin_season:
|
||||||
|
if meta.begin_season != torrent_meta.begin_season:
|
||||||
logger.debug(f'{torrent_info.title} 季不匹配')
|
logger.debug(f'{torrent_info.title} 季不匹配')
|
||||||
continue
|
continue
|
||||||
# 非洗版
|
elif meta.begin_season != 1:
|
||||||
if not subscribe.best_version:
|
logger.debug(f'{torrent_info.title} 季不匹配')
|
||||||
# 不是缺失的剧集不要
|
continue
|
||||||
if no_exists and no_exists.get(mediakey):
|
# 非洗版
|
||||||
# 缺失集
|
if not subscribe.best_version:
|
||||||
no_exists_info = no_exists.get(mediakey).get(subscribe.season)
|
# 不是缺失的剧集不要
|
||||||
if no_exists_info:
|
if no_exists and no_exists.get(mediakey):
|
||||||
# 是否有交集
|
# 缺失集
|
||||||
if no_exists_info.episodes and \
|
no_exists_info = no_exists.get(mediakey).get(subscribe.season)
|
||||||
torrent_meta.episode_list and \
|
if no_exists_info:
|
||||||
not set(no_exists_info.episodes).intersection(
|
# 是否有交集
|
||||||
set(torrent_meta.episode_list)
|
if no_exists_info.episodes and \
|
||||||
):
|
torrent_meta.episode_list and \
|
||||||
logger.debug(
|
not set(no_exists_info.episodes).intersection(
|
||||||
f'{torrent_info.title} 对应剧集 {torrent_meta.episode_list} 未包含缺失的剧集'
|
set(torrent_meta.episode_list)
|
||||||
)
|
):
|
||||||
continue
|
logger.debug(
|
||||||
else:
|
f'{torrent_info.title} 对应剧集 {torrent_meta.episode_list} 未包含缺失的剧集'
|
||||||
# 洗版时,非整季不要
|
)
|
||||||
if meta.type == MediaType.TV:
|
|
||||||
if torrent_meta.episode_list:
|
|
||||||
logger.debug(f'{subscribe.name} 正在洗版,{torrent_info.title} 不是整季')
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 匹配订阅附加参数
|
|
||||||
if not torrenthelper.filter_torrent(torrent_info=torrent_info,
|
|
||||||
filter_params=self.get_params(subscribe)):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# 优先级过滤规则
|
|
||||||
if subscribe.best_version:
|
|
||||||
rule_groups = subscribe.filter_groups \
|
|
||||||
or systemconfig.get(SystemConfigKey.BestVersionFilterRuleGroups)
|
|
||||||
else:
|
else:
|
||||||
rule_groups = subscribe.filter_groups \
|
# 洗版时,非整季不要
|
||||||
or systemconfig.get(SystemConfigKey.SubscribeFilterRuleGroups)
|
if meta.type == MediaType.TV:
|
||||||
result: List[TorrentInfo] = self.filter_torrents(
|
if torrent_meta.episode_list:
|
||||||
rule_groups=rule_groups,
|
logger.debug(f'{subscribe.name} 正在洗版,{torrent_info.title} 不是整季')
|
||||||
torrent_list=[torrent_info],
|
continue
|
||||||
mediainfo=torrent_mediainfo)
|
|
||||||
if result is not None and not result:
|
# 匹配订阅附加参数
|
||||||
# 不符合过滤规则
|
if not torrenthelper.filter_torrent(torrent_info=torrent_info,
|
||||||
logger.debug(f"{torrent_info.title} 不匹配过滤规则")
|
filter_params=self.get_params(subscribe)):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 优先级过滤规则
|
||||||
|
if subscribe.best_version:
|
||||||
|
rule_groups = subscribe.filter_groups \
|
||||||
|
or systemconfig.get(SystemConfigKey.BestVersionFilterRuleGroups)
|
||||||
|
else:
|
||||||
|
rule_groups = subscribe.filter_groups \
|
||||||
|
or systemconfig.get(SystemConfigKey.SubscribeFilterRuleGroups)
|
||||||
|
result: List[TorrentInfo] = self.filter_torrents(
|
||||||
|
rule_groups=rule_groups,
|
||||||
|
torrent_list=[torrent_info],
|
||||||
|
mediainfo=torrent_mediainfo)
|
||||||
|
if result is not None and not result:
|
||||||
|
# 不符合过滤规则
|
||||||
|
logger.debug(f"{torrent_info.title} 不匹配过滤规则")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 洗版时,优先级小于已下载优先级的不要
|
||||||
|
if subscribe.best_version:
|
||||||
|
if subscribe.current_priority \
|
||||||
|
and torrent_info.pri_order <= subscribe.current_priority:
|
||||||
|
logger.info(
|
||||||
|
f'{subscribe.name} 正在洗版,{torrent_info.title} 优先级低于或等于已下载优先级')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 洗版时,优先级小于已下载优先级的不要
|
# 匹配成功
|
||||||
if subscribe.best_version:
|
logger.info(f'{mediainfo.title_year} 匹配成功:{torrent_info.title}')
|
||||||
if subscribe.current_priority \
|
# 自定义属性
|
||||||
and torrent_info.pri_order <= subscribe.current_priority:
|
if subscribe.media_category:
|
||||||
logger.info(
|
torrent_mediainfo.category = subscribe.media_category
|
||||||
f'{subscribe.name} 正在洗版,{torrent_info.title} 优先级低于或等于已下载优先级')
|
if subscribe.episode_group:
|
||||||
continue
|
torrent_mediainfo.episode_group = subscribe.episode_group
|
||||||
|
_match_context.append(_context)
|
||||||
# 匹配成功
|
|
||||||
logger.info(f'{mediainfo.title_year} 匹配成功:{torrent_info.title}')
|
|
||||||
# 自定义属性
|
|
||||||
if subscribe.media_category:
|
|
||||||
torrent_mediainfo.category = subscribe.media_category
|
|
||||||
if subscribe.episode_group:
|
|
||||||
torrent_mediainfo.episode_group = subscribe.episode_group
|
|
||||||
_match_context.append(_context)
|
|
||||||
finally:
|
|
||||||
contexts.clear()
|
|
||||||
del contexts
|
|
||||||
|
|
||||||
if not _match_context:
|
if not _match_context:
|
||||||
# 未匹配到资源
|
# 未匹配到资源
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
APP_VERSION = 'v2.5.9-2'
|
APP_VERSION = 'v2.5.9-3'
|
||||||
FRONTEND_VERSION = 'v2.5.9-1'
|
FRONTEND_VERSION = 'v2.5.9-1'
|
||||||
|
|||||||
Reference in New Issue
Block a user