fix api
This commit is contained in:
@ -359,19 +359,21 @@ class TheMovieDbModule(_ModuleBase):
|
||||
"""
|
||||
return self.tmdb.get_tv_recommend(tmdbid=tmdbid)
|
||||
|
||||
def movie_credits(self, tmdbid: int) -> List[dict]:
|
||||
def movie_credits(self, tmdbid: int, page: int = 1) -> List[dict]:
|
||||
"""
|
||||
根据TMDBID查询电影演职员表
|
||||
:param tmdbid: TMDBID
|
||||
:param page: 页码
|
||||
"""
|
||||
return self.tmdb.get_movie_credits(tmdbid=tmdbid)
|
||||
return self.tmdb.get_movie_credits(tmdbid=tmdbid, page=page)
|
||||
|
||||
def tv_credits(self, tmdbid: int) -> List[dict]:
|
||||
def tv_credits(self, tmdbid: int, page: int = 1) -> List[dict]:
|
||||
"""
|
||||
根据TMDBID查询电视剧演职员表
|
||||
:param tmdbid: TMDBID
|
||||
:param page: 页码
|
||||
"""
|
||||
return self.tmdb.get_tv_credits(tmdbid=tmdbid)
|
||||
return self.tmdb.get_tv_credits(tmdbid=tmdbid, page=page)
|
||||
|
||||
def person_detail(self, person_id: int) -> dict:
|
||||
"""
|
||||
|
@ -1094,30 +1094,36 @@ class TmdbHelper:
|
||||
print(str(e))
|
||||
return []
|
||||
|
||||
def get_movie_credits(self, tmdbid: int) -> List[dict]:
|
||||
def get_movie_credits(self, tmdbid: int, page: int = 1, count: int = 24) -> List[dict]:
|
||||
"""
|
||||
获取电影的演职员列表
|
||||
"""
|
||||
if not self.movie:
|
||||
return []
|
||||
try:
|
||||
logger.info(f"正在获取电影演职员:{tmdbid}...")
|
||||
logger.info(f"正在获取电影演职人员:{tmdbid}...")
|
||||
info = self.movie.credits(movie_id=tmdbid) or {}
|
||||
return info.get('cast') or []
|
||||
cast = info.get('cast') or []
|
||||
if cast:
|
||||
return [c.to_dict() for c in cast][(page - 1) * count: page * count]
|
||||
return []
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return []
|
||||
|
||||
def get_tv_credits(self, tmdbid: int) -> List[dict]:
|
||||
def get_tv_credits(self, tmdbid: int, page: int = 1, count: int = 24) -> List[dict]:
|
||||
"""
|
||||
获取电视剧的演职员列表
|
||||
"""
|
||||
if not self.tv:
|
||||
return []
|
||||
try:
|
||||
logger.info(f"正在获取电视剧演职员:{tmdbid}...")
|
||||
logger.info(f"正在获取电视剧演职人员:{tmdbid}...")
|
||||
info = self.tv.credits(tv_id=tmdbid) or {}
|
||||
return info.get('cast') or []
|
||||
cast = info.get('cast') or []
|
||||
if cast:
|
||||
return [c.to_dict() for c in cast][(page - 1) * count: page * count]
|
||||
return []
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return []
|
||||
|
@ -29,7 +29,7 @@ class TMDb(object):
|
||||
def __init__(self, obj_cached=True, session=None):
|
||||
if self.__class__._session is None or session is not None:
|
||||
self.__class__._session = requests.Session() if session is None else session
|
||||
self._base = "https://api.themoviedb.org/3"
|
||||
self.domain = "api.themoviedb.org"
|
||||
self._remaining = 40
|
||||
self._reset = None
|
||||
self.obj_cached = obj_cached
|
||||
@ -143,8 +143,8 @@ class TMDb(object):
|
||||
if self.api_key is None or self.api_key == "":
|
||||
raise TMDbException("No API key found.")
|
||||
|
||||
url = "%s%s?api_key=%s&%s&language=%s" % (
|
||||
self._base,
|
||||
url = "https://%s/3%s?api_key=%s&%s&language=%s" % (
|
||||
self.domain,
|
||||
action,
|
||||
self.api_key,
|
||||
params,
|
||||
|
Reference in New Issue
Block a user