Misc: Change layout of function params

pull/105/head
desimaniac 5 years ago
parent fabb41ddaf
commit 430bba33b0

@ -24,11 +24,14 @@ class Trakt:
# Requests # Requests
############################################################ ############################################################
def _make_request(self, url, payload={}, authenticate_user=None, request_type='get'): def _make_request(self, url, payload=None, authenticate_user=None, request_type='get'):
headers, authenticate_user = self._headers(authenticate_user) headers, authenticate_user = self._headers(authenticate_user)
headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' \ headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' \
'(KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36' '(KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36'
if payload is None:
payload = {}
if authenticate_user: if authenticate_user:
url = url.replace('{authenticate_user}', authenticate_user) url = url.replace('{authenticate_user}', authenticate_user)
@ -52,7 +55,11 @@ class Trakt:
return req, resp_data return req, resp_data
@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_item_request(self, url, object_name, payload={}): def _make_item_request(self, url, object_name, payload=None):
if payload is None:
payload = {}
payload = dict_merge(payload, {'extended': 'full'}) payload = dict_merge(payload, {'extended': 'full'})
try: try:
@ -72,11 +79,27 @@ class Trakt:
return None return None
@backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=6, on_backoff=backoff_handler) @backoff.on_predicate(backoff.expo, lambda x: x is None, max_tries=6, on_backoff=backoff_handler)
def _make_items_request(self, url, limit, type_name, object_name, authenticate_user=None, payload={}, def _make_items_request(
sleep_between=5, years=None, countries=None, languages=None, genres=None, self,
include_non_acting_roles=False): url,
limit,
# languages type_name,
object_name,
authenticate_user=None,
payload=None,
sleep_between=5,
years=None,
countries=None,
languages=None,
genres=None,
include_non_acting_roles=False,
):
# default payload
if payload is None:
payload = {}
# languages list
if not languages: if not languages:
languages = ['en'] languages = ['en']
languages = ','.join(languages).lower() languages = ','.join(languages).lower()
@ -88,15 +111,15 @@ class Trakt:
'languages': languages, 'languages': languages,
}) })
# years # years range
if years: if years:
payload['years'] = years payload['years'] = years
# countries # countries list
if countries: if countries:
payload['countries'] = ','.join(countries).lower() payload['countries'] = ','.join(countries).lower()
# genres # genres list
if genres: if genres:
payload['genres'] = ','.join(genres).lower() payload['genres'] = ','.join(genres).lower()
@ -409,7 +432,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_trending_shows(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_trending_shows(
self,
limit=1000,
years=None,
countries=None,
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',
object_name='shows', object_name='shows',
@ -422,7 +453,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_popular_shows(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_popular_shows(
self,
limit=1000,
years=None,
countries=None,
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',
object_name='shows', object_name='shows',
@ -435,7 +474,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_anticipated_shows(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_anticipated_shows(
self,
limit=1000,
years=None,
countries=None,
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',
object_name='shows', object_name='shows',
@ -447,8 +494,17 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_person_shows(self, person, limit=1000, years=None, countries=None, languages=None, genres=None, def get_person_shows(
include_non_acting_roles=False): self,
person,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
include_non_acting_roles=False,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/people/%s/shows' % person.replace(' ', '-').lower(), url='https://api.trakt.tv/people/%s/shows' % person.replace(' ', '-').lower(),
object_name='shows', object_name='shows',
@ -462,8 +518,16 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_played_shows(self, limit=1000, years=None, countries=None, languages=None, genres=None, def get_most_played_shows(
most_type=None): self,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
most_type=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/played/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/shows/played/%s' % ('weekly' if not most_type else most_type),
object_name='shows', object_name='shows',
@ -476,8 +540,16 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_watched_shows(self, limit=1000, years=None, countries=None, languages=None, genres=None, def get_most_watched_shows(
most_type=None): self,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
most_type=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/shows/watched/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/shows/watched/%s' % ('weekly' if not most_type else most_type),
object_name='shows', object_name='shows',
@ -490,8 +562,16 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_recommended_shows(self, authenticate_user=None, limit=1000, years=None, countries=None, languages=None, def get_recommended_shows(
genres=None): self,
authenticate_user=None,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/recommendations/shows', url='https://api.trakt.tv/recommendations/shows',
object_name='shows', object_name='shows',
@ -504,8 +584,16 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_watchlist_shows(self, authenticate_user=None, limit=1000, years=None, countries=None, languages=None, def get_watchlist_shows(
genres=None): self,
authenticate_user=None,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/users/{authenticate_user}/watchlist/shows', url='https://api.trakt.tv/users/{authenticate_user}/watchlist/shows',
object_name='shows', object_name='shows',
@ -518,8 +606,17 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_user_list_shows(self, list_url, authenticate_user=None, limit=1000, years=None, countries=None, def get_user_list_shows(
languages=None, genres=None): self,
list_url,
authenticate_user=None,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
list_user, list_key = extract_list_user_and_key_from_url(list_url) list_user, list_key = extract_list_user_and_key_from_url(list_url)
log.debug('Fetching %s from %s', list_key, list_user) log.debug('Fetching %s from %s', list_key, list_user)
@ -547,7 +644,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_trending_movies(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_trending_movies(
self,
limit=1000,
years=None,
countries=None,
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',
object_name='movies', object_name='movies',
@ -560,7 +665,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_popular_movies(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_popular_movies(
self,
limit=1000,
years=None,
countries=None,
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',
object_name='movies', object_name='movies',
@ -573,7 +686,15 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_anticipated_movies(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_anticipated_movies(
self,
limit=1000,
years=None,
countries=None,
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',
object_name='movies', object_name='movies',
@ -585,8 +706,17 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_person_movies(self, person, limit=1000, years=None, countries=None, languages=None, genres=None, def get_person_movies(
include_non_acting_roles=False): self,
person,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
include_non_acting_roles=False,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/people/%s/movies' % person.replace(' ', '-').lower(), url='https://api.trakt.tv/people/%s/movies' % person.replace(' ', '-').lower(),
object_name='movies', object_name='movies',
@ -600,8 +730,16 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_played_movies(self, limit=1000, years=None, countries=None, languages=None, genres=None, def get_most_played_movies(
most_type=None): self,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
most_type=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/played/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/movies/played/%s' % ('weekly' if not most_type else most_type),
object_name='movies', object_name='movies',
@ -614,8 +752,16 @@ class Trakt:
) )
@cache(cache_file=cachefile, retry_if_blank=True) @cache(cache_file=cachefile, retry_if_blank=True)
def get_most_watched_movies(self, limit=1000, years=None, countries=None, languages=None, genres=None, def get_most_watched_movies(
most_type=None): self,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
most_type=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/watched/%s' % ('weekly' if not most_type else most_type), url='https://api.trakt.tv/movies/watched/%s' % ('weekly' if not most_type else most_type),
object_name='movies', object_name='movies',
@ -627,7 +773,15 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_boxoffice_movies(self, limit=1000, years=None, countries=None, languages=None, genres=None): def get_boxoffice_movies(
self,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/movies/boxoffice', url='https://api.trakt.tv/movies/boxoffice',
object_name='movies', object_name='movies',
@ -639,8 +793,16 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_recommended_movies(self, authenticate_user=None, limit=1000, years=None, countries=None, languages=None, def get_recommended_movies(
genres=None): self,
authenticate_user=None,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/recommendations/movies', url='https://api.trakt.tv/recommendations/movies',
object_name='movies', object_name='movies',
@ -653,8 +815,16 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_watchlist_movies(self, authenticate_user=None, limit=1000, years=None, countries=None, languages=None, def get_watchlist_movies(
genres=None): self,
authenticate_user=None,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
return self._make_items_request( return self._make_items_request(
url='https://api.trakt.tv/users/{authenticate_user}/watchlist/movies', url='https://api.trakt.tv/users/{authenticate_user}/watchlist/movies',
object_name='movies', object_name='movies',
@ -667,8 +837,17 @@ class Trakt:
genres=genres, genres=genres,
) )
def get_user_list_movies(self, list_url, authenticate_user=None, limit=1000, years=None, countries=None, def get_user_list_movies(
languages=None, genres=None): self,
list_url,
authenticate_user=None,
limit=1000,
years=None,
countries=None,
languages=None,
genres=None,
):
list_user, list_key = extract_list_user_and_key_from_url(list_url) list_user, list_key = extract_list_user_and_key_from_url(list_url)
log.debug('Fetching %s from %s', list_key, list_user) log.debug('Fetching %s from %s', list_key, list_user)

@ -176,7 +176,12 @@ def get_exclusions(pvr, pvr_type, notifications):
'--no-search', '--no-search',
is_flag=True, is_flag=True,
help='Disable search when adding show to Sonarr.') help='Disable search when adding show to Sonarr.')
def show(show_id, folder=None, no_search=False): def show(
show_id,
folder=None,
no_search=False,
):
from media.sonarr import Sonarr from media.sonarr import Sonarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import sonarr as sonarr_helper from helpers import sonarr as sonarr_helper
@ -238,7 +243,8 @@ def show(show_id, folder=None, no_search=False):
log.debug("Set series type for \'%s (%s)\' to: %s", series_title, series_year, series_type.title()) log.debug("Set series type for \'%s (%s)\' to: %s", series_title, series_year, series_type.title())
# add show to sonarr # add show to sonarr
if sonarr.add_series(trakt_show['ids']['tvdb'], if sonarr.add_series(
trakt_show['ids']['tvdb'],
series_title, series_title,
trakt_show['ids']['slug'], trakt_show['ids']['slug'],
quality_profile_id, quality_profile_id,
@ -246,7 +252,9 @@ def show(show_id, folder=None, no_search=False):
cfg.sonarr.root_folder, cfg.sonarr.root_folder,
use_tags, use_tags,
not no_search, not no_search,
series_type): series_type,
):
if profile_tags is not None and readable_tags is not None: if profile_tags is not None and readable_tags is not None:
log.info("ADDED: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year, log.info("ADDED: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year,
readable_tags) readable_tags)
@ -325,9 +333,22 @@ def show(show_id, folder=None, no_search=False):
'--remove-rejected-from-recommended', '--remove-rejected-from-recommended',
is_flag=True, is_flag=True,
help='Removes rejected/existing shows from recommended.') help='Removes rejected/existing shows from recommended.')
def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genres=None, folder=None, actor=None, no_search=False, def shows(
include_non_acting_roles=False, notifications=False, authenticate_user=None, ignore_blacklist=False, list_type,
remove_rejected_from_recommended=False): add_limit=0,
add_delay=2.5,
sort='votes',
genres=None,
folder=None,
actor=None,
no_search=False,
include_non_acting_roles=False,
notifications=False,
authenticate_user=None,
ignore_blacklist=False,
remove_rejected_from_recommended=False,
):
from media.sonarr import Sonarr from media.sonarr import Sonarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import str as misc_str from helpers import str as misc_str
@ -464,9 +485,12 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genres=None, fold
remove_rejected_from_recommended = False remove_rejected_from_recommended = False
# build filtered series list without series that exist in sonarr # build filtered series list without series that exist in sonarr
processed_series_list = sonarr_helper.remove_existing_series(pvr_objects_list, trakt_objects_list, processed_series_list = sonarr_helper.remove_existing_series(
callback_remove_recommended pvr_objects_list,
if remove_rejected_from_recommended else None) trakt_objects_list,
callback_remove_recommended if remove_rejected_from_recommended else None
)
if processed_series_list is None: if processed_series_list is None:
log.error("Aborting due to failure to remove existing Sonarr shows from retrieved Trakt shows list.") log.error("Aborting due to failure to remove existing Sonarr shows from retrieved Trakt shows list.")
if notifications: if notifications:
@ -529,9 +553,13 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genres=None, fold
continue continue
# check if series passes out blacklist criteria inspection # check if series passes out blacklist criteria inspection
if not trakt_helper.is_show_blacklisted(series, cfg.filters.shows, ignore_blacklist, if not trakt_helper.is_show_blacklisted(
callback_remove_recommended series,
if remove_rejected_from_recommended else None): cfg.filters.shows,
ignore_blacklist,
callback_remove_recommended if remove_rejected_from_recommended else None,
):
log.info("ADDING: %s (%s) | Country: %s | Language: %s | Genre(s): %s | Network: %s", log.info("ADDING: %s (%s) | Country: %s | Language: %s | Genre(s): %s | Network: %s",
series_title, series_title,
series_year, series_year,
@ -547,12 +575,19 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genres=None, fold
if profile_tags is not None: if profile_tags is not None:
# determine which tags to use when adding this series # determine which tags to use when adding this series
use_tags = sonarr_helper.series_tag_id_from_network(profile_tags, cfg.sonarr.tags, use_tags = sonarr_helper.series_tag_id_from_network(
series['show']['network']) profile_tags,
readable_tags = sonarr_helper.readable_tag_from_ids(profile_tags, use_tags) cfg.sonarr.tags,
series['show']['network'],
)
readable_tags = sonarr_helper.readable_tag_from_ids(
profile_tags,
use_tags,
)
# add show to sonarr # add show to sonarr
if sonarr.add_series(series['show']['ids']['tvdb'], if sonarr.add_series(
series['show']['ids']['tvdb'],
series_title, series_title,
series['show']['ids']['slug'], series['show']['ids']['slug'],
quality_profile_id, quality_profile_id,
@ -560,7 +595,9 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genres=None, fold
cfg.sonarr.root_folder, cfg.sonarr.root_folder,
use_tags, use_tags,
not no_search, not no_search,
series_type): series_type,
):
if profile_tags is not None and readable_tags is not None: if profile_tags is not None and readable_tags is not None:
log.info("ADDED: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year, log.info("ADDED: \'%s (%s)\' with Sonarr Tags: %s", series_title, series_year,
readable_tags) readable_tags)
@ -621,7 +658,13 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genres=None, fold
'--no-search', '--no-search',
is_flag=True, is_flag=True,
help='Disable search when adding movie to Radarr.') help='Disable search when adding movie to Radarr.')
def movie(movie_id, folder=None, minimum_availability=None, no_search=False): def movie(
movie_id,
folder=None,
minimum_availability=None,
no_search=False,
):
from media.radarr import Radarr from media.radarr import Radarr
from media.trakt import Trakt from media.trakt import Trakt
@ -663,14 +706,17 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
log.info("Retrieved Trakt movie information for \'%s\': \'%s (%s)\'", movie_id, trakt_movie['title'], movie_year) log.info("Retrieved Trakt movie information for \'%s\': \'%s (%s)\'", movie_id, trakt_movie['title'], movie_year)
# add movie to radarr # add movie to radarr
if radarr.add_movie(trakt_movie['ids']['tmdb'], if radarr.add_movie(
trakt_movie['ids']['tmdb'],
trakt_movie['title'], trakt_movie['title'],
trakt_movie['year'], trakt_movie['year'],
trakt_movie['ids']['slug'], trakt_movie['ids']['slug'],
quality_profile_id, quality_profile_id,
cfg.radarr.root_folder, cfg.radarr.root_folder,
cfg.radarr.minimum_availability, cfg.radarr.minimum_availability,
not no_search): not no_search,
):
log.info("ADDED \'%s (%s)\'", trakt_movie['title'], movie_year) log.info("ADDED \'%s (%s)\'", trakt_movie['title'], movie_year)
else: else:
log.error("FAILED ADDING \'%s (%s)\'", trakt_movie['title'], movie_year) log.error("FAILED ADDING \'%s (%s)\'", trakt_movie['title'], movie_year)
@ -749,9 +795,24 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
'--remove-rejected-from-recommended', '--remove-rejected-from-recommended',
is_flag=True, is_flag=True,
help='Removes rejected/existing movies from recommended.') help='Removes rejected/existing movies from recommended.')
def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rotten_tomatoes=None, genres=None, folder=None, def movies(
minimum_availability=None, actor=None, include_non_acting_roles=False, no_search=False, notifications=False, list_type,
authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False): add_limit=0,
add_delay=2.5,
sort='votes',
rotten_tomatoes=None,
genres=None,
folder=None,
minimum_availability=None,
actor=None,
include_non_acting_roles=False,
no_search=False,
notifications=False,
authenticate_user=None,
ignore_blacklist=False,
remove_rejected_from_recommended=False,
):
from media.radarr import Radarr from media.radarr import Radarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import misc as misc_helper from helpers import misc as misc_helper
@ -977,9 +1038,12 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rotten_tomatoes=
continue continue
# check if movie passes out blacklist criteria inspection # check if movie passes out blacklist criteria inspection
if not trakt_helper.is_movie_blacklisted(sorted_movie, cfg.filters.movies, ignore_blacklist, if not trakt_helper.is_movie_blacklisted(
callback_remove_recommended if remove_rejected_from_recommended sorted_movie,
else None): cfg.filters.movies,
ignore_blacklist,
callback_remove_recommended if remove_rejected_from_recommended else None,
):
# Skip movie if below user specified min RT score # Skip movie if below user specified min RT score
if rotten_tomatoes is not None and cfg.omdb.api_key: if rotten_tomatoes is not None and cfg.omdb.api_key:
@ -988,7 +1052,8 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rotten_tomatoes=
movie_title, movie_title,
movie_year, movie_year,
movie_imdb_id, movie_imdb_id,
rotten_tomatoes): rotten_tomatoes,
):
continue continue
log.info("ADDING: \'%s (%s)\' | Country: %s | Language: %s | Genre(s): %s ", log.info("ADDING: \'%s (%s)\' | Country: %s | Language: %s | Genre(s): %s ",
@ -996,17 +1061,20 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rotten_tomatoes=
movie_year, movie_year,
(sorted_movie['movie']['country'] or 'N/A').upper(), (sorted_movie['movie']['country'] or 'N/A').upper(),
(sorted_movie['movie']['language'] or 'N/A').upper(), (sorted_movie['movie']['language'] or 'N/A').upper(),
movie_genres) movie_genres,
)
# add movie to radarr # add movie to radarr
if radarr.add_movie(sorted_movie['movie']['ids']['tmdb'], if radarr.add_movie(
sorted_movie['movie']['ids']['tmdb'],
movie_title, movie_title,
movie_year, movie_year,
sorted_movie['movie']['ids']['slug'], sorted_movie['movie']['ids']['slug'],
quality_profile_id, quality_profile_id,
cfg.radarr.root_folder, cfg.radarr.root_folder,
cfg.radarr.minimum_availability, cfg.radarr.minimum_availability,
not no_search): not no_search,
):
log.info("ADDED: \'%s (%s)\'", movie_title, movie_year) log.info("ADDED: \'%s (%s)\'", movie_title, movie_year)
if notifications: if notifications:
@ -1106,7 +1174,14 @@ def callback_notify(data):
############################################################ ############################################################
def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=False, ignore_blacklist=False): def automatic_shows(
add_delay=2.5,
sort='votes',
no_search=False,
notifications=False,
ignore_blacklist=False,
):
from media.trakt import Trakt from media.trakt import Trakt
total_shows_added = 0 total_shows_added = 0
@ -1140,9 +1215,16 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
local_ignore_blacklist = True local_ignore_blacklist = True
# run shows # run shows
added_shows = shows.callback(list_type=list_type, add_limit=limit, added_shows = shows.callback(
add_delay=add_delay, sort=sort, no_search=no_search, list_type=list_type,
notifications=notifications, ignore_blacklist=local_ignore_blacklist) add_limit=limit,
add_delay=add_delay,
sort=sort,
no_search=no_search,
notifications=notifications,
ignore_blacklist=local_ignore_blacklist,
)
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':
for authenticate_user, limit in value.items(): for authenticate_user, limit in value.items():
if limit <= 0: if limit <= 0:
@ -1158,10 +1240,17 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
local_ignore_blacklist = True local_ignore_blacklist = True
# run shows # run shows
added_shows = shows.callback(list_type=list_type, add_limit=limit, added_shows = shows.callback(
add_delay=add_delay, sort=sort, no_search=no_search, list_type=list_type,
notifications=notifications, authenticate_user=authenticate_user, add_limit=limit,
ignore_blacklist=local_ignore_blacklist) add_delay=add_delay,
sort=sort,
no_search=no_search,
notifications=notifications,
authenticate_user=authenticate_user,
ignore_blacklist=local_ignore_blacklist,
)
elif list_type.lower() == 'lists': elif list_type.lower() == 'lists':
if len(value.items()) == 0: if len(value.items()) == 0:
@ -1186,10 +1275,16 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
local_ignore_blacklist = True local_ignore_blacklist = True
# run shows # run shows
added_shows = shows.callback(list_type=list_, add_limit=limit, added_shows = shows.callback(
add_delay=add_delay, sort=sort, no_search=no_search, list_type=list_,
notifications=notifications, authenticate_user=authenticate_user, add_limit=limit,
ignore_blacklist=local_ignore_blacklist) add_delay=add_delay,
sort=sort,
no_search=no_search,
notifications=notifications,
authenticate_user=authenticate_user,
ignore_blacklist=local_ignore_blacklist,
)
if added_shows is None: if added_shows is None:
if not list_type.lower() == 'lists': if not list_type.lower() == 'lists':
@ -1211,8 +1306,15 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
return return
def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications=False, ignore_blacklist=False, def automatic_movies(
rotten_tomatoes=None): add_delay=2.5,
sort='votes',
no_search=False,
notifications=False,
ignore_blacklist=False,
rotten_tomatoes=None,
):
from media.trakt import Trakt from media.trakt import Trakt
total_movies_added = 0 total_movies_added = 0
@ -1246,10 +1348,17 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
local_ignore_blacklist = True local_ignore_blacklist = True
# run movies # run movies
added_movies = movies.callback(list_type=list_type, add_limit=limit, added_movies = movies.callback(
add_delay=add_delay, sort=sort, no_search=no_search, list_type=list_type,
notifications=notifications, ignore_blacklist=local_ignore_blacklist, add_limit=limit,
rotten_tomatoes=rotten_tomatoes) add_delay=add_delay,
sort=sort,
no_search=no_search,
notifications=notifications,
ignore_blacklist=local_ignore_blacklist,
rotten_tomatoes=rotten_tomatoes,
)
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':
for authenticate_user, limit in value.items(): for authenticate_user, limit in value.items():
if limit <= 0: if limit <= 0:
@ -1265,11 +1374,18 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
local_ignore_blacklist = True local_ignore_blacklist = True
# run movies # run movies
added_movies = movies.callback(list_type=list_type, add_limit=limit, added_movies = movies.callback(
add_delay=add_delay, sort=sort, no_search=no_search, list_type=list_type,
notifications=notifications, authenticate_user=authenticate_user, add_limit=limit,
add_delay=add_delay,
sort=sort,
no_search=no_search,
otifications=notifications,
authenticate_user=authenticate_user,
ignore_blacklist=local_ignore_blacklist, ignore_blacklist=local_ignore_blacklist,
rotten_tomatoes=rotten_tomatoes) rotten_tomatoes=rotten_tomatoes,
)
elif list_type.lower() == 'lists': elif list_type.lower() == 'lists':
if len(value.items()) == 0: if len(value.items()) == 0:
@ -1294,11 +1410,17 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
local_ignore_blacklist = True local_ignore_blacklist = True
# run shows # run shows
added_movies = movies.callback(list_type=list_, add_limit=limit, added_movies = movies.callback(
add_delay=add_delay, sort=sort, no_search=no_search, list_type=list_,
notifications=notifications, authenticate_user=authenticate_user, add_limit=limit,
add_delay=add_delay,
sort=sort,
no_search=no_search,
notifications=notifications,
authenticate_user=authenticate_user,
ignore_blacklist=local_ignore_blacklist, ignore_blacklist=local_ignore_blacklist,
rotten_tomatoes=rotten_tomatoes) rotten_tomatoes=rotten_tomatoes,
)
if added_movies is None: if added_movies is None:
if not list_type.lower() == 'lists': if not list_type.lower() == 'lists':
@ -1348,7 +1470,15 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
'--ignore-blacklist', '--ignore-blacklist',
is_flag=True, is_flag=True,
help='Ignores the blacklist when running the command.') help='Ignores the blacklist when running the command.')
def run(add_delay=2.5, sort='votes', no_search=False, run_now=False, no_notifications=False, ignore_blacklist=False): def run(
add_delay=2.5,
sort='votes',
no_search=False,
run_now=False,
no_notifications=False,
ignore_blacklist=False,
):
log.info("Automatic mode is now running.") log.info("Automatic mode is now running.")
# send notification # send notification

Loading…
Cancel
Save