mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-21 16:23:34 +08:00
fix: preserve parent year in media recognition
This commit is contained in:
@@ -9,6 +9,7 @@ from app.chain.tmdb import TmdbChain
|
||||
from app.core.config import settings
|
||||
from app.core.context import Context
|
||||
from app.core.event import eventmanager
|
||||
from app.core.meta import MetaBase
|
||||
from app.core.metainfo import MetaInfo, MetaInfoPath
|
||||
from app.core.security import verify_token, verify_apitoken
|
||||
from app.db.models import User
|
||||
@@ -22,6 +23,29 @@ router = APIRouter()
|
||||
MediaSource = str
|
||||
|
||||
|
||||
def _build_recognize_metainfo(
|
||||
title: str,
|
||||
subtitle: Optional[str] = None,
|
||||
custom_words: Optional[str] = None,
|
||||
) -> MetaBase:
|
||||
"""构造标题识别元数据,并兼容第三方客户端传入媒体文件路径。"""
|
||||
custom_word_list = custom_words.split("\n") if custom_words else None
|
||||
normalized_title = title.replace("\\", "/")
|
||||
title_path = Path(normalized_title)
|
||||
if (
|
||||
("/" in title or "\\" in title)
|
||||
and "://" not in title
|
||||
and title_path.suffix.lower() in settings.RMT_MEDIAEXT
|
||||
):
|
||||
metainfo = MetaInfoPath(
|
||||
title_path,
|
||||
custom_words=custom_word_list,
|
||||
)
|
||||
metainfo.title = title
|
||||
return metainfo
|
||||
return MetaInfo(title, subtitle, custom_words=custom_word_list)
|
||||
|
||||
|
||||
def _build_media_seasons(
|
||||
mediainfo: Any, season: Optional[int] = None,
|
||||
) -> List[schemas.MediaSeason]:
|
||||
@@ -84,9 +108,7 @@ async def recognize(
|
||||
:param _:
|
||||
"""
|
||||
# 识别媒体信息,传入临时识别词时优先于系统配置的识别词生效
|
||||
metainfo = MetaInfo(
|
||||
title, subtitle, custom_words=custom_words.split("\n") if custom_words else None
|
||||
)
|
||||
metainfo = _build_recognize_metainfo(title, subtitle, custom_words)
|
||||
mediainfo = await MediaChain().async_recognize_by_meta(
|
||||
metainfo,
|
||||
source=source,
|
||||
|
||||
Reference in New Issue
Block a user