send genre tag in trakt list request

pull/54/head
l3uddz 7 years ago
parent 6124790abd
commit fb0589b9cd

@ -57,11 +57,14 @@ class Trakt:
@backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=4, on_backoff=backoff_handler) @backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=4, on_backoff=backoff_handler)
def _make_items_request(self, url, limit, languages, type_name, object_name, authenticate_user=None, payload={}, def _make_items_request(self, url, limit, languages, type_name, object_name, authenticate_user=None, payload={},
sleep_between=5): sleep_between=5, genres=None):
if languages is None: if languages is None:
languages = ['en'] languages = ['en']
payload = dict_merge(payload, {'extended': 'full', 'limit': limit, 'page': 1, 'languages': ','.join(languages)}) payload = dict_merge(payload, {'extended': 'full', 'limit': limit, 'page': 1, 'languages': ','.join(languages)})
if genres:
payload['genres'] = genres
processed = [] processed = []
type_name = type_name.replace('{authenticate_user}', self._user_used_for_authentication(authenticate_user)) type_name = type_name.replace('{authenticate_user}', self._user_used_for_authentication(authenticate_user))
@ -306,31 +309,34 @@ class Trakt:
object_name='show', object_name='show',
) )
def get_trending_shows(self, limit=1000, languages=None): def get_trending_shows(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/trending', url='https://api.trakt.tv/shows/trending',
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='shows', object_name='shows',
type_name='trending', type_name='trending',
genres=genres
) )
def get_popular_shows(self, limit=1000, languages=None): def get_popular_shows(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/popular', url='https://api.trakt.tv/shows/popular',
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='shows', object_name='shows',
type_name='popular', type_name='popular',
genres=genres
) )
def get_anticipated_shows(self, limit=1000, languages=None): def get_anticipated_shows(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/anticipated', url='https://api.trakt.tv/shows/anticipated',
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='shows', object_name='shows',
type_name='anticipated', type_name='anticipated',
genres=genres
) )
def get_watchlist_shows(self, authenticate_user=None, limit=1000, languages=None): def get_watchlist_shows(self, authenticate_user=None, limit=1000, languages=None):
@ -367,31 +373,34 @@ class Trakt:
object_name='movie', object_name='movie',
) )
def get_trending_movies(self, limit=1000, languages=None): def get_trending_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/trending', url='https://api.trakt.tv/movies/trending',
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='movies', object_name='movies',
type_name='trending', type_name='trending',
genres=genres
) )
def get_popular_movies(self, limit=1000, languages=None): def get_popular_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/popular', url='https://api.trakt.tv/movies/popular',
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='movies', object_name='movies',
type_name='popular', type_name='popular',
genres=genres
) )
def get_anticipated_movies(self, limit=1000, languages=None): def get_anticipated_movies(self, limit=1000, languages=None, genres=None):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/anticipated', url='https://api.trakt.tv/movies/anticipated',
limit=limit, limit=limit,
languages=languages, languages=languages,
object_name='movies', object_name='movies',
type_name='anticipated', type_name='anticipated',
genres=genres
) )
def get_boxoffice_movies(self, limit=1000, languages=None): def get_boxoffice_movies(self, limit=1000, languages=None):

@ -211,11 +211,11 @@ def shows(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_sea
# get trakt series list # get trakt series list
if list_type.lower() == 'anticipated': if list_type.lower() == 'anticipated':
trakt_objects_list = trakt.get_anticipated_shows() trakt_objects_list = trakt.get_anticipated_shows(genres=genre)
elif list_type.lower() == 'trending': elif list_type.lower() == 'trending':
trakt_objects_list = trakt.get_trending_shows() trakt_objects_list = trakt.get_trending_shows(genres=genre)
elif list_type.lower() == 'popular': elif list_type.lower() == 'popular':
trakt_objects_list = trakt.get_popular_shows() trakt_objects_list = trakt.get_popular_shows(genres=genre)
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':
trakt_objects_list = trakt.get_watchlist_shows(authenticate_user) trakt_objects_list = trakt.get_watchlist_shows(authenticate_user)
else: else:
@ -386,11 +386,11 @@ def movies(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_se
# get trakt movies list # get trakt movies list
if list_type.lower() == 'anticipated': if list_type.lower() == 'anticipated':
trakt_objects_list = trakt.get_anticipated_movies() trakt_objects_list = trakt.get_anticipated_movies(genres=genre)
elif list_type.lower() == 'trending': elif list_type.lower() == 'trending':
trakt_objects_list = trakt.get_trending_movies() trakt_objects_list = trakt.get_trending_movies(genres=genre)
elif list_type.lower() == 'popular': elif list_type.lower() == 'popular':
trakt_objects_list = trakt.get_popular_movies() trakt_objects_list = trakt.get_popular_movies(genres=genre)
elif list_type.lower() == 'boxoffice': elif list_type.lower() == 'boxoffice':
trakt_objects_list = trakt.get_boxoffice_movies() trakt_objects_list = trakt.get_boxoffice_movies()
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':

Loading…
Cancel
Save