From a906b361ec19d744bb677688102e1d5f3c41d550 Mon Sep 17 00:00:00 2001 From: "davidaghaian@student.cccd.edu" Date: Sat, 4 Aug 2018 15:06:34 -0700 Subject: [PATCH] Pass entire move object instead of just ID for logging purposes --- helpers/rating.py | 18 +++++++++++++----- traktarr.py | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) 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'])