fix 年份匹配

This commit is contained in:
jxxghp 2023-06-11 18:42:23 +08:00
parent 1b64ff0469
commit db4b9fcef8
4 changed files with 31 additions and 5 deletions

View File

@ -386,7 +386,7 @@ class DownloadChain(ChainBase):
# 所有剧集均缺失 # 所有剧集均缺失
for season, episodes in mediainfo.seasons.items(): for season, episodes in mediainfo.seasons.items():
# 全季不存在 # 全季不存在
if meta.get_season_list() \ if meta.begin_season \
and season not in meta.get_season_list(): and season not in meta.get_season_list():
continue continue
__append_no_exists(_season=season, _episodes=[], _total=len(episodes), _start=min(episodes)) __append_no_exists(_season=season, _episodes=[], _total=len(episodes), _start=min(episodes))
@ -394,7 +394,7 @@ class DownloadChain(ChainBase):
else: else:
# 存在一些,检查缺失的季集 # 存在一些,检查缺失的季集
for season, episodes in mediainfo.seasons.items(): for season, episodes in mediainfo.seasons.items():
if meta.get_season_list() \ if meta.begin_season \
and season not in meta.get_season_list(): and season not in meta.get_season_list():
continue continue
exist_seasons = exists_tvs.get("seasons") exist_seasons = exists_tvs.get("seasons")

View File

@ -8,6 +8,7 @@ from app.core.metainfo import MetaInfo
from app.helper.sites import SitesHelper from app.helper.sites import SitesHelper
from app.log import logger from app.log import logger
from app.utils.string import StringUtils from app.utils.string import StringUtils
from app.utils.types import MediaType
class SearchChain(ChainBase): class SearchChain(ChainBase):
@ -64,6 +65,7 @@ class SearchChain(ChainBase):
logger.warn(f'{keyword or mediainfo.title} 未搜索到资源') logger.warn(f'{keyword or mediainfo.title} 未搜索到资源')
return [] return []
# 过滤种子 # 过滤种子
logger.info(f'开始过滤资源,当前规则:{settings.FILTER_RULE} ...')
result: List[TorrentInfo] = self.filter_torrents(torrent_list=torrents, result: List[TorrentInfo] = self.filter_torrents(torrent_list=torrents,
season_episodes=season_episodes) season_episodes=season_episodes)
if result is not None: if result is not None:
@ -72,6 +74,7 @@ class SearchChain(ChainBase):
logger.warn(f'{keyword or mediainfo.title} 没有符合过滤条件的资源') logger.warn(f'{keyword or mediainfo.title} 没有符合过滤条件的资源')
return [] return []
# 过滤不匹配的资源 # 过滤不匹配的资源
logger.info(f'开始匹配,总 {len(torrents)} 个资源 ...')
_match_torrents = [] _match_torrents = []
if mediainfo: if mediainfo:
for torrent in torrents: for torrent in torrents:
@ -84,6 +87,16 @@ class SearchChain(ChainBase):
continue continue
# 识别 # 识别
torrent_meta = MetaInfo(torrent.title, torrent.description) torrent_meta = MetaInfo(torrent.title, torrent.description)
# 比对年份
if torrent_meta.year and mediainfo.year:
if mediainfo.type == MediaType.TV:
# 剧集
if torrent_meta.year not in [year for year in mediainfo.season_years.values()]:
continue
else:
# 没有季的剧集或者电影
if torrent_meta.year != mediainfo.year:
continue
# 比对标题 # 比对标题
if torrent_meta.get_name() in [mediainfo.title, mediainfo.original_title]: if torrent_meta.get_name() in [mediainfo.title, mediainfo.original_title]:
logger.info(f'{mediainfo.title} 匹配到资源:{torrent.site_name} - {torrent.title}') logger.info(f'{mediainfo.title} 匹配到资源:{torrent.site_name} - {torrent.title}')
@ -98,6 +111,7 @@ class SearchChain(ChainBase):
break break
else: else:
_match_torrents = torrents _match_torrents = torrents
logger.info(f"匹配完成,共匹配到 {len(_match_torrents)} 个资源")
# 组装上下文返回 # 组装上下文返回
return [Context(meta=MetaInfo(torrent.title), return [Context(meta=MetaInfo(torrent.title),
mediainfo=mediainfo, mediainfo=mediainfo,

View File

@ -105,7 +105,9 @@ class UserMessageChain(ChainBase):
no_exists=no_exists) no_exists=no_exists)
if not contexts: if not contexts:
# 没有数据 # 没有数据
self.post_message(title=f"{mediainfo.title} 未搜索到资源!", userid=userid) self.post_message(title=f"{mediainfo.title}"
f"{self._current_meta.get_season_string()} 未搜索到资源!",
userid=userid)
return return
# 搜索结果排序 # 搜索结果排序
contexts = TorrentHelper.sort_torrents(contexts) contexts = TorrentHelper.sort_torrents(contexts)

View File

@ -122,6 +122,8 @@ class MediaInfo:
names: Optional[list] = [] names: Optional[list] = []
# 各季的剧集清单信息 # 各季的剧集清单信息
seasons: Optional[dict] = {} seasons: Optional[dict] = {}
# 各季的年份
season_years: Optional[dict] = {}
# 二级分类 # 二级分类
category: str = "" category: str = ""
# TMDB INFO # TMDB INFO
@ -137,6 +139,7 @@ class MediaInfo:
# 初始化 # 初始化
self.seasons = {} self.seasons = {}
self.names = [] self.names = []
self.season_years = {}
self.directors = [] self.directors = []
self.actors = [] self.actors = []
self.tmdb_info = {} self.tmdb_info = {}
@ -267,10 +270,17 @@ class MediaInfo:
# 季集信息 # 季集信息
if info.get('seasons'): if info.get('seasons'):
for season_info in info.get('seasons'): for season_info in info.get('seasons'):
if not season_info.get("season_number"): # 季
season = season_info.get("season_number")
if not season:
continue continue
# 集
episode_count = season_info.get("episode_count") episode_count = season_info.get("episode_count")
self.seasons[season_info.get("season_number")] = list(range(1, episode_count + 1)) self.seasons[season] = list(range(1, episode_count + 1))
# 年份
air_date = season_info.get("air_date")
if air_date:
self.season_years[season] = air_date[:4]
# 海报 # 海报
if info.get('poster_path'): if info.get('poster_path'):
self.poster_path = f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{info.get('poster_path')}" self.poster_path = f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{info.get('poster_path')}"