feat 完善豆瓣详情API
This commit is contained in:
parent
c336e62885
commit
b6ac5f0f84
@ -131,5 +131,6 @@ def media_info(mediaid: str, type_name: str,
|
|||||||
return schemas.MediaInfo()
|
return schemas.MediaInfo()
|
||||||
mediainfo = MediaChain().recognize_media(tmdbid=tmdbid, doubanid=doubanid, mtype=mtype)
|
mediainfo = MediaChain().recognize_media(tmdbid=tmdbid, doubanid=doubanid, mtype=mtype)
|
||||||
if mediainfo:
|
if mediainfo:
|
||||||
|
MediaChain().obtain_images(mediainfo)
|
||||||
return mediainfo.to_dict()
|
return mediainfo.to_dict()
|
||||||
return schemas.MediaInfo()
|
return schemas.MediaInfo()
|
||||||
|
@ -658,6 +658,35 @@ class DoubanModule(_ModuleBase):
|
|||||||
logger.error(f"刮削文件 {file} 失败,原因:{str(e)}")
|
logger.error(f"刮削文件 {file} 失败,原因:{str(e)}")
|
||||||
logger.info(f"{path} 刮削完成")
|
logger.info(f"{path} 刮削完成")
|
||||||
|
|
||||||
|
def obtain_images(self, mediainfo: MediaInfo) -> Optional[MediaInfo]:
|
||||||
|
"""
|
||||||
|
补充抓取媒体信息图片
|
||||||
|
:param mediainfo: 识别的媒体信息
|
||||||
|
:return: 更新后的媒体信息
|
||||||
|
"""
|
||||||
|
if settings.RECOGNIZE_SOURCE != "douban":
|
||||||
|
return None
|
||||||
|
if not mediainfo.douban_id:
|
||||||
|
return None
|
||||||
|
if mediainfo.backdrop_path:
|
||||||
|
# 没有图片缺失
|
||||||
|
return mediainfo
|
||||||
|
# 调用图片接口
|
||||||
|
if not mediainfo.backdrop_path:
|
||||||
|
if mediainfo.type == MediaType.MOVIE:
|
||||||
|
info = self.doubanapi.movie_photos(mediainfo.douban_id)
|
||||||
|
else:
|
||||||
|
info = self.doubanapi.tv_photos(mediainfo.douban_id)
|
||||||
|
if not info:
|
||||||
|
return mediainfo
|
||||||
|
images = info.get("photos")
|
||||||
|
# 背景图
|
||||||
|
if images:
|
||||||
|
backdrop = images[0].get("image", {}).get("large") or {}
|
||||||
|
if backdrop:
|
||||||
|
mediainfo.backdrop_path = backdrop.get("url")
|
||||||
|
return mediainfo
|
||||||
|
|
||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
"""
|
"""
|
||||||
清除缓存
|
清除缓存
|
||||||
|
@ -430,27 +430,51 @@ class DoubanApi(metaclass=Singleton):
|
|||||||
def movie_recommendations(self, subject_id: str, start: int = 0, count: int = 20,
|
def movie_recommendations(self, subject_id: str, start: int = 0, count: int = 20,
|
||||||
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
"""
|
"""
|
||||||
电影推荐
|
电影推荐
|
||||||
:param subject_id: 电影id
|
:param subject_id: 电影id
|
||||||
:param start: 开始
|
:param start: 开始
|
||||||
:param count: 数量
|
:param count: 数量
|
||||||
:param ts: 时间戳
|
:param ts: 时间戳
|
||||||
"""
|
"""
|
||||||
return self.__invoke(self._urls["movie_recommendations"] % subject_id,
|
return self.__invoke(self._urls["movie_recommendations"] % subject_id,
|
||||||
start=start, count=count, _ts=ts)
|
start=start, count=count, _ts=ts)
|
||||||
|
|
||||||
def tv_recommendations(self, subject_id: str, start: int = 0, count: int = 20,
|
def tv_recommendations(self, subject_id: str, start: int = 0, count: int = 20,
|
||||||
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
"""
|
"""
|
||||||
电视剧推荐
|
电视剧推荐
|
||||||
:param subject_id: 电视剧id
|
:param subject_id: 电视剧id
|
||||||
:param start: 开始
|
:param start: 开始
|
||||||
:param count: 数量
|
:param count: 数量
|
||||||
:param ts: 时间戳
|
:param ts: 时间戳
|
||||||
"""
|
"""
|
||||||
return self.__invoke(self._urls["tv_recommendations"] % subject_id,
|
return self.__invoke(self._urls["tv_recommendations"] % subject_id,
|
||||||
start=start, count=count, _ts=ts)
|
start=start, count=count, _ts=ts)
|
||||||
|
|
||||||
|
def movie_photos(self, subject_id: str, start: int = 0, count: int = 20,
|
||||||
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
|
"""
|
||||||
|
电影剧照
|
||||||
|
:param subject_id: 电影id
|
||||||
|
:param start: 开始
|
||||||
|
:param count: 数量
|
||||||
|
:param ts: 时间戳
|
||||||
|
"""
|
||||||
|
return self.__invoke(self._urls["movie_photos"] % subject_id,
|
||||||
|
start=start, count=count, _ts=ts)
|
||||||
|
|
||||||
|
def tv_photos(self, subject_id: str, start: int = 0, count: int = 20,
|
||||||
|
ts=datetime.strftime(datetime.now(), '%Y%m%d')):
|
||||||
|
"""
|
||||||
|
电视剧剧照
|
||||||
|
:param subject_id: 电视剧id
|
||||||
|
:param start: 开始
|
||||||
|
:param count: 数量
|
||||||
|
:param ts: 时间戳
|
||||||
|
"""
|
||||||
|
return self.__invoke(self._urls["tv_photos"] % subject_id,
|
||||||
|
start=start, count=count, _ts=ts)
|
||||||
|
|
||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
"""
|
"""
|
||||||
清空LRU缓存
|
清空LRU缓存
|
||||||
|
@ -312,6 +312,8 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
:param mediainfo: 识别的媒体信息
|
:param mediainfo: 识别的媒体信息
|
||||||
:return: 更新后的媒体信息
|
:return: 更新后的媒体信息
|
||||||
"""
|
"""
|
||||||
|
if settings.RECOGNIZE_SOURCE != "themoviedb":
|
||||||
|
return None
|
||||||
if not mediainfo.tmdb_id:
|
if not mediainfo.tmdb_id:
|
||||||
return mediainfo
|
return mediainfo
|
||||||
if mediainfo.logo_path \
|
if mediainfo.logo_path \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user