fix douban api
This commit is contained in:
@ -56,33 +56,35 @@ async def douban_info(doubanid: str, _: schemas.TokenPayload = Depends(verify_to
|
||||
@router.get("/movies", summary="豆瓣电影", response_model=List[schemas.MediaInfo])
|
||||
async def douban_movies(sort: str = "R",
|
||||
tags: str = "",
|
||||
start: int = 0,
|
||||
page: int = 1,
|
||||
count: int = 30,
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
浏览豆瓣电影信息
|
||||
"""
|
||||
movies = DoubanChain().douban_discover(mtype=MediaType.MOVIE,
|
||||
sort=sort, tags=tags, start=start, count=count)
|
||||
sort=sort, tags=tags, page=page, count=count)
|
||||
if not movies:
|
||||
return []
|
||||
return [MediaInfo(douban_info=movie).to_dict() for movie in movies]
|
||||
medias = [MediaInfo(douban_info=movie) for movie in movies]
|
||||
return [media.to_dict() for media in medias if media.poster_path]
|
||||
|
||||
|
||||
@router.get("/tvs", summary="豆瓣剧集", response_model=List[schemas.MediaInfo])
|
||||
async def douban_tvs(sort: str = "R",
|
||||
tags: str = "",
|
||||
start: int = 0,
|
||||
page: int = 1,
|
||||
count: int = 30,
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
浏览豆瓣剧集信息
|
||||
"""
|
||||
tvs = DoubanChain().douban_discover(mtype=MediaType.TV,
|
||||
sort=sort, tags=tags, start=start, count=count)
|
||||
sort=sort, tags=tags, page=page, count=count)
|
||||
if not tvs:
|
||||
return []
|
||||
return [MediaInfo(douban_info=tv).to_dict() for tv in tvs]
|
||||
medias = [MediaInfo(douban_info=tv).to_dict() for tv in tvs]
|
||||
return [media.to_dict() for media in medias if media.poster_path]
|
||||
|
||||
|
||||
@router.get("/movie_top250", summary="豆瓣电影TOP250", response_model=List[schemas.MediaInfo])
|
||||
|
@ -78,18 +78,18 @@ class DoubanChain(ChainBase):
|
||||
return self.run_module("tv_weekly_global", page=page, count=count)
|
||||
|
||||
def douban_discover(self, mtype: MediaType, sort: str, tags: str,
|
||||
start: int = 0, count: int = 30) -> Optional[List[dict]]:
|
||||
page: int = 0, count: int = 30) -> Optional[List[dict]]:
|
||||
"""
|
||||
发现豆瓣电影、剧集
|
||||
:param mtype: 媒体类型
|
||||
:param sort: 排序方式
|
||||
:param tags: 标签
|
||||
:param start: 起始位置
|
||||
:param page: 页码
|
||||
:param count: 数量
|
||||
:return: 媒体信息列表
|
||||
"""
|
||||
return self.run_module("douban_discover", mtype=mtype, sort=sort, tags=tags,
|
||||
start=start, count=count)
|
||||
page=page, count=count)
|
||||
|
||||
def remote_sync(self, userid: Union[int, str]):
|
||||
"""
|
||||
|
@ -53,22 +53,22 @@ class DoubanModule(_ModuleBase):
|
||||
return douban_info
|
||||
|
||||
def douban_discover(self, mtype: MediaType, sort: str, tags: str,
|
||||
start: int = 0, count: int = 30) -> Optional[List[dict]]:
|
||||
page: int = 1, count: int = 30) -> Optional[List[dict]]:
|
||||
"""
|
||||
发现豆瓣电影、剧集
|
||||
:param mtype: 媒体类型
|
||||
:param sort: 排序方式
|
||||
:param tags: 标签
|
||||
:param start: 起始位置
|
||||
:param page: 页码
|
||||
:param count: 数量
|
||||
:return: 媒体信息列表
|
||||
"""
|
||||
logger.info(f"开始发现豆瓣 {mtype.value} ...")
|
||||
if mtype == MediaType.MOVIE:
|
||||
infos = self.doubanapi.movie_recommend(start=start, count=count,
|
||||
infos = self.doubanapi.movie_recommend(start=(page - 1) * count, count=count,
|
||||
sort=sort, tags=tags)
|
||||
else:
|
||||
infos = self.doubanapi.tv_recommend(start=start, count=count,
|
||||
infos = self.doubanapi.tv_recommend(start=(page - 1) * count, count=count,
|
||||
sort=sort, tags=tags)
|
||||
if not infos:
|
||||
return []
|
||||
|
Reference in New Issue
Block a user