From 82226f195623a83268d2cb3a6cb2865e86176aff Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 21 May 2024 11:57:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=20https://github.com/jxxghp/MoviePilot/issu?= =?UTF-8?q?es/2125=20=20=E8=B0=83=E6=95=B4=E8=AE=A2=E9=98=85=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/search.py | 13 ------------- app/chain/subscribe.py | 42 ++++++++++++++++++++++-------------------- app/helper/torrent.py | 10 ++++++++++ 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/app/chain/search.py b/app/chain/search.py index 9df06e27..4cb72c8b 100644 --- a/app/chain/search.py +++ b/app/chain/search.py @@ -192,19 +192,6 @@ class SearchChain(ChainBase): torrent_meta = MetaInfo(title=torrent.title, subtitle=torrent.description) if torrent.title != torrent_meta.org_string: logger.info(f"种子名称应用识别词后发生改变:{torrent.title} => {torrent_meta.org_string}") - # 比对词条指定的tmdbid - if torrent_meta.tmdbid or torrent_meta.doubanid: - if torrent_meta.tmdbid and torrent_meta.tmdbid == mediainfo.tmdb_id: - logger.info( - f'{mediainfo.title} 通过词表指定TMDBID匹配到资源:{torrent.site_name} - {torrent.title}') - _match_torrents.append(torrent) - continue - if torrent_meta.doubanid and torrent_meta.doubanid == mediainfo.douban_id: - logger.info( - f'{mediainfo.title} 通过词表指定豆瓣ID匹配到资源:{torrent.site_name} - {torrent.title}') - _match_torrents.append(torrent) - continue - # 比对种子 if self.torrenthelper.match_torrent(mediainfo=mediainfo, torrent_meta=torrent_meta, diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index 9b919369..71124041 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -597,9 +597,27 @@ class SubscribeChain(ChainBase): torrent_meta = context.meta_info torrent_mediainfo = context.media_info torrent_info = context.torrent_info - # 如果识别了媒体信息,则比对TMDBID和类型 - if torrent_mediainfo.tmdb_id or torrent_mediainfo.douban_id: - # 直接比对媒体信息 + + # 先判断是否有没识别的种子 + if not torrent_mediainfo or (not torrent_mediainfo.tmdb_id and not torrent_mediainfo.douban_id): + logger.info(f'{torrent_info.site_name} - {torrent_info.title} 订阅缓存为未识别状态,偿试重新识别...') + # 重新识别(不使用缓存) + torrent_mediainfo = self.recognize_media(meta=meta, cache=False) + if not torrent_mediainfo: + logger.warn(f'{torrent_info.site_name} - {torrent_info.title} 重新识别失败,偿试通过标题匹配...') + if self.torrenthelper.match_torrent(mediainfo=mediainfo, + torrent_meta=torrent_meta, + torrent=torrent_info): + # 匹配成功 + logger.info(f'{mediainfo.title_year} 通过标题匹配到资源:{torrent_info.site_name} - {torrent_info.title}') + # 更新缓存 + torrent_mediainfo = mediainfo + context.media_info = mediainfo + else: + continue + + # 直接比对媒体信息 + if torrent_mediainfo and (torrent_mediainfo.tmdb_id or torrent_mediainfo.douban_id): if torrent_mediainfo.type != mediainfo.type: continue if torrent_mediainfo.tmdb_id \ @@ -610,23 +628,7 @@ class SubscribeChain(ChainBase): continue logger.info( f'{mediainfo.title_year} 通过媒体信ID匹配到资源:{torrent_info.site_name} - {torrent_info.title}') - else: - # 没有torrent_mediainfo媒体信息,按标题匹配 - manual_match = False - # 比对词条指定的tmdbid - if torrent_meta.tmdbid or torrent_meta.doubanid: - if torrent_meta.tmdbid and torrent_meta.tmdbid != mediainfo.tmdb_id: - continue - if torrent_meta.doubanid and torrent_meta.doubanid != mediainfo.douban_id: - continue - manual_match = True - if not manual_match: - # 没有指定tmdbid,按标题匹配 - if not self.torrenthelper.match_torrent(mediainfo=mediainfo, - torrent_meta=torrent_meta, - torrent=torrent_info, - logerror=False): - continue + # 优先级过滤规则 if subscribe.best_version: priority_rule = self.systemconfig.get(SystemConfigKey.BestVersionFilterRules) diff --git a/app/helper/torrent.py b/app/helper/torrent.py index 692bde4a..3ec7ef0d 100644 --- a/app/helper/torrent.py +++ b/app/helper/torrent.py @@ -437,6 +437,16 @@ class TorrentHelper(metaclass=Singleton): :param torrent: 种子信息 :param logerror: 是否记录错误日志 """ + # 比对词条指定的tmdbid + if torrent_meta.tmdbid or torrent_meta.doubanid: + if torrent_meta.tmdbid and torrent_meta.tmdbid == mediainfo.tmdb_id: + logger.info( + f'{mediainfo.title} 通过词表指定TMDBID匹配到资源:{torrent.site_name} - {torrent.title}') + return True + if torrent_meta.doubanid and torrent_meta.doubanid == mediainfo.douban_id: + logger.info( + f'{mediainfo.title} 通过词表指定豆瓣ID匹配到资源:{torrent.site_name} - {torrent.title}') + return True # 要匹配的媒体标题、原标题 media_titles = { StringUtils.clear_upper(mediainfo.title),