From b789bfc979cebfbd285f53a18fe4ee7e9660e342 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 22 Jul 2023 12:53:12 +0800 Subject: [PATCH] fix bug --- app/api/endpoints/media.py | 6 +++++- app/core/context.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/api/endpoints/media.py b/app/api/endpoints/media.py index c983f687..423c4902 100644 --- a/app/api/endpoints/media.py +++ b/app/api/endpoints/media.py @@ -5,6 +5,7 @@ from sqlalchemy.orm import Session from app import schemas from app.chain.media import MediaChain +from app.core.metainfo import MetaInfo from app.core.security import verify_token from app.db import get_db from app.db.mediaserver_oper import MediaServerOper @@ -51,8 +52,11 @@ def exists(title: str = None, """ 判断本地是否存在 """ + meta = MetaInfo(title) + if not season: + season = meta.begin_season exist = MediaServerOper(db).exists( - title=title, year=year, mtype=mtype, tmdbid=tmdbid, season=season + title=meta.name, year=year, mtype=mtype, tmdbid=tmdbid, season=season ) return schemas.Response(success=True if exist else False, data={ "item": exist or {} diff --git a/app/core/context.py b/app/core/context.py index 3f158a4f..54d165f4 100644 --- a/app/core/context.py +++ b/app/core/context.py @@ -399,6 +399,11 @@ class MediaInfo: # 简介 if not self.overview: self.overview = info.get("intro") or info.get("card_subtitle") or "" + # 从简介中提取年份 + if self.overview and not self.year: + match = re.search(r'\d{4}', self.overview) + if match: + self.year = match.group() # 导演和演员 if not self.directors: self.directors = info.get("directors") or []