|
|
|
@ -72,18 +72,25 @@ class Trakt:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
@backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=6, on_backoff=backoff_handler)
|
|
|
|
|
def _make_items_request(self, url, limit, languages, type_name, object_name, authenticate_user=None, payload={},
|
|
|
|
|
sleep_between=5, genres=None, include_non_acting_roles=False):
|
|
|
|
|
def _make_items_request(self, url, limit, type_name, object_name, authenticate_user=None, payload={},
|
|
|
|
|
sleep_between=5, countries=None, languages=None, genres=None, include_non_acting_roles=False):
|
|
|
|
|
|
|
|
|
|
# languages
|
|
|
|
|
if not languages:
|
|
|
|
|
languages = ['en']
|
|
|
|
|
languages = ','.join(languages).lower()
|
|
|
|
|
|
|
|
|
|
payload = dict_merge(payload, {
|
|
|
|
|
'extended': 'full',
|
|
|
|
|
'limit': limit,
|
|
|
|
|
'page': 1,
|
|
|
|
|
'languages': ','.join(languages),
|
|
|
|
|
'languages': languages,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# countries
|
|
|
|
|
if countries:
|
|
|
|
|
payload['countries'] = ','.join(countries).lower()
|
|
|
|
|
|
|
|
|
|
# currently only support for one genre item, despite name
|
|
|
|
|
if genres:
|
|
|
|
|
payload['genres'] = genres
|
|
|
|
@ -395,95 +402,103 @@ class Trakt:
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_trending_shows(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_trending_shows(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/shows/trending',
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='trending',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_popular_shows(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_popular_shows(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/shows/popular',
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='popular',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_anticipated_shows(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_anticipated_shows(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/shows/anticipated',
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='anticipated',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_person_shows(self, person, limit=1000, languages=None, genres=None,
|
|
|
|
|
def get_person_shows(self, person, limit=1000, countries=None, languages=None, genres=None,
|
|
|
|
|
include_non_acting_roles=False):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/people/%s/shows' % person.replace(' ', '-').lower(),
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='person',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
include_non_acting_roles=include_non_acting_roles,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_most_played_shows(self, limit=1000, languages=None, genres=None, most_type=None):
|
|
|
|
|
def get_most_played_shows(self, limit=1000, countries=None, languages=None, genres=None, most_type=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/shows/played/%s' % ('weekly' if not most_type else most_type),
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='played',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_most_watched_shows(self, limit=1000, languages=None, genres=None, most_type=None):
|
|
|
|
|
def get_most_watched_shows(self, limit=1000, languages=None, countries=None, genres=None, most_type=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/shows/watched/%s' % ('weekly' if not most_type else most_type),
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='watched',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_recommended_shows(self, authenticate_user=None, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_recommended_shows(self, authenticate_user=None, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/recommendations/shows',
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='recommended from {authenticate_user}',
|
|
|
|
|
authenticate_user=authenticate_user,
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_watchlist_shows(self, authenticate_user=None, limit=1000, languages=None):
|
|
|
|
|
def get_watchlist_shows(self, authenticate_user=None, limit=1000, countries=None, languages=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/users/{authenticate_user}/watchlist/shows',
|
|
|
|
|
object_name='shows',
|
|
|
|
|
type_name='watchlist from {authenticate_user}',
|
|
|
|
|
authenticate_user=authenticate_user,
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_user_list_shows(self, list_url, authenticate_user=None, limit=1000, languages=None):
|
|
|
|
|
def get_user_list_shows(self, list_url, authenticate_user=None, limit=1000, countries=None, languages=None):
|
|
|
|
|
list_user, list_key = extract_list_user_and_key_from_url(list_url)
|
|
|
|
|
|
|
|
|
|
log.debug('Fetching %s from %s', list_key, list_user)
|
|
|
|
@ -494,6 +509,7 @@ class Trakt:
|
|
|
|
|
type_name=(list_key + ' from ' + list_user),
|
|
|
|
|
authenticate_user=authenticate_user,
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -508,104 +524,113 @@ class Trakt:
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_trending_movies(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_trending_movies(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/movies/trending',
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='trending',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_popular_movies(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_popular_movies(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/movies/popular',
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='popular',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_anticipated_movies(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_anticipated_movies(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/movies/anticipated',
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='anticipated',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_person_movies(self, person, limit=1000, languages=None, genres=None,
|
|
|
|
|
def get_person_movies(self, person, limit=1000, countries=None, languages=None, genres=None,
|
|
|
|
|
include_non_acting_roles=False):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/people/%s/movies' % person.replace(' ', '-').lower(),
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='person',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
include_non_acting_roles=include_non_acting_roles,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_most_played_movies(self, limit=1000, languages=None, genres=None, most_type=None):
|
|
|
|
|
def get_most_played_movies(self, limit=1000, countries=None, languages=None, genres=None, most_type=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/movies/played/%s' % ('weekly' if not most_type else most_type),
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='played',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@cache(cache_file=cachefile, retry_if_blank=True)
|
|
|
|
|
def get_most_watched_movies(self, limit=1000, languages=None, genres=None, most_type=None):
|
|
|
|
|
def get_most_watched_movies(self, limit=1000, countries=None, languages=None, genres=None, most_type=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/movies/watched/%s' % ('weekly' if not most_type else most_type),
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='watched',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_boxoffice_movies(self, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_boxoffice_movies(self, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/movies/boxoffice',
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='anticipated',
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_recommended_movies(self, authenticate_user=None, limit=1000, languages=None, genres=None):
|
|
|
|
|
def get_recommended_movies(self, authenticate_user=None, limit=1000, countries=None, languages=None, genres=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/recommendations/movies',
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='recommended from {authenticate_user}',
|
|
|
|
|
authenticate_user=authenticate_user,
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
genres=genres,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_watchlist_movies(self, authenticate_user=None, limit=1000, languages=None):
|
|
|
|
|
def get_watchlist_movies(self, authenticate_user=None, limit=1000, countries=None, languages=None):
|
|
|
|
|
return self._make_items_request(
|
|
|
|
|
url='https://api.trakt.tv/users/{authenticate_user}/watchlist/movies',
|
|
|
|
|
object_name='movies',
|
|
|
|
|
type_name='watchlist from {authenticate_user}',
|
|
|
|
|
authenticate_user=authenticate_user,
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def get_user_list_movies(self, list_url, authenticate_user=None, limit=1000, languages=None):
|
|
|
|
|
def get_user_list_movies(self, list_url, authenticate_user=None, limit=1000, countries=None, languages=None):
|
|
|
|
|
list_user, list_key = extract_list_user_and_key_from_url(list_url)
|
|
|
|
|
|
|
|
|
|
log.debug('Fetching %s from %s', list_key, list_user)
|
|
|
|
@ -616,5 +641,6 @@ class Trakt:
|
|
|
|
|
type_name=(list_key + ' from ' + list_user),
|
|
|
|
|
authenticate_user=authenticate_user,
|
|
|
|
|
limit=limit,
|
|
|
|
|
countries=countries,
|
|
|
|
|
languages=languages,
|
|
|
|
|
)
|
|
|
|
|