From 295a854b0a02f099b9d305ef4bbd4a189d5c196a Mon Sep 17 00:00:00 2001 From: desimaniac <5501908+desimaniac@users.noreply.github.com> Date: Fri, 14 Jun 2019 11:54:04 -0500 Subject: [PATCH] Ratings: Precisely log when no RT score is found. --- helpers/rating.py | 9 ++++++++- traktarr.py | 11 ++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/helpers/rating.py b/helpers/rating.py index 0bf601a..5eeb706 100644 --- a/helpers/rating.py +++ b/helpers/rating.py @@ -7,6 +7,7 @@ log = logger.get_logger(__name__) def get_rating(apikey, movie): + ratings_exist = False imdb_id = movie['movie']['ids']['imdb'] if imdb_id: log.debug("Requesting info from OMDB for %s (%d) | Genres: %s | Country: %s | IMDB ID: %s", @@ -19,11 +20,17 @@ def get_rating(apikey, movie): ', '.join(movie['movie']['genres']), (movie['movie']['country'] or 'N/A').upper(), imdb_id) for source in json.loads(r.text)["Ratings"]: if source['Source'] == 'Rotten Tomatoes': + # noinspection PyUnusedLocal + ratings_exist = True log.debug("Rotten Tomatoes score of %s for %s (%d) | Genres: %s | Country: %s | IMDB ID: %s ", source['Value'], movie['movie']['title'], movie['movie']['year'], ', '.join(movie['movie']['genres']), (movie['movie']['country'] or 'N/A').upper(), imdb_id) return int(source['Value'].split('%')[0]) + if not ratings_exist: + log.debug("No Rotten Tomatoes score found for %s (%d) | Genres: %s | Country: %s | IMDB ID: %s ", + movie['movie']['title'], movie['movie']['year'], ', '.join(movie['movie']['genres']), + (movie['movie']['country'] or 'N/A').upper(), imdb_id) else: log.debug("Error encountered when requesting ratings from OMDB for %s (%d) | Genres: %s | Country: %s" + " | IMDB ID: %s", movie['movie']['title'], movie['movie']['year'], @@ -33,4 +40,4 @@ def get_rating(apikey, movie): movie['movie']['title'], movie['movie']['year'], ', '.join(movie['movie']['genres']), (movie['movie']['country'] or 'N/A').upper()) - return -1 + return -1 \ No newline at end of file diff --git a/traktarr.py b/traktarr.py index 3d44cd4..57a290d 100755 --- a/traktarr.py +++ b/traktarr.py @@ -532,7 +532,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen # display specified RT score if rating is not None and 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']: - log.debug("Minimum Rotten Tomatoes score specified: %s%%", rating) + log.debug("Minimum Rotten Tomatoes score of %d%% requested.", rating) # loop movies log.info("Processing list now...") @@ -554,8 +554,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen if rating is not None and 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']: movie_rating = rating_helper.get_rating(cfg['omdb']['api_key'], sorted_movie) if movie_rating == -1: - log.debug("Skipping: %s because it did not have a Rotten Tomatoes rating/lacked IMDB ID", - sorted_movie['movie']['title']) + log.info("SKIPPED %s (%d)", sorted_movie['movie']['title'], sorted_movie['movie']['year']) continue if (rating is None or movie_rating is None) or movie_rating >= rating: log.info("Adding: %s (%d) | Genres: %s | Country: %s", sorted_movie['movie']['title'], @@ -574,10 +573,8 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen log.error("FAILED adding %s (%d)", sorted_movie['movie']['title'], sorted_movie['movie']['year']) else: - log.info("Minimum Rotten Tomatoes score was not met. " + - "Skipping: %s (%d) | Genres: %s | Country: %s", sorted_movie['movie']['title'], - sorted_movie['movie']['year'], ', '.join(sorted_movie['movie']['genres']), - (sorted_movie['movie']['country'] or 'N/A').upper()) + log.debug("Minimum Rotten Tomatoes score of %d%% was not met.", rating) + log.info("SKIPPED %s (%d)", sorted_movie['movie']['title'], sorted_movie['movie']['year']) # stop adding movies, if added_movies >= add_limit if add_limit and added_movies >= add_limit: break