From 85a581f0cd7c3c9d8f2be6926eab2567e70708e8 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 30 Aug 2023 08:28:37 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=8E=A8=E8=8D=90=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E7=83=AD=E6=98=A0=20fix=20=E8=B1=86=E7=93=A3?= =?UTF-8?q?=E6=90=9C=E7=B4=A2API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/douban.py | 15 +++++++++++++++ app/api/endpoints/search.py | 2 +- app/core/context.py | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/api/endpoints/douban.py b/app/api/endpoints/douban.py index a1e7c6bf..6766e6db 100644 --- a/app/api/endpoints/douban.py +++ b/app/api/endpoints/douban.py @@ -45,6 +45,21 @@ def recognize_doubanid(doubanid: str, return schemas.Context() +@router.get("/showing", summary="豆瓣正在热映", response_model=List[schemas.MediaInfo]) +def movie_showing(page: int = 1, + count: int = 30, + db: Session = Depends(get_db), + _: schemas.TokenPayload = Depends(verify_token)) -> Any: + """ + 浏览豆瓣正在热映 + """ + movies = DoubanChain(db).movie_showing(page=page, count=count) + if not movies: + return [] + medias = [MediaInfo(douban_info=movie) for movie in movies] + return [media.to_dict() for media in medias] + + @router.get("/movies", summary="豆瓣电影", response_model=List[schemas.MediaInfo]) def douban_movies(sort: str = "R", tags: str = "", diff --git a/app/api/endpoints/search.py b/app/api/endpoints/search.py index cb89b76b..3a2ae68e 100644 --- a/app/api/endpoints/search.py +++ b/app/api/endpoints/search.py @@ -42,7 +42,7 @@ def search_by_tmdbid(mediaid: str, # 识别豆瓣信息 context = DoubanChain(db).recognize_by_doubanid(doubanid) if not context or not context.media_info or not context.media_info.tmdb_id: - raise HTTPException(status_code=404, detail="无法识别TMDB媒体信息!") + return [] torrents = SearchChain(db).search_by_tmdbid(tmdbid=context.media_info.tmdb_id, mtype=context.media_info.type, area=area) diff --git a/app/core/context.py b/app/core/context.py index b8537c15..702848a6 100644 --- a/app/core/context.py +++ b/app/core/context.py @@ -446,6 +446,8 @@ class MediaInfo: self.poster_path = info.get("pic", {}).get("large") if not self.poster_path and info.get("cover_url"): self.poster_path = info.get("cover_url") + if not self.poster_path and info.get("cover"): + self.poster_path = info.get("cover").get("url") # 简介 if not self.overview: self.overview = info.get("intro") or info.get("card_subtitle") or ""