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
@@ -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")
@@ -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"
)
@@ -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"])
@@ -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
)
@@ -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")
@@ -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")
@@ -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")
@@ -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"
)
@@ -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"
)
@@ -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"
)
@@ -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.(异步版本)
@@ -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
)
@@ -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)
+310
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"
)