From e39daaaad8c20235ee0437c8b480317ebbfa52b5 Mon Sep 17 00:00:00 2001 From: l3uddz <> Date: Fri, 18 May 2018 19:06:28 +0100 Subject: [PATCH] send genre tag in trakt list request --- media/trakt.py | 23 ++++++++++++++++------- traktarr.py | 12 ++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/media/trakt.py b/media/trakt.py index c6111be..90dbc00 100644 --- a/media/trakt.py +++ b/media/trakt.py @@ -57,11 +57,14 @@ class Trakt: @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={}, - sleep_between=5): + sleep_between=5, genres=None): if languages is None: languages = ['en'] payload = dict_merge(payload, {'extended': 'full', 'limit': limit, 'page': 1, 'languages': ','.join(languages)}) + if genres: + payload['genres'] = genres + processed = [] type_name = type_name.replace('{authenticate_user}', self._user_used_for_authentication(authenticate_user)) @@ -306,31 +309,34 @@ class Trakt: 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( url='https://api.trakt.tv/shows/trending', limit=limit, languages=languages, object_name='shows', 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( url='https://api.trakt.tv/shows/popular', limit=limit, languages=languages, object_name='shows', 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( url='https://api.trakt.tv/shows/anticipated', limit=limit, languages=languages, object_name='shows', type_name='anticipated', + genres=genres ) def get_watchlist_shows(self, authenticate_user=None, limit=1000, languages=None): @@ -367,31 +373,34 @@ class Trakt: 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( url='https://api.trakt.tv/movies/trending', limit=limit, languages=languages, object_name='movies', 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( url='https://api.trakt.tv/movies/popular', limit=limit, languages=languages, object_name='movies', 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( url='https://api.trakt.tv/movies/anticipated', limit=limit, languages=languages, object_name='movies', type_name='anticipated', + genres=genres ) def get_boxoffice_movies(self, limit=1000, languages=None): diff --git a/traktarr.py b/traktarr.py index 23e4b8c..cd06078 100755 --- a/traktarr.py +++ b/traktarr.py @@ -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 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': - trakt_objects_list = trakt.get_trending_shows() + trakt_objects_list = trakt.get_trending_shows(genres=genre) 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': trakt_objects_list = trakt.get_watchlist_shows(authenticate_user) 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 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': - trakt_objects_list = trakt.get_trending_movies() + trakt_objects_list = trakt.get_trending_movies(genres=genre) 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': trakt_objects_list = trakt.get_boxoffice_movies() elif list_type.lower() == 'watchlist':