diff --git a/helpers/rating.py b/helpers/rating.py index fd42d3a..15e4283 100644 --- a/helpers/rating.py +++ b/helpers/rating.py @@ -3,16 +3,24 @@ import json import requests log = logger.get_logger(__name__) -def get_rating(apikey,imdbID): - log.debug("Requesting ratings from omdb for imdbID: %s",imdbID) +def get_rating(apikey,movie): + imdbID = movie['movie']['ids']['imdb'] + + log.debug("Requesting ratings from OMDB for %s (%d) | Genres: %s | Country: %s | imdbID: %s",movie['movie']['title'], movie['movie']['year'], + ', '.join(movie['movie']['genres']), movie['movie']['country'].upper(),imdbID) r = requests.get('http://www.omdbapi.com/?i=' + imdbID + '&apikey=' + apikey) if(r.status_code == 200): - log.debug("Successfully requested ratings from OMDB") + log.debug("Successfully requested ratings from OMDB for %s (%d) | Genres: %s | Country: %s | imdbID: %s", + movie['movie']['title'], movie['movie']['year'], + ', '.join(movie['movie']['genres']), movie['movie']['country'].upper(), imdbID) for source in json.loads(r.text)["Ratings"]: if(source['Source'] == 'Rotten Tomatoes'): - log.debug("Rotten Tomatoes shows rating: %s for imdbID: %s",source['Value'],imdbID) + log.debug("Rotten Tomatoes shows rating: %s for %s (%d) | Genres: %s | Country: %s | imdbID: %s ",source['Value'],movie['movie']['title'], movie['movie']['year'], + ', '.join(movie['movie']['genres']), movie['movie']['country'].upper(),imdbID) return int(source['Value'].split('%')[0]) else: - log.error("ERROR encountered while requesting rating for imdbID: %s Status Code: %d",imdbID,r.status_code) + log.debug("Error encountered when requesting ratings from OMDB for %s (%d) | Genres: %s | Country: %s | imdbID: %s", + movie['movie']['title'], movie['movie']['year'], + ', '.join(movie['movie']['genres']), movie['movie']['country'].upper(), imdbID) return -1 diff --git a/traktarr.py b/traktarr.py index 16ec748..b2251e2 100755 --- a/traktarr.py +++ b/traktarr.py @@ -523,7 +523,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=0, genre= # Assuming the movie is not blacklisted, proceed to pull RT score if the user wishes to restrict movieRating = None if (rating and cfg['omdb']['api_key'] != ''): - movieRating = rating_helper.get_rating(cfg['omdb']['api_key'], movie['movie']['ids']['imdb']) + movieRating = rating_helper.get_rating(cfg['omdb']['api_key'],movie) if (movieRating == -1): log.debug("Skipping: %s because it did not have a rating/lacked imdbID", movie['movie']['title'])