Trakt: Pass range of runtimes to limit api results even further

pull/105/head
desimaniac 5 years ago
parent bf23ef3330
commit b0441ff79a

@ -92,6 +92,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
include_non_acting_roles=False,
):
@ -123,6 +124,10 @@ class Trakt:
if genres:
payload['genres'] = ','.join(genres).lower()
# runtimes range
if runtimes:
payload['runtimes'] = runtimes
processed = []
if authenticate_user:
@ -439,6 +444,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -450,6 +456,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -460,6 +467,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -471,6 +479,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -481,6 +490,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -492,6 +502,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_person_shows(
@ -502,6 +513,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
include_non_acting_roles=False,
):
@ -514,6 +526,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
include_non_acting_roles=include_non_acting_roles,
)
@ -525,6 +538,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
most_type=None,
):
@ -537,6 +551,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -547,6 +562,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
most_type=None,
):
@ -559,6 +575,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -570,6 +587,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -582,6 +600,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_watchlist_shows(
@ -592,6 +611,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -604,6 +624,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_user_list_shows(
@ -615,6 +636,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
list_user, list_key = extract_list_user_and_key_from_url(list_url)
@ -631,6 +653,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
############################################################
@ -651,6 +674,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -662,6 +686,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -672,6 +697,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -683,6 +709,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -693,6 +720,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -704,6 +732,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_person_movies(
@ -714,6 +743,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
include_non_acting_roles=False,
):
@ -726,6 +756,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
include_non_acting_roles=include_non_acting_roles,
)
@ -737,6 +768,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
most_type=None,
):
@ -749,6 +781,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
@cache(cache_file=cachefile, retry_if_blank=True)
@ -760,6 +793,7 @@ class Trakt:
languages=None,
genres=None,
most_type=None,
runtimes=None,
):
return self._make_items_request(
@ -771,6 +805,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_boxoffice_movies(
@ -780,6 +815,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -791,6 +827,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_recommended_movies(
@ -801,6 +838,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -813,6 +851,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_watchlist_movies(
@ -823,6 +862,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
return self._make_items_request(
@ -835,6 +875,7 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)
def get_user_list_movies(
@ -846,6 +887,7 @@ class Trakt:
countries=None,
languages=None,
genres=None,
runtimes=None,
):
list_user, list_key = extract_list_user_and_key_from_url(list_url)
@ -862,4 +904,5 @@ class Trakt:
countries=countries,
languages=languages,
genres=genres,
runtimes=runtimes,
)

@ -63,6 +63,7 @@ class Config(object, metaclass=Singleton):
'blacklisted_genres': [],
'blacklisted_networks': [],
'blacklisted_min_runtime': 15,
'blacklisted_max_runtime': 0,
'blacklisted_min_year': 2000,
'blacklisted_max_year': 2019,
'blacklisted_title_keywords': [],
@ -74,6 +75,7 @@ class Config(object, metaclass=Singleton):
'allowed_languages': [],
'blacklisted_genres': [],
'blacklisted_min_runtime': 60,
'blacklisted_max_runtime': 0,
'blacklisted_min_year': 2000,
'blacklisted_max_year': 2019,
'blacklisted_title_keywords': [],

@ -40,6 +40,7 @@
"fan-film"
],
"blacklisted_min_runtime": 60,
"blacklisted_max_runtime": 0,
"blacklisted_min_year": 2000,
"blacklisted_max_year": 2019,
"blacklisted_title_keywords": [
@ -86,6 +87,7 @@
"yahoo!"
],
"blacklisted_min_runtime": 15,
"blacklisted_max_runtime": 0,
"blacklisted_min_year": 2010,
"blacklisted_max_year": 2019,
"blacklisted_title_keywords": []

@ -387,6 +387,22 @@ def shows(
else:
years = None
# runtimes range
if cfg.filters.shows.blacklisted_min_runtime:
min_runtime = cfg.filters.shows.blacklisted_min_runtime
else:
min_runtime = 0
if cfg.filters.shows.blacklisted_max_runtime and cfg.filters.shows.blacklisted_max_runtime >= min_runtime:
max_runtime = cfg.filters.shows.blacklisted_max_runtime
else:
max_runtime = 9999
if min_runtime == 0 and max_runtime == 9999:
runtimes = None
else:
runtimes = str(min_runtime) + '-' + str(max_runtime)
# replace sonarr root_folder if folder is supplied
if folder:
cfg['sonarr']['root_folder'] = folder
@ -415,6 +431,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'trending':
@ -423,6 +440,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'popular':
@ -431,6 +449,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'person':
@ -444,6 +463,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
include_non_acting_roles=include_non_acting_roles,
)
@ -454,6 +474,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower().startswith('played'):
@ -463,6 +484,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
most_type=most_type if most_type else None,
)
@ -473,6 +495,7 @@ def shows(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
most_type=most_type if most_type else None,
)
@ -866,6 +889,22 @@ def movies(
else:
years = None
# runtimes range
if cfg.filters.movies.blacklisted_min_runtime:
min_runtime = cfg.filters.movies.blacklisted_min_runtime
else:
min_runtime = 0
if cfg.filters.movies.blacklisted_max_runtime and cfg.filters.movies.blacklisted_max_runtime >= min_runtime:
max_runtime = cfg.filters.movies.blacklisted_max_runtime
else:
max_runtime = 9999
if min_runtime == 0 and max_runtime == 9999:
runtimes = None
else:
runtimes = str(min_runtime) + '-' + str(max_runtime)
# replace radarr root_folder if folder is supplied
if folder:
cfg['radarr']['root_folder'] = folder
@ -901,6 +940,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'trending':
@ -909,6 +949,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'popular':
@ -917,6 +958,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'boxoffice':
@ -925,6 +967,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower() == 'person':
@ -938,6 +981,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
include_non_acting_roles=include_non_acting_roles,
)
@ -948,6 +992,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
)
elif list_type.lower().startswith('played'):
@ -957,6 +1002,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
most_type=most_type if most_type else None,
)
@ -967,6 +1013,7 @@ def movies(
countries=cfg.filters.shows.allowed_countries,
languages=cfg.filters.shows.allowed_languages,
genres=genres,
runtimes=runtimes,
most_type=most_type if most_type else None,
)

Loading…
Cancel
Save