fix themoviedb api

This commit is contained in:
jxxghp
2025-07-31 08:34:47 +08:00
parent b6ff9f7196
commit 8b708e8939
15 changed files with 2089 additions and 1 deletions

View File

@@ -1426,7 +1426,228 @@ class TmdbApi:
"""
self.tmdb.cache_clear()
# 异步方法
# 私有异步方法
async def __async_search_movie_by_name(self, name: str, year: str) -> Optional[dict]:
"""
根据名称查询电影TMDB匹配异步版本
:param name: 识别的文件名或种子名
:param year: 电影上映日期
:return: 匹配的媒体信息
"""
try:
if year:
movies = await self.search.async_movies(term=name, year=year)
else:
movies = await self.search.async_movies(term=name)
except TMDbException as err:
logger.error(f"连接TMDB出错{str(err)}")
return None
except Exception as e:
logger.error(f"连接TMDB出错{str(e)} - {traceback.format_exc()}")
return None
logger.debug(f"API返回{str(self.search.total_results)}")
if (movies is None) or (len(movies) == 0):
logger.debug(f"{name} 未找到相关电影信息!")
return {}
else:
# 按年份降序排列
movies = sorted(
movies,
key=lambda x: x.get('release_date') or '0000-00-00',
reverse=True
)
for movie in movies:
# 年份
movie_year = movie.get('release_date')[0:4] if movie.get('release_date') else None
if year and movie_year != year:
# 年份不匹配
continue
# 匹配标题、原标题
if self.__compare_names(name, movie.get('title')):
return movie
if self.__compare_names(name, movie.get('original_title')):
return movie
# 匹配别名、译名
if not movie.get("names"):
movie = await self.async_get_info(mtype=MediaType.MOVIE, tmdbid=movie.get("id"))
if movie and self.__compare_names(name, movie.get("names")):
return movie
return {}
async def __async_search_tv_by_name(self, name: str, year: str) -> Optional[dict]:
"""
根据名称查询电视剧TMDB匹配异步版本
:param name: 识别的文件名或者种子名
:param year: 电视剧的首播年份
:return: 匹配的媒体信息
"""
try:
if year:
tvs = await self.search.async_tv_shows(term=name, release_year=year)
else:
tvs = await self.search.async_tv_shows(term=name)
except TMDbException as err:
logger.error(f"连接TMDB出错{str(err)}")
return None
except Exception as e:
logger.error(f"连接TMDB出错{str(e)} - {traceback.format_exc()}")
return None
logger.debug(f"API返回{str(self.search.total_results)}")
if (tvs is None) or (len(tvs) == 0):
logger.debug(f"{name} 未找到相关剧集信息!")
return {}
else:
# 按年份降序排列
tvs = sorted(
tvs,
key=lambda x: x.get('first_air_date') or '0000-00-00',
reverse=True
)
for tv in tvs:
tv_year = tv.get('first_air_date')[0:4] if tv.get('first_air_date') else None
if year and tv_year != year:
# 年份不匹配
continue
# 匹配标题、原标题
if self.__compare_names(name, tv.get('name')):
return tv
if self.__compare_names(name, tv.get('original_name')):
return tv
# 匹配别名、译名
if not tv.get("names"):
tv = await self.async_get_info(mtype=MediaType.TV, tmdbid=tv.get("id"))
if tv and self.__compare_names(name, tv.get("names")):
return tv
return {}
async def __async_search_tv_by_season(self, name: str, season_year: str, season_number: int,
group_seasons: Optional[List[dict]] = None) -> Optional[dict]:
"""
根据电视剧的名称和季的年份及序号匹配TMDB异步版本
:param name: 识别的文件名或者种子名
:param season_year: 季的年份
:param season_number: 季序号
:param group_seasons: 集数组信息
:return: 匹配的媒体信息
"""
def __season_match(tv_info: dict, _season_year: str) -> bool:
if not tv_info:
return False
try:
if group_seasons:
for group_season in group_seasons:
season = group_season.get('order')
if season != season_number:
continue
episodes = group_season.get('episodes')
if not episodes:
continue
first_date = episodes[0].get("air_date")
if re.match(r"^\d{4}-\d{2}-\d{2}$", first_date):
if str(_season_year) == str(first_date).split("-")[0]:
return True
else:
seasons = self.__get_tv_seasons(tv_info)
for season, season_info in seasons.items():
if season_info.get("air_date"):
if season_info.get("air_date")[0:4] == str(_season_year) \
and season == int(season_number):
return True
except Exception as e1:
logger.error(f"连接TMDB出错{e1}")
print(traceback.format_exc())
return False
return False
try:
tvs = await self.search.async_tv_shows(term=name)
except TMDbException as err:
logger.error(f"连接TMDB出错{str(err)}")
return None
except Exception as e:
logger.error(f"连接TMDB出错{str(e)}")
print(traceback.format_exc())
return None
if (tvs is None) or (len(tvs) == 0):
logger.debug("%s 未找到季%s相关信息!" % (name, season_number))
return {}
else:
# 按年份降序排列
tvs = sorted(
tvs,
key=lambda x: x.get('first_air_date') or '0000-00-00',
reverse=True
)
for tv in tvs:
# 年份
tv_year = tv.get('first_air_date')[0:4] if tv.get('first_air_date') else None
if (self.__compare_names(name, tv.get('name'))
or self.__compare_names(name, tv.get('original_name'))) \
and (tv_year == str(season_year)):
return tv
# 匹配别名、译名
if not tv.get("names"):
tv = await self.async_get_info(mtype=MediaType.TV, tmdbid=tv.get("id"))
if not tv or not self.__compare_names(name, tv.get("names")):
continue
if __season_match(tv_info=tv, _season_year=season_year):
return tv
return {}
async def __async_get_movie_detail(self,
tmdbid: int,
append_to_response: Optional[str] = "images,"
"credits,"
"alternative_titles,"
"translations,"
"release_dates,"
"external_ids") -> Optional[dict]:
"""
获取电影的详情(异步版本)
:param tmdbid: TMDB ID
:return: TMDB信息
"""
if not self.movie:
return {}
try:
logger.debug("正在查询TMDB电影%s ..." % tmdbid)
tmdbinfo = await self.movie.async_details(tmdbid, append_to_response)
if tmdbinfo:
logger.debug(f"{tmdbid} 查询结果:{tmdbinfo.get('title')}")
return tmdbinfo or {}
except Exception as e:
logger.error(str(e))
return None
async def __async_get_tv_detail(self,
tmdbid: int,
append_to_response: Optional[str] = "images,"
"credits,"
"alternative_titles,"
"translations,"
"content_ratings,"
"external_ids,"
"episode_groups") -> Optional[dict]:
"""
获取电视剧的详情(异步版本)
:param tmdbid: TMDB ID
:return: TMDB信息
"""
if not self.tv:
return {}
try:
logger.debug("正在查询TMDB电视剧%s ..." % tmdbid)
tmdbinfo = await self.tv.async_details(tv_id=tmdbid, append_to_response=append_to_response)
if tmdbinfo:
logger.debug(f"{tmdbid} 查询结果:{tmdbinfo.get('name')}")
return tmdbinfo or {}
except Exception as e:
logger.error(str(e))
return None
# 公共异步方法
async def async_search_multiis(self, title: str) -> List[dict]:
"""
同时查询模糊匹配的电影、电视剧TMDB信息异步版本
@@ -1505,6 +1726,452 @@ class TmdbApi:
logger.error(f"获取电视剧发现失败:{str(e)}")
return []
async def async_search_persons(self, name: str) -> List[dict]:
"""
查询模糊匹配的所有人物TMDB信息异步版本
"""
if not name:
return []
return await self.search.async_people(term=name) or []
async def async_search_collections(self, name: str) -> List[dict]:
"""
查询模糊匹配的所有合集TMDB信息异步版本
"""
if not name:
return []
collections = await self.search.async_collections(term=name) or []
for collection in collections:
collection['media_type'] = MediaType.COLLECTION
collection['collection_id'] = collection.get("id")
return collections
async def async_get_collection(self, collection_id: int) -> List[dict]:
"""
根据合集ID查询合集详情异步版本
"""
if not collection_id:
return []
try:
return await self.collection.async_details(collection_id=collection_id)
except TMDbException as err:
logger.error(f"连接TMDB出错{str(err)}")
except Exception as e:
logger.error(f"连接TMDB出错{str(e)}")
return []
async def async_match(self, name: str,
mtype: MediaType,
year: Optional[str] = None,
season_year: Optional[str] = None,
season_number: Optional[int] = None,
group_seasons: Optional[List[dict]] = None) -> Optional[dict]:
"""
搜索tmdb中的媒体信息匹配返回一条尽可能正确的信息异步版本
:param name: 检索的名称
:param mtype: 类型:电影、电视剧
:param year: 年份,如要是季集需要是首播年份(first_air_date)
:param season_year: 当前季集年份
:param season_number: 季集,整数
:param group_seasons: 集数组信息
:return: TMDB的INFO同时会将mtype赋值到media_type中
"""
if not self.search:
return None
if not name:
return None
# TMDB搜索
info = {}
if mtype != MediaType.TV:
year_range = [year]
if year:
year_range.append(str(int(year) + 1))
year_range.append(str(int(year) - 1))
for year in year_range:
logger.debug(
f"正在识别{mtype.value}{name}, 年份={year} ...")
info = await self.__async_search_movie_by_name(name, year)
if info:
info['media_type'] = MediaType.MOVIE
break
else:
# 有当前季和当前季集年份,使用精确匹配
if season_year and season_number:
logger.debug(
f"正在识别{mtype.value}{name}, 季集={season_number}, 季集年份={season_year} ...")
info = await self.__async_search_tv_by_season(name,
season_year,
season_number,
group_seasons)
if not info:
year_range = [year]
if year:
year_range.append(str(int(year) + 1))
year_range.append(str(int(year) - 1))
for year in year_range:
logger.debug(
f"正在识别{mtype.value}{name}, 年份={year} ...")
info = await self.__async_search_tv_by_name(name, year)
if info:
break
if info:
info['media_type'] = MediaType.TV
# 返回
return info
async def async_match_multi(self, name: str) -> Optional[dict]:
"""
根据名称同时查询电影和电视剧,没有类型也没有年份时使用(异步版本)
:param name: 识别的文件名或种子名
:return: 匹配的媒体信息
"""
try:
multis = await self.search.async_multi(term=name) or []
except TMDbException as err:
logger.error(f"连接TMDB出错{str(err)}")
return None
except Exception as e:
logger.error(f"连接TMDB出错{str(e)}")
print(traceback.format_exc())
return None
logger.debug(f"API返回{str(self.search.total_results)}")
# 返回结果
ret_info = {}
if (multis is None) or (len(multis) == 0):
logger.debug(f"{name} 未找到相关媒体息!")
return {}
else:
# 按年份降序排列,电影在前面
multis = sorted(
multis,
key=lambda x: ("1"
if x.get("media_type") == "movie"
else "0") + (x.get('release_date')
or x.get('first_air_date')
or '0000-00-00'),
reverse=True
)
for multi in multis:
if multi.get("media_type") == "movie":
if self.__compare_names(name, multi.get('title')) \
or self.__compare_names(name, multi.get('original_title')):
ret_info = multi
break
# 匹配别名、译名
if not multi.get("names"):
multi = await self.async_get_info(mtype=MediaType.MOVIE, tmdbid=multi.get("id"))
if multi and self.__compare_names(name, multi.get("names")):
ret_info = multi
break
elif multi.get("media_type") == "tv":
if self.__compare_names(name, multi.get('name')) \
or self.__compare_names(name, multi.get('original_name')):
ret_info = multi
break
# 匹配别名、译名
if not multi.get("names"):
multi = await self.async_get_info(mtype=MediaType.TV, tmdbid=multi.get("id"))
if multi and self.__compare_names(name, multi.get("names")):
ret_info = multi
break
# 类型变更
if (ret_info
and not isinstance(ret_info.get("media_type"), MediaType)):
ret_info['media_type'] = MediaType.MOVIE if ret_info.get("media_type") == "movie" else MediaType.TV
return ret_info
async def async_get_info(self,
mtype: MediaType,
tmdbid: int) -> dict:
"""
给定TMDB号查询一条媒体信息异步版本
:param mtype: 类型:电影、电视剧,为空时都查(此时用不上年份)
:param tmdbid: TMDB的ID有tmdbid时优先使用tmdbid否则使用年份和标题
"""
def __get_genre_ids(genres: list) -> list:
"""
从TMDB详情中获取genre_id列表
"""
if not genres:
return []
genre_ids = []
for genre in genres:
genre_ids.append(genre.get('id'))
return genre_ids
# 查询TMDB详情
if mtype == MediaType.MOVIE:
tmdb_info = await self.__async_get_movie_detail(tmdbid)
if tmdb_info:
tmdb_info['media_type'] = MediaType.MOVIE
elif mtype == MediaType.TV:
tmdb_info = await self.__async_get_tv_detail(tmdbid)
if tmdb_info:
tmdb_info['media_type'] = MediaType.TV
else:
tmdb_info_tv = await self.__async_get_tv_detail(tmdbid)
tmdb_info_movie = await self.__async_get_movie_detail(tmdbid)
if tmdb_info_tv and tmdb_info_movie:
tmdb_info = None
logger.warn(f"无法判断tmdb_id:{tmdbid} 是电影还是电视剧")
elif tmdb_info_tv:
tmdb_info = tmdb_info_tv
tmdb_info['media_type'] = MediaType.TV
elif tmdb_info_movie:
tmdb_info = tmdb_info_movie
tmdb_info['media_type'] = MediaType.MOVIE
else:
tmdb_info = None
logger.warn(f"tmdb_id:{tmdbid} 未查询到媒体信息")
if tmdb_info:
# 转换genreid
tmdb_info['genre_ids'] = __get_genre_ids(tmdb_info.get('genres'))
# 别名和译名
tmdb_info['names'] = self.__get_names(tmdb_info)
# 内容分级
tmdb_info['content_rating'] = self.__get_content_rating(tmdb_info)
# 转换多语种标题
self.__update_tmdbinfo_extra_title(tmdb_info)
# 转换中文标题
if settings.TMDB_LOCALE == "zh":
self.__update_tmdbinfo_cn_title(tmdb_info)
return tmdb_info
async def async_get_tv_season_detail(self, tmdbid: int, season: int):
"""
获取电视剧季的详情(异步版本)
:param tmdbid: TMDB ID
:param season: 季,数字
:return: TMDB信息
"""
if not self.season_obj:
return {}
try:
logger.debug("正在查询TMDB电视剧%s,季:%s ..." % (tmdbid, season))
tmdbinfo = await self.season_obj.async_details(tv_id=tmdbid, season_num=season)
return tmdbinfo or {}
except Exception as e:
logger.error(str(e))
return {}
async def async_get_tv_episode_detail(self, tmdbid: int, season: int, episode: int) -> dict:
"""
获取电视剧集的详情(异步版本)
:param tmdbid: TMDB ID
:param season: 季,数字
:param episode: 集,数字
"""
if not self.episode_obj:
return {}
try:
logger.debug("正在查询TMDB集详情%s,季:%s,集:%s ..." % (tmdbid, season, episode))
tmdbinfo = await self.episode_obj.async_details(tv_id=tmdbid, season_num=season, episode_num=episode)
return tmdbinfo or {}
except Exception as e:
logger.error(str(e))
return {}
async def async_discover_trending(self, page: Optional[int] = 1) -> List[dict]:
"""
流行趋势(异步版本)
"""
if not self.trending:
return []
try:
logger.debug(f"正在获取流行趋势page={page} ...")
return await self.trending.async_all_week(page=page)
except Exception as e:
logger.error(str(e))
return []
async def async_get_movie_images(self, tmdbid: int) -> dict:
"""
获取电影的图片(异步版本)
"""
if not self.movie:
return {}
try:
logger.debug(f"正在获取电影图片:{tmdbid}...")
return await self.movie.async_images(movie_id=tmdbid) or {}
except Exception as e:
logger.error(str(e))
return {}
async def async_get_tv_images(self, tmdbid: int) -> dict:
"""
获取电视剧的图片(异步版本)
"""
if not self.tv:
return {}
try:
logger.debug(f"正在获取电视剧图片:{tmdbid}...")
return await self.tv.async_images(tv_id=tmdbid) or {}
except Exception as e:
logger.error(str(e))
return {}
async def async_get_movie_similar(self, tmdbid: int) -> List[dict]:
"""
获取电影的相似电影(异步版本)
"""
if not self.movie:
return []
try:
logger.debug(f"正在获取相似电影:{tmdbid}...")
return await self.movie.async_similar(movie_id=tmdbid) or []
except Exception as e:
logger.error(str(e))
return []
async def async_get_tv_similar(self, tmdbid: int) -> List[dict]:
"""
获取电视剧的相似电视剧(异步版本)
"""
if not self.tv:
return []
try:
logger.debug(f"正在获取相似电视剧:{tmdbid}...")
return await self.tv.async_similar(tv_id=tmdbid) or []
except Exception as e:
logger.error(str(e))
return []
async def async_get_movie_recommend(self, tmdbid: int) -> List[dict]:
"""
获取电影的推荐电影(异步版本)
"""
if not self.movie:
return []
try:
logger.debug(f"正在获取推荐电影:{tmdbid}...")
return await self.movie.async_recommendations(movie_id=tmdbid) or []
except Exception as e:
logger.error(str(e))
return []
async def async_get_tv_recommend(self, tmdbid: int) -> List[dict]:
"""
获取电视剧的推荐电视剧(异步版本)
"""
if not self.tv:
return []
try:
logger.debug(f"正在获取推荐电视剧:{tmdbid}...")
return await self.tv.async_recommendations(tv_id=tmdbid) or []
except Exception as e:
logger.error(str(e))
return []
async def async_get_movie_credits(self, tmdbid: int, page: Optional[int] = 1, count: Optional[int] = 24) -> List[
dict]:
"""
获取电影的演职员列表(异步版本)
"""
if not self.movie:
return []
try:
logger.debug(f"正在获取电影演职人员:{tmdbid}...")
info = await self.movie.async_credits(movie_id=tmdbid) or {}
cast = info.get('cast') or []
if cast:
return cast[(page - 1) * count: page * count]
return []
except Exception as e:
logger.error(str(e))
return []
async def async_get_tv_credits(self, tmdbid: int, page: Optional[int] = 1, count: Optional[int] = 24) -> List[dict]:
"""
获取电视剧的演职员列表(异步版本)
"""
if not self.tv:
return []
try:
logger.debug(f"正在获取电视剧演职人员:{tmdbid}...")
info = await self.tv.async_credits(tv_id=tmdbid) or {}
cast = info.get('cast') or []
if cast:
return cast[(page - 1) * count: page * count]
return []
except Exception as e:
logger.error(str(e))
return []
async def async_get_tv_group_seasons(self, group_id: str) -> List[dict]:
"""
获取电视剧剧集组季集列表(异步版本)
"""
if not self.tv:
return []
try:
logger.debug(f"正在获取剧集组:{group_id}...")
group_seasons = await self.tv.async_group_episodes(group_id) or []
return [
{
**group_season,
"episodes": [
{**ep, "episode_number": idx}
# 剧集组中每个季的episode_number从1开始
for idx, ep in enumerate(group_season.get("episodes", []), start=1)
]
}
for group_season in group_seasons
]
except Exception as e:
logger.error(str(e))
return []
async def async_get_tv_group_detail(self, group_id: str, season: int) -> dict:
"""
获取剧集组某个季的信息(异步版本)
"""
group_seasons = await self.async_get_tv_group_seasons(group_id)
if not group_seasons:
return {}
for group_season in group_seasons:
if group_season.get('order') == season:
return group_season
return {}
async def async_get_person_detail(self, person_id: int) -> dict:
"""
获取人物详情(异步版本)
"""
if not self.person:
return {}
try:
logger.debug(f"正在获取人物详情:{person_id}...")
return await self.person.async_details(person_id=person_id) or {}
except Exception as e:
logger.error(str(e))
return {}
async def async_get_person_credits(self, person_id: int, page: Optional[int] = 1, count: Optional[int] = 24) -> \
List[dict]:
"""
获取人物参演作品(异步版本)
"""
if not self.person:
return []
try:
logger.debug(f"正在获取人物参演作品:{person_id}...")
movies = await self.person.async_movie_credits(person_id=person_id) or {}
tvs = await self.person.async_tv_credits(person_id=person_id) or {}
cast = (movies.get('cast') or []) + (tvs.get('cast') or [])
if cast:
# 按年份降序排列
cast = sorted(cast, key=lambda x: x.get('release_date') or x.get('first_air_date') or '1900-01-01',
reverse=True)
return cast[(page - 1) * count: page * count]
return []
except Exception as e:
logger.error(str(e))
return []
def close(self):
"""
关闭连接

View File

@@ -31,3 +31,28 @@ class Collection(TMDb):
:return:
"""
return self._request_obj(self._urls["translations"] % collection_id, key="translations")
# 异步版本方法
async def async_details(self, collection_id):
"""
Get collection details by id.(异步版本)
:param collection_id: int
:return:
"""
return await self._async_request_obj(self._urls["details"] % collection_id, key="parts")
async def async_images(self, collection_id):
"""
Get the images for a collection by id.(异步版本)
:param collection_id: int
:return:
"""
return await self._async_request_obj(self._urls["images"] % collection_id)
async def async_translations(self, collection_id):
"""
Get the list translations for a collection by id.(异步版本)
:param collection_id: int
:return:
"""
return await self._async_request_obj(self._urls["translations"] % collection_id, key="translations")

View File

@@ -45,3 +45,41 @@ class Company(TMDb):
params="page=%s" % page,
key="results"
)
# 异步版本方法
async def async_details(self, company_id):
"""
Get a companies details by id.(异步版本)
:param company_id: int
:return:
"""
return await self._async_request_obj(self._urls["details"] % company_id)
async def async_alternative_names(self, company_id):
"""
Get the alternative names of a company.(异步版本)
:param company_id: int
:return:
"""
return await self._async_request_obj(self._urls["alternative_names"] % company_id, key="results")
async def async_images(self, company_id):
"""
Get the alternative names of a company.(异步版本)
:param company_id: int
:return:
"""
return await self._async_request_obj(self._urls["images"] % company_id, key="logos")
async def async_movies(self, company_id, page=1):
"""
Get the movies of a company by id.(异步版本)
:param company_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["movies"] % company_id,
params="page=%s" % page,
key="results"
)

View File

@@ -1,4 +1,5 @@
import warnings
from ..tmdb import TMDb
@@ -52,3 +53,40 @@ class Configuration(TMDb):
Get the list of timezones used throughout TMDb.
"""
return self._request_obj(self._urls["timezones"])
# 异步版本方法
async def async_api_configuration(self):
"""
Get the system wide configuration info.(异步版本)
"""
return await self._async_request_obj(self._urls["api_configuration"])
async def async_countries(self):
"""
Get the list of countries (ISO 3166-1 tags) used throughout TMDb.(异步版本)
"""
return await self._async_request_obj(self._urls["countries"])
async def async_jobs(self):
"""
Get a list of the jobs and departments we use on TMDb.(异步版本)
"""
return await self._async_request_obj(self._urls["jobs"])
async def async_languages(self):
"""
Get the list of languages (ISO 639-1 tags) used throughout TMDb.(异步版本)
"""
return await self._async_request_obj(self._urls["languages"])
async def async_primary_translations(self):
"""
Get a list of the officially supported translations on TMDb.(异步版本)
"""
return await self._async_request_obj(self._urls["primary_translations"])
async def async_timezones(self):
"""
Get the list of timezones used throughout TMDb.(异步版本)
"""
return await self._async_request_obj(self._urls["timezones"])

View File

@@ -155,3 +155,146 @@ class Episode(TMDb):
self._urls["videos"] % (tv_id, season_num, episode_num),
params=params
)
# 异步版本方法
async def async_details(self, tv_id, season_num, episode_num,
append_to_response="trailers,images,casts,translations"):
"""
Get the TV episode details by id.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:param append_to_response: str
:return:
"""
return await self._async_request_obj(
self._urls["details"] % (tv_id, season_num, episode_num),
params="append_to_response=%s" % append_to_response
)
async def async_account_states(self, tv_id, season_num, episode_num):
"""
Get your rating for a episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:return:
"""
return await self._async_request_obj(
self._urls["account_states"] % (tv_id, season_num, episode_num),
params="session_id=%s" % self.session_id
)
async def async_changes(self, episode_id, start_date=None, end_date=None, page=1):
"""
Get the changes for a TV episode. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date and end_date query parameters.(异步版本)
:param episode_id: int
:param start_date: str
:param end_date: str
:param page: int
:return:
"""
params = "page=%s" % page
if start_date:
params += "&start_date=%s" % start_date
if end_date:
params += "&end_date=%s" % end_date
return await self._async_request_obj(
self._urls["changes"] % episode_id,
params=params,
key="changes"
)
async def async_credits(self, tv_id, season_num, episode_num):
"""
Get the credits for TV season.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:return:
"""
return await self._async_request_obj(self._urls["credits"] % (tv_id, season_num, episode_num))
async def async_external_ids(self, tv_id, season_num, episode_num):
"""
Get the external ids for a TV episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:return:
"""
return await self._async_request_obj(self._urls["external_ids"] % (tv_id, season_num, episode_num))
async def async_images(self, tv_id, season_num, episode_num, include_image_language=None):
"""
Get the images that belong to a TV episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:param include_image_language: str
:return:
"""
return await self._async_request_obj(
self._urls["images"] % (tv_id, season_num, episode_num),
params="include_image_language=%s" % include_image_language if include_image_language else "",
key="stills"
)
async def async_translations(self, tv_id, season_num, episode_num):
"""
Get the translation data for an episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:return:
"""
return await self._async_request_obj(
self._urls["translations"] % (tv_id, season_num, episode_num),
key="translations"
)
async def async_rate_tv_episode(self, tv_id, season_num, episode_num, rating):
"""
Rate a TV episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:param rating: float
"""
await self._async_request_obj(
self._urls["rate_tv_episode"] % (tv_id, season_num, episode_num),
params="session_id=%s" % self.session_id,
method="POST",
json={"value": rating}
)
async def async_delete_rating(self, tv_id, season_num, episode_num):
"""
Remove your rating for a TV episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
"""
await self._async_request_obj(
self._urls["delete_rating"] % (tv_id, season_num, episode_num),
params="session_id=%s" % self.session_id,
method="DELETE"
)
async def async_videos(self, tv_id, season_num, episode_num, include_video_language=None):
"""
Get the videos that have been added to a TV episode.(异步版本)
:param tv_id: int
:param season_num: int
:param episode_num: int
:param include_video_language: str
:return:
"""
params = ""
if include_video_language:
params += "&include_video_language=%s" % include_video_language
return await self._async_request_obj(
self._urls["videos"] % (tv_id, season_num, episode_num),
params=params
)

View File

@@ -81,3 +81,80 @@ class Find(TMDb):
:return:
"""
return self.find(twitter_id, "twitter_id")
# 异步版本方法
async def async_find(self, external_id, external_source):
"""
The find method makes it easy to search for objects in our database by an external id. For example, an IMDB ID.(异步版本)
:param external_id: str
:param external_source str
:return:
"""
return await self._async_request_obj(
self._urls["find"] % external_id.replace("/", "%2F"),
params="external_source=" + external_source
)
async def async_find_by_imdb_id(self, imdb_id):
"""
The find method makes it easy to search for objects in our database by an IMDB ID.(异步版本)
:param imdb_id: str
:return:
"""
return await self.async_find(imdb_id, "imdb_id")
async def async_find_by_tvdb_id(self, tvdb_id):
"""
The find method makes it easy to search for objects in our database by a TVDB ID.(异步版本)
:param tvdb_id: int
:return:
"""
return await self.async_find(tvdb_id, "tvdb_id")
async def async_find_by_freebase_mid(self, freebase_mid):
"""
The find method makes it easy to search for objects in our database by a Freebase MID.(异步版本)
:param freebase_mid: str
:return:
"""
return await self.async_find(freebase_mid, "freebase_mid")
async def async_find_by_freebase_id(self, freebase_id):
"""
The find method makes it easy to search for objects in our database by a Freebase ID.(异步版本)
:param freebase_id: str
:return:
"""
return await self.async_find(freebase_id, "freebase_id")
async def async_find_by_tvrage_id(self, tvrage_id):
"""
The find method makes it easy to search for objects in our database by a TVRage ID.(异步版本)
:param tvrage_id: str
:return:
"""
return await self.async_find(tvrage_id, "tvrage_id")
async def async_find_by_facebook_id(self, facebook_id):
"""
The find method makes it easy to search for objects in our database by a Facebook ID.(异步版本)
:param facebook_id: str
:return:
"""
return await self.async_find(facebook_id, "facebook_id")
async def async_find_by_instagram_id(self, instagram_id):
"""
The find method makes it easy to search for objects in our database by a Instagram ID.(异步版本)
:param instagram_id: str
:return:
"""
return await self.async_find(instagram_id, "instagram_id")
async def async_find_by_twitter_id(self, twitter_id):
"""
The find method makes it easy to search for objects in our database by a Twitter ID.(异步版本)
:param twitter_id: str
:return:
"""
return await self.async_find(twitter_id, "twitter_id")

View File

@@ -20,3 +20,18 @@ class Genre(TMDb):
:return:
"""
return self._request_obj(self._urls["tv_list"], key="genres")
# 异步版本方法
async def async_movie_list(self):
"""
Get the list of official genres for movies.(异步版本)
:return:
"""
return await self._async_request_obj(self._urls["movie_list"], key="genres")
async def async_tv_list(self):
"""
Get the list of official genres for TV shows.(异步版本)
:return:
"""
return await self._async_request_obj(self._urls["tv_list"], key="genres")

View File

@@ -22,3 +22,20 @@ class Keyword(TMDb):
:return:
"""
return self._request_obj(self._urls["movies"] % keyword_id, key="results")
# 异步版本方法
async def async_details(self, keyword_id):
"""
Get a keywords details by id.(异步版本)
:param keyword_id: int
:return:
"""
return await self._async_request_obj(self._urls["details"] % keyword_id)
async def async_movies(self, keyword_id):
"""
Get the movies of a keyword by id.(异步版本)
:param keyword_id: int
:return:
"""
return await self._async_request_obj(self._urls["movies"] % keyword_id, key="results")

View File

@@ -94,3 +94,89 @@ class List(TMDb):
params="session_id=%s" % self.session_id,
method="DELETE"
)
# 异步版本方法
async def async_details(self, list_id):
"""
Get list details by id.(异步版本)
:param list_id: int
:return:
"""
return await self._async_request_obj(self._urls["details"] % list_id, key="items")
async def async_check_item_status(self, list_id, movie_id):
"""
You can use this method to check if a movie has already been added to the list.(异步版本)
:param list_id: int
:param movie_id: int
:return:
"""
result = await self._async_request_obj(self._urls["check_status"] % list_id, params="movie_id=%s" % movie_id)
return result["item_present"]
async def async_create_list(self, name, description):
"""
You can use this method to check if a movie has already been added to the list.(异步版本)
:param name: str
:param description: str
:return:
"""
result = await self._async_request_obj(
self._urls["create"],
params="session_id=%s" % self.session_id,
method="POST",
json={
"name": name,
"description": description,
"language": self.language
}
)
return result.list_id
async def async_add_movie(self, list_id, movie_id):
"""
Add a movie to a list.(异步版本)
:param list_id: int
:param movie_id: int
"""
await self._async_request_obj(
self._urls["add_movie"] % list_id,
params="session_id=%s" % self.session_id,
method="POST",
json={"media_id": movie_id}
)
async def async_remove_movie(self, list_id, movie_id):
"""
Remove a movie from a list.(异步版本)
:param list_id: int
:param movie_id: int
"""
await self._async_request_obj(
self._urls["remove_movie"] % list_id,
params="session_id=%s" % self.session_id,
method="POST",
json={"media_id": movie_id}
)
async def async_clear_list(self, list_id):
"""
Clear all of the items from a list.(异步版本)
:param list_id: int
"""
await self._async_request_obj(
self._urls["clear_list"] % list_id,
params="session_id=%s&confirm=true" % self.session_id,
method="POST"
)
async def async_delete_list(self, list_id):
"""
Delete a list.(异步版本)
:param list_id: int
"""
await self._async_request_obj(
self._urls["delete_list"] % list_id,
params="session_id=%s" % self.session_id,
method="DELETE"
)

View File

@@ -321,3 +321,299 @@ class Movie(TMDb):
params=params,
key="results"
)
# 异步版本方法
async def async_details(self, movie_id,
append_to_response="videos,trailers,images,casts,translations,keywords,release_dates"):
"""
Get the primary information about a movie.(异步版本)
:param movie_id: int
:param append_to_response: str
:return:
"""
return await self._async_request_obj(
self._urls["details"] % movie_id,
params="append_to_response=%s" % append_to_response
)
async def async_account_states(self, movie_id):
"""
Grab the following account states for a session:
Movie rating, If it belongs to your watchlist, or If it belongs to your favourite list.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(
self._urls["account_states"] % movie_id,
params="session_id=%s" % self.session_id
)
async def async_alternative_titles(self, movie_id, country=None):
"""
Get all of the alternative titles for a movie.(异步版本)
:param movie_id: int
:param country: str
:return:
"""
return await self._async_request_obj(
self._urls["alternative_titles"] % movie_id,
params="country=%s" % country if country else "",
key="titles"
)
async def async_changes(self, movie_id, start_date=None, end_date=None, page=1):
"""
Get the changes for a movie. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date and end_date query parameters.(异步版本)
:param movie_id: int
:param start_date: str
:param end_date: str
:param page: int
:return:
"""
params = "page=%s" % page
if start_date:
params += "&start_date=%s" % start_date
if end_date:
params += "&end_date=%s" % end_date
return await self._async_request_obj(
self._urls["changes"] % movie_id,
params=params,
key="changes"
)
async def async_credits(self, movie_id):
"""
Get the cast and crew for a movie.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(self._urls["credits"] % movie_id)
async def async_external_ids(self, movie_id):
"""
Get the external ids for a movie.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(self._urls["external_ids"] % movie_id)
async def async_images(self, movie_id, include_image_language=None):
"""
Get the images that belong to a movie.
Querying images with a language parameter will filter the results.
If you want to include a fallback language (especially useful for backdrops)
you can use the include_image_language parameter.
This should be a comma separated value like so: include_image_language=en,null.(异步版本)
:param movie_id: int
:param include_image_language: str
:return:
"""
return await self._async_request_obj(
self._urls["images"] % movie_id,
params="include_image_language=%s" % include_image_language if include_image_language else ""
)
async def async_keywords(self, movie_id):
"""
Get the keywords associated to a movie.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(
self._urls["keywords"] % movie_id,
key="keywords"
)
async def async_lists(self, movie_id, page=1):
"""
Get a list of lists that this movie belongs to.(异步版本)
:param movie_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["lists"] % movie_id,
params="page=%s" % page,
key="results"
)
async def async_recommendations(self, movie_id, page=1):
"""
Get a list of recommended movies for a movie.(异步版本)
:param movie_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["recommendations"] % movie_id,
params="page=%s" % page,
key="results"
)
async def async_release_dates(self, movie_id):
"""
Get the release date along with the certification for a movie.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(
self._urls["release_dates"] % movie_id,
key="results"
)
async def async_reviews(self, movie_id, page=1):
"""
Get the user reviews for a movie.(异步版本)
:param movie_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["reviews"] % movie_id,
params="page=%s" % page,
key="results"
)
async def async_similar(self, movie_id, page=1):
"""
Get a list of similar movies.(异步版本)
:param movie_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["similar"] % movie_id,
params="page=%s" % page,
key="results"
)
async def async_translations(self, movie_id):
"""
Get a list of translations that have been created for a movie.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(
self._urls["translations"] % movie_id,
key="translations"
)
async def async_videos(self, movie_id, page=1):
"""
Get the videos that have been added to a movie.(异步版本)
:param movie_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["videos"] % movie_id,
params="page=%s" % page,
key="results"
)
async def async_watch_providers(self, movie_id):
"""
You can query this method to get a list of the availabilities per country by provider.(异步版本)
:param movie_id: int
:return:
"""
return await self._async_request_obj(
self._urls["watch_providers"] % movie_id,
key="results"
)
async def async_rate_movie(self, movie_id, rating):
"""
Rate a movie.(异步版本)
:param movie_id: int
:param rating: float
"""
await self._async_request_obj(
self._urls["rate_movie"] % movie_id,
params="session_id=%s" % self.session_id,
method="POST",
json={"value": rating}
)
async def async_delete_rating(self, movie_id):
"""
Remove your rating for a movie.(异步版本)
:param movie_id: int
"""
await self._async_request_obj(
self._urls["delete_rating"] % movie_id,
params="session_id=%s" % self.session_id,
method="DELETE"
)
async def async_latest(self):
"""
Get the most newly created movie. This is a live response and will continuously change.(异步版本)
:return:
"""
return await self._async_request_obj(self._urls["latest"])
async def async_now_playing(self, region=None, page=1):
"""
Get a list of movies in theatres.(异步版本)
:param region: str
:param page: int
:return:
"""
params = "page=%s" % page
if region:
params += "&region=%s" % region
return await self._async_request_obj(
self._urls["now_playing"],
params=params,
key="results"
)
async def async_popular(self, region=None, page=1):
"""
Get a list of the current popular movies on TMDb. This list updates daily.(异步版本)
:param region: str
:param page: int
:return:
"""
params = "page=%s" % page
if region:
params += "&region=%s" % region
return await self._async_request_obj(
self._urls["popular"],
params=params,
key="results"
)
async def async_top_rated(self, region=None, page=1):
"""
Get the top rated movies on TMDb.(异步版本)
:param region: str
:param page: int
:return:
"""
params = "page=%s" % page
if region:
params += "&region=%s" % region
return await self._async_request_obj(
self._urls["top_rated"],
params=params,
key="results"
)
async def async_upcoming(self, region=None, page=1):
"""
Get a list of upcoming movies in theatres.(异步版本)
:param region: str
:param page: int
:return:
"""
params = "page=%s" % page
if region:
params += "&region=%s" % region
return await self._async_request_obj(
self._urls["upcoming"],
params=params,
key="results"
)

View File

@@ -135,3 +135,124 @@ class Person(TMDb):
params="page=%s" % page,
key="results"
)
# 异步版本方法
async def async_details(self, person_id, append_to_response="videos,images"):
"""
Get the primary person details by id.(异步版本)
:param append_to_response: str
:param person_id: int
:return:
"""
return await self._async_request_obj(
self._urls["details"] % person_id,
params="append_to_response=%s" % append_to_response
)
async def async_changes(self, person_id, start_date=None, end_date=None, page=1):
"""
Get the changes for a person. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date and end_date query parameters.(异步版本)
:param person_id: int
:param start_date: str
:param end_date: str
:param page: int
:return:
"""
params = "page=%s" % page
if start_date:
params += "&start_date=%s" % start_date
if end_date:
params += "&end_date=%s" % end_date
return await self._async_request_obj(
self._urls["changes"] % person_id,
params=params,
key="changes"
)
async def async_movie_credits(self, person_id):
"""
Get the movie credits for a person.(异步版本)
:param person_id: int
:return:
"""
return await self._async_request_obj(self._urls["movie_credits"] % person_id)
async def async_tv_credits(self, person_id):
"""
Get the TV show credits for a person.(异步版本)
:param person_id: int
:return:
"""
return await self._async_request_obj(self._urls["tv_credits"] % person_id)
async def async_combined_credits(self, person_id):
"""
Get the movie and TV credits together in a single response.(异步版本)
:param person_id: int
:return:
"""
return await self._async_request_obj(self._urls["combined_credits"] % person_id)
async def async_external_ids(self, person_id):
"""
Get the external ids for a person. We currently support the following external sources.
IMDB ID, Facebook, Freebase MID, Freebase ID, Instagram, TVRage ID, and Twitter异步版本
:param person_id: int
:return:
"""
return await self._async_request_obj(self._urls["external_ids"] % person_id)
async def async_images(self, person_id):
"""
Get the images for a person.(异步版本)
:param person_id: int
:return:
"""
return await self._async_request_obj(
self._urls["images"] % person_id,
key="profiles"
)
async def async_tagged_images(self, person_id, page=1):
"""
Get the images that this person has been tagged in.(异步版本)
:param person_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["tagged_images"] % person_id,
params="page=%s" % page,
key="results"
)
async def async_translations(self, person_id):
"""
Get a list of translations that have been created for a person.(异步版本)
:param person_id: int
:return:
"""
return await self._async_request_obj(
self._urls["translations"] % person_id,
key="translations"
)
async def async_latest(self):
"""
Get the most newly created person. This is a live response and will continuously change.(异步版本)
:return:
"""
return await self._async_request_obj(self._urls["latest"])
async def async_popular(self, page=1):
"""
Get the list of popular people on TMDb. This list updates daily.(异步版本)
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["popular"],
params="page=%s" % page,
key="results"
)

View File

@@ -143,6 +143,66 @@ class Search(TMDb):
key="results"
)
# 异步版本方法
async def async_companies(self, term, page=1):
"""
Search for companies.(异步版本)
:param term: str
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["companies"],
params="query=%s&page=%s" % (quote(term), page),
key="results"
)
async def async_collections(self, term, page=1):
"""
Search for collections.(异步版本)
:param term: str
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["collections"],
params="query=%s&page=%s" % (quote(term), page),
key="results"
)
async def async_keywords(self, term, page=1):
"""
Search for keywords.(异步版本)
:param term: str
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["keywords"],
params="query=%s&page=%s" % (quote(term), page),
key="results"
)
async def async_people(self, term, adult=None, region=None, page=1):
"""
Search for people.(异步版本)
:param term: str
:param adult: bool
:param region: str
:param page: int
:return:
"""
params = "query=%s&page=%s" % (quote(term), page)
if adult is not None:
params += "&include_adult=%s" % "true" if adult else "false"
if region is not None:
params += "&region=%s" % quote(region)
return await self._async_request_obj(
self._urls["people"],
params=params,
key="results"
)
async def async_multi(self, term, adult=None, region=None, page=1):
"""
Search multiple models in a single request.(异步版本)

View File

@@ -131,3 +131,122 @@ class Season(TMDb):
self._urls["videos"] % (tv_id, season_num),
params=params
)
# 异步版本方法
async def async_details(self, tv_id, season_num, append_to_response="videos,trailers,images,credits,translations"):
"""
Get the TV season details by id.(异步版本)
:param tv_id: int
:param season_num: int
:param append_to_response: str
:return:
"""
return await self._async_request_obj(
self._urls["details"] % (tv_id, season_num),
params="append_to_response=%s" % append_to_response
)
async def async_account_states(self, tv_id, season_num):
"""
Get all of the user ratings for the season's episodes.(异步版本)
:param tv_id: int
:param season_num: int
:return:
"""
return await self._async_request_obj(
self._urls["account_states"] % (tv_id, season_num),
params="session_id=%s" % self.session_id,
key="results"
)
async def async_aggregate_credits(self, tv_id, season_num):
"""
Get the aggregate credits for TV season.
This call differs from the main credits call in that it does not only return the season credits,
but rather is a view of all the cast & crew for all of the episodes belonging to a season.(异步版本)
:param tv_id: int
:param season_num: int
:return:
"""
return await self._async_request_obj(self._urls["aggregate_credits"] % (tv_id, season_num))
async def async_changes(self, season_id, start_date=None, end_date=None, page=1):
"""
Get the changes for a TV season. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date and end_date query parameters.(异步版本)
:param season_id: int
:param start_date: str
:param end_date: str
:param page: int
:return:
"""
params = "page=%s" % page
if start_date:
params += "&start_date=%s" % start_date
if end_date:
params += "&end_date=%s" % end_date
return await self._async_request_obj(
self._urls["changes"] % season_id,
params=params,
key="changes"
)
async def async_credits(self, tv_id, season_num):
"""
Get the credits for TV season.(异步版本)
:param tv_id: int
:param season_num: int
:return:
"""
return await self._async_request_obj(self._urls["credits"] % (tv_id, season_num))
async def async_external_ids(self, tv_id, season_num):
"""
Get the external ids for a TV season.(异步版本)
:param tv_id: int
:param season_num: int
:return:
"""
return await self._async_request_obj(self._urls["external_ids"] % (tv_id, season_num))
async def async_images(self, tv_id, season_num, include_image_language=None):
"""
Get the images that belong to a TV season.(异步版本)
:param tv_id: int
:param season_num: int
:param include_image_language: str
:return:
"""
return await self._async_request_obj(
self._urls["images"] % (tv_id, season_num),
params="include_image_language=%s" % include_image_language if include_image_language else "",
key="posters"
)
async def async_translations(self, tv_id, season_num):
"""
Get a list of the translations that exist for a TV show.(异步版本)
:param tv_id: int
:param season_num: int
"""
return await self._async_request_obj(
self._urls["translations"] % (tv_id, season_num),
key="translations"
)
async def async_videos(self, tv_id, season_num, include_video_language=None, page=1):
"""
Get the videos that have been added to a TV show.(异步版本)
:param tv_id: int
:param season_num: int
:param include_video_language: str
:param page: int
:return:
"""
params = "page=%s" % page
if include_video_language:
params += "&include_video_language=%s" % include_video_language
return await self._async_request_obj(
self._urls["videos"] % (tv_id, season_num),
params=params
)

View File

@@ -78,3 +78,79 @@ class Trending(TMDb):
:return:
"""
return self._trending(media_type="person", time_window="week", page=page)
# 异步版本方法
async def _async_trending(self, media_type="all", time_window="day", page=1):
"""
Get trending, TTLCache 12 hours异步版本
"""
return await self._async_request_obj(
self._urls["trending"] % (media_type, time_window),
params="page=%s" % page,
key="results",
call_cached=False
)
async def async_all_day(self, page=1):
"""
Get all daily trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="all", time_window="day", page=page)
async def async_all_week(self, page=1):
"""
Get all weekly trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="all", time_window="week", page=page)
async def async_movie_day(self, page=1):
"""
Get movie daily trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="movie", time_window="day", page=page)
async def async_movie_week(self, page=1):
"""
Get movie weekly trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="movie", time_window="week", page=page)
async def async_tv_day(self, page=1):
"""
Get tv daily trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="tv", time_window="day", page=page)
async def async_tv_week(self, page=1):
"""
Get tv weekly trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="tv", time_window="week", page=page)
async def async_person_day(self, page=1):
"""
Get person daily trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="person", time_window="day", page=page)
async def async_person_week(self, page=1):
"""
Get person weekly trending异步版本
:param page: int
:return:
"""
return await self._async_trending(media_type="person", time_window="week", page=page)

View File

@@ -344,3 +344,313 @@ class TV(TMDb):
params="page=%s" % page,
key="results"
)
# 异步版本方法
async def async_details(self, tv_id, append_to_response="videos,trailers,images,credits,translations"):
"""
Get the primary TV show details by id.(异步版本)
:param tv_id: int
:param append_to_response: str
:return:
"""
return await self._async_request_obj(
self._urls["details"] % tv_id,
params="append_to_response=%s" % append_to_response,
)
async def async_account_states(self, tv_id):
"""
Grab the following account states for a session:
TV show rating, If it belongs to your watchlist, or If it belongs to your favourite list.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["account_states"] % tv_id,
params="session_id=%s" % self.session_id
)
async def async_aggregate_credits(self, tv_id):
"""
Get the aggregate credits (cast and crew) that have been added to a TV show.
This call differs from the main credits call in that it does not return the newest season but rather,
is a view of all the entire cast & crew for all episodes belonging to a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(self._urls["aggregate_credits"] % tv_id)
async def async_alternative_titles(self, tv_id):
"""
Returns all of the alternative titles for a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["alternative_titles"] % tv_id,
key="results"
)
async def async_changes(self, tv_id, start_date=None, end_date=None, page=1):
"""
Get the changes for a TV show. By default only the last 24 hours are returned.
You can query up to 14 days in a single query by using the start_date and end_date query parameters.(异步版本)
:param tv_id: int
:param start_date: str
:param end_date: str
:param page: int
"""
params = "page=%s" % page
if start_date:
params += "&start_date=%s" % start_date
if end_date:
params += "&end_date=%s" % end_date
return await self._async_request_obj(
self._urls["changes"] % tv_id,
params=params,
key="changes"
)
async def async_content_ratings(self, tv_id):
"""
Get the list of content ratings (certifications) that have been added to a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["content_ratings"] % tv_id,
key="results"
)
async def async_credits(self, tv_id):
"""
Get the credits (cast and crew) that have been added to a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(self._urls["credits"] % tv_id)
async def async_episode_groups(self, tv_id):
"""
Get all of the episode groups that have been created for a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["episode_groups"] % tv_id,
key="results"
)
async def async_group_episodes(self, group_id):
"""
查询剧集组所有剧集(异步版本)
:param group_id: int
:return:
"""
return await self._async_request_obj(
self._urls["group_episodes"] % group_id,
key="groups"
)
async def async_external_ids(self, tv_id):
"""
Get the external ids for a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(self._urls["external_ids"] % tv_id)
async def async_images(self, tv_id, include_image_language=None):
"""
Get the images that belong to a TV show.
Querying images with a language parameter will filter the results.
If you want to include a fallback language (especially useful for backdrops)
you can use the include_image_language parameter.
This should be a comma separated value like so: include_image_language=en,null.(异步版本)
:param tv_id: int
:param include_image_language: str
:return:
"""
return await self._async_request_obj(
self._urls["images"] % tv_id,
params="include_image_language=%s" % include_image_language if include_image_language else ""
)
async def async_keywords(self, tv_id):
"""
Get the keywords that have been added to a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["keywords"] % tv_id,
key="results"
)
async def async_recommendations(self, tv_id, page=1):
"""
Get the list of TV show recommendations for this item.(异步版本)
:param tv_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["recommendations"] % tv_id,
params="page=%s" % page,
key="results"
)
async def async_reviews(self, tv_id, page=1):
"""
Get the reviews for a TV show.(异步版本)
:param tv_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["reviews"] % tv_id,
params="page=%s" % page,
key="results"
)
async def async_screened_theatrically(self, tv_id):
"""
Get a list of seasons or episodes that have been screened in a film festival or theatre.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["screened_theatrically"] % tv_id,
key="results"
)
async def async_similar(self, tv_id, page=1):
"""
Get the primary TV show details by id.(异步版本)
:param tv_id: int
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["similar"] % tv_id,
params="page=%s" % page,
key="results"
)
async def async_translations(self, tv_id):
"""
Get a list of the translations that exist for a TV show.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["translations"] % tv_id,
key="translations"
)
async def async_videos(self, tv_id, include_video_language=None, page=1):
"""
Get the videos that have been added to a TV show.(异步版本)
:param tv_id: int
:param include_video_language: str
:param page: int
:return:
"""
params = "page=%s" % page
if include_video_language:
params += "&include_video_language=%s" % include_video_language
return await self._async_request_obj(
self._urls["videos"] % tv_id,
params=params
)
async def async_watch_providers(self, tv_id):
"""
You can query this method to get a list of the availabilities per country by provider.(异步版本)
:param tv_id: int
:return:
"""
return await self._async_request_obj(
self._urls["watch_providers"] % tv_id,
key="results"
)
async def async_rate_tv_show(self, tv_id, rating):
"""
Rate a TV show.(异步版本)
:param tv_id: int
:param rating: float
"""
await self._async_request_obj(
self._urls["rate_tv_show"] % tv_id,
params="session_id=%s" % self.session_id,
method="POST",
json={"value": rating}
)
async def async_delete_rating(self, tv_id):
"""
Remove your rating for a TV show.(异步版本)
:param tv_id: int
"""
await self._async_request_obj(
self._urls["delete_rating"] % tv_id,
params="session_id=%s" % self.session_id,
method="DELETE"
)
async def async_latest(self):
"""
Get the most newly created TV show. This is a live response and will continuously change.(异步版本)
:return:
"""
return await self._async_request_obj(self._urls["latest"])
async def async_airing_today(self, page=1):
"""
Get a list of TV shows that are airing today.
This query is purely day based as we do not currently support airing times.(异步版本)
:param page: int
:return:
"""
return await self._async_request_obj(
self._urls["airing_today"],
params="page=%s" % page,
key="results"
)
async def async_on_the_air(self, page=1):
"""
Get a list of shows that are currently on the air.(异步版本)
:param page:
:return:
"""
return await self._async_request_obj(
self._urls["on_the_air"],
params="page=%s" % page,
key="results"
)
async def async_popular(self, page=1):
"""
Get a list of the current popular TV shows on TMDb. This list updates daily.(异步版本)
:param page:
:return:
"""
return await self._async_request_obj(
self._urls["popular"],
params="page=%s" % page,
key="results"
)
async def async_top_rated(self, page=1):
"""
Get a list of the top rated TV shows on TMDb.(异步版本)
:param page:
:return:
"""
return await self._async_request_obj(
self._urls["top_rated"],
params="page=%s" % page,
key="results"
)