Ratings: Use common variables to pass into function

pull/105/head
desimaniac 5 years ago
parent e0a6caebc1
commit 805adc0ede

@ -57,12 +57,7 @@ def get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id):
return False return False
def does_movie_have_min_req_rating(omdb_api_key, sorted_movie, req_rating): def does_movie_have_min_req_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id, req_rating):
movie_title = sorted_movie['movie']['title']
movie_year = str(sorted_movie['movie']['year']) \
if sorted_movie['movie']['year'] else '????'
movie_imdb_id = sorted_movie['movie']['ids']['imdb']
# pull RT score # pull RT score
movie_rating = get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id) movie_rating = get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id)

@ -212,8 +212,7 @@ 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: if profile_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)
@ -479,8 +478,7 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde
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: if profile_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)
@ -589,8 +587,7 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False):
profile_id, 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)
@ -816,6 +813,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
# set common series variables # set common series variables
movie_title = sorted_movie['movie']['title'] movie_title = sorted_movie['movie']['title']
movie_tmdb_id = sorted_movie['movie']['ids']['tmdb'] movie_tmdb_id = sorted_movie['movie']['ids']['tmdb']
movie_imdb_id = sorted_movie['movie']['ids']['imdb']
# convert movie year to string # convert movie year to string
movie_year = str(sorted_movie['movie']['year']) \ movie_year = str(sorted_movie['movie']['year']) \
@ -843,7 +841,12 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
# Skip movie if below user specified min RT rating # Skip movie if below user specified min RT rating
if rating is not None and 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']: if rating is not None and 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']:
if not rating_helper.does_movie_have_min_req_rating(cfg['omdb']['api_key'], sorted_movie, rating): if not rating_helper.does_movie_have_min_req_rating(
cfg['omdb']['api_key'],
movie_title,
movie_year,
movie_imdb_id,
rating):
continue continue
log.info("ADDING: \'%s (%s)\' | Country: %s | Language: %s | Genre: %s ", log.info("ADDING: \'%s (%s)\' | Country: %s | Language: %s | Genre: %s ",
@ -851,8 +854,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
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'],
@ -862,8 +864,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
profile_id, 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:
@ -1048,7 +1049,7 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
# sleep # sleep
time.sleep(10) time.sleep(10)
log.info("Finished, added %d show(s) total to Sonarr!", total_shows_added) log.info("FINISHED: Added %d show(s) total to Sonarr!", total_shows_added)
# send notification # send notification
if notifications and (cfg.notifications.verbose or total_shows_added > 0): if notifications and (cfg.notifications.verbose or total_shows_added > 0):
notify.send(message="Added %d show(s) total to Sonarr!" % total_shows_added) notify.send(message="Added %d show(s) total to Sonarr!" % total_shows_added)
@ -1100,7 +1101,7 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
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:
log.info("Skipped Trakt user \'%s\''s \'%s\'", authenticate_user, list_type.capitalize) log.info("SKIPPED Trakt user \'%s\''s \'%s\'", authenticate_user, list_type.capitalize)
continue continue
else: else:
log.info("ADDING %d movie(s) from Trakt user \'%s\''s \'%s\'", limit, log.info("ADDING %d movie(s) from Trakt user \'%s\''s \'%s\'", limit,
@ -1145,7 +1146,7 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
# sleep # sleep
time.sleep(10) time.sleep(10)
log.info("Finished, added %d movie(s) total to Radarr!", total_movies_added) log.info("FINISHED: Added %d movie(s) total to Radarr!", total_movies_added)
# send notification # send notification
if notifications and (cfg.notifications.verbose or total_movies_added > 0): if notifications and (cfg.notifications.verbose or total_movies_added > 0):
notify.send(message="Added %d movie(s) total to Radarr!" % total_movies_added) notify.send(message="Added %d movie(s) total to Radarr!" % total_movies_added)

Loading…
Cancel
Save