Ratings: Precisely log when no RT score is found.

pull/93/head
desimaniac 6 years ago
parent c1a42c636c
commit 295a854b0a

@ -7,6 +7,7 @@ log = logger.get_logger(__name__)
def get_rating(apikey, movie): def get_rating(apikey, movie):
ratings_exist = False
imdb_id = movie['movie']['ids']['imdb'] imdb_id = movie['movie']['ids']['imdb']
if imdb_id: if imdb_id:
log.debug("Requesting info from OMDB for %s (%d) | Genres: %s | Country: %s | IMDB ID: %s", 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) ', '.join(movie['movie']['genres']), (movie['movie']['country'] or 'N/A').upper(), imdb_id)
for source in json.loads(r.text)["Ratings"]: for source in json.loads(r.text)["Ratings"]:
if source['Source'] == 'Rotten Tomatoes': 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 ", 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'], source['Value'], movie['movie']['title'], movie['movie']['year'],
', '.join(movie['movie']['genres']), (movie['movie']['country'] or 'N/A').upper(), ', '.join(movie['movie']['genres']), (movie['movie']['country'] or 'N/A').upper(),
imdb_id) imdb_id)
return int(source['Value'].split('%')[0]) 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: else:
log.debug("Error encountered when requesting ratings from OMDB for %s (%d) | Genres: %s | Country: %s" + 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'], " | IMDB ID: %s", movie['movie']['title'], movie['movie']['year'],

@ -532,7 +532,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
# display specified RT score # display specified RT score
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']:
log.debug("Minimum Rotten Tomatoes score specified: %s%%", rating) log.debug("Minimum Rotten Tomatoes score of %d%% requested.", rating)
# loop movies # loop movies
log.info("Processing list now...") 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']: 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) movie_rating = rating_helper.get_rating(cfg['omdb']['api_key'], sorted_movie)
if movie_rating == -1: if movie_rating == -1:
log.debug("Skipping: %s because it did not have a Rotten Tomatoes rating/lacked IMDB ID", log.info("SKIPPED %s (%d)", sorted_movie['movie']['title'], sorted_movie['movie']['year'])
sorted_movie['movie']['title'])
continue continue
if (rating is None or movie_rating is None) or movie_rating >= rating: 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'], 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'], log.error("FAILED adding %s (%d)", sorted_movie['movie']['title'],
sorted_movie['movie']['year']) sorted_movie['movie']['year'])
else: else:
log.info("Minimum Rotten Tomatoes score was not met. " + log.debug("Minimum Rotten Tomatoes score of %d%% was not met.", rating)
"Skipping: %s (%d) | Genres: %s | Country: %s", sorted_movie['movie']['title'], log.info("SKIPPED %s (%d)", sorted_movie['movie']['title'], sorted_movie['movie']['year'])
sorted_movie['movie']['year'], ', '.join(sorted_movie['movie']['genres']),
(sorted_movie['movie']['country'] or 'N/A').upper())
# stop adding movies, if added_movies >= add_limit # stop adding movies, if added_movies >= add_limit
if add_limit and added_movies >= add_limit: if add_limit and added_movies >= add_limit:
break break

Loading…
Cancel
Save