Merge pull request #72 from l3uddz/feat/trakt-cache

Feat/trakt cache
pull/73/head
desimaniac 6 years ago committed by GitHub
commit 3b0cdf25e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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),

@ -4,3 +4,4 @@ attrdict==2.0.0
click==6.7
requests~=2.20.0
pyfiglet
cashier~=1.3

@ -529,7 +529,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
log.debug("Skipping: %s because it did not have a rating/lacked imdbID",
movie['movie']['title'])
continue
if rating is None or movieRating >= rating:
if (rating is None or movieRating is None) or movieRating >= rating:
log.info("Adding: %s (%d) | Genres: %s | Country: %s", movie['movie']['title'],
movie['movie']['year'],
', '.join(movie['movie']['genres']), movie['movie']['country'].upper())

Loading…
Cancel
Save