diff --git a/media/trakt.py b/media/trakt.py index e8d2187..59afd8b 100644 --- a/media/trakt.py +++ b/media/trakt.py @@ -3,6 +3,7 @@ import time import backoff import requests +from cashier import cache from helpers.misc import backoff_handler, dict_merge from helpers.trakt import extract_list_user_and_key_from_url @@ -377,6 +378,7 @@ class Trakt: object_name='show', ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_trending_shows(self, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/shows/trending', @@ -387,6 +389,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_popular_shows(self, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/shows/popular', @@ -397,6 +400,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_anticipated_shows(self, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/shows/anticipated', @@ -407,6 +411,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_person_shows(self, person, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/people/%s/shows' % person, @@ -417,6 +422,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_most_played_shows(self, limit=1000, 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), @@ -427,6 +433,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_most_watched_shows(self, limit=1000, languages=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), @@ -437,6 +444,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_recommended_shows(self, authenticate_user=None, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/recommendations/shows', @@ -482,6 +490,7 @@ class Trakt: object_name='movie', ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_trending_movies(self, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/movies/trending', @@ -492,6 +501,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_popular_movies(self, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/movies/popular', @@ -502,6 +512,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_anticipated_movies(self, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/movies/anticipated', @@ -512,6 +523,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_person_movies(self, person, limit=1000, languages=None, genres=None): return self._make_items_request( url='https://api.trakt.tv/people/%s/movies' % person, @@ -522,6 +534,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_most_played_movies(self, limit=1000, 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), @@ -532,6 +545,7 @@ class Trakt: genres=genres ) + @cache(cache_file='cache.db', retry_if_blank=True) def get_most_watched_movies(self, limit=1000, 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), diff --git a/requirements.txt b/requirements.txt index 8066002..1f3ada8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ attrdict==2.0.0 click==6.7 requests~=2.20.0 pyfiglet +cashier~=1.3 \ No newline at end of file