From 62746f2f7a130d6f1fda45146622a1efa91ec4e3 Mon Sep 17 00:00:00 2001 From: desimaniac <5501908+desimaniac@users.noreply.github.com> Date: Fri, 27 Sep 2019 12:51:26 -0500 Subject: [PATCH] OMDB: Renamed ratings to rotten_tomatoes. --- README.md | 22 +++++++++++--------- helpers/{rating.py => omdb.py} | 16 +++++++------- misc/config.py | 2 +- sample/config.json | 10 ++++----- traktarr.py | 38 ++++++++++++++++++++-------------- 5 files changed, 47 insertions(+), 41 deletions(-) rename helpers/{rating.py => omdb.py} (82%) diff --git a/README.md b/README.md index 913d75d..02ab983 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,9 @@ You can repeat this process for as many users as you like. "gb", "ca" ], - "allowed_languages": [], + "allowed_languages": [ + "en" + ], "blacklist_title_keywords": [ "untitled", "barbie", @@ -261,7 +263,7 @@ You can repeat this process for as many users as you like. "blacklisted_min_runtime": 60, "blacklisted_min_year": 2000, "blacklisted_tmdb_ids": [], - "rating_limit": "" + "rotten_tomatoes": "" }, "shows": { "disabled_for": [], @@ -547,7 +549,7 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi "blacklisted_min_runtime": 60, "blacklisted_min_year": 2000, "blacklisted_tmdb_ids": [], - "rating_limit": "" + "rotten_tomatoes": "" }, ``` @@ -618,7 +620,7 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi ], ``` -`rating_limit` - Only add movies that are equal to or above this Rotten Tomatoes score. Requires an OMDb API Key (see [below](#omdb)). +`rotten_tomatoes` - Only add movies that are equal to or above this Rotten Tomatoes score. Requires an OMDb API Key (see [below](#omdb)). ### Shows @@ -1010,7 +1012,7 @@ Trakt Authentication info: - This is only needed if you wish to use a minimum Rotten Tomatoes score to filter out movies. -- Use `rating_limit` in config for automatic scheduling or `--rating` as an argument for CLI. +- Use `rotten_tomatoes` in config for automatic scheduling or `--rotten_tomatoes` as an argument for CLI. # Usage @@ -1171,7 +1173,7 @@ Options: -d, --add-delay FLOAT Seconds between each add request to Radarr. [default: 2.5] -s, --sort [rating|release|votes] Sort list to process. [default: votes] - -r, --rating INTEGER Set a minimum Rotten Tomatoes score. + -rt, --rotten_tomatoes INTEGER Set a minimum Rotten Tomatoes score. -g, --genre TEXT Only add movies from this genre to Radarr. Only one genre can be specified. Use 'ignore' to add movies from any genre, including @@ -1227,9 +1229,9 @@ Options: - Example: `-s release` -`-r`, `--rating` - Only add movies above this Rotten Tomatoes score. +`-rt`, `--rotten_tomatoes` - Only add movies equal to or above this Rotten Tomatoes score. - - Example: `-r 75` + - Example: `-rt 75` `-g`, `--genre` - Only add movies from this genre to Radarr. @@ -1435,10 +1437,10 @@ Options: traktarr movies -t https://trakt.tv/users/user1/lists/private-movies-list --authenticate-user=user1 ``` -- Add movies, from the trending list, with a minimum rating of 80% on Rotten Tomatoes. +- Add movies, from the trending list, with a minimum Rotten Tomatoes score of 80%. ``` - traktarr movies -t trending -r 80 + traktarr movies -t trending -rt 80 ``` - Add movies, with actor 'Keanu Reeves', limited to 10 items. diff --git a/helpers/rating.py b/helpers/omdb.py similarity index 82% rename from helpers/rating.py rename to helpers/omdb.py index c425956..4a57b71 100644 --- a/helpers/rating.py +++ b/helpers/omdb.py @@ -5,7 +5,7 @@ import requests log = logger.get_logger(__name__) -def get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id): +def get_movie_rt_score(omdb_api_key, movie_title, movie_year, movie_imdb_id): """ Lookup movie ratings via OMDb @@ -57,20 +57,20 @@ def get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id): return False -def does_movie_have_min_req_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id, req_rating): +def does_movie_have_min_req_rt_score(omdb_api_key, movie_title, movie_year, movie_imdb_id, min_req_rt_score): # pull RT score - movie_rating = get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id) + movie_rt_score = get_movie_rt_score(omdb_api_key, movie_title, movie_year, movie_imdb_id) - if not movie_rating: + if not movie_rt_score: log.info("SKIPPING: \'%s (%s)\' because a Rotten Tomatoes score could not be found.", movie_title, movie_year) return False - elif movie_rating < req_rating: + elif movie_rt_score < min_req_rt_score: log.info("SKIPPING: \'%s (%s)\' because its Rotten Tomatoes score of %d%% is below the required score of %d%%.", - movie_title, movie_year, movie_rating, req_rating) + movie_title, movie_year, movie_rt_score, min_req_rt_score) return False - elif movie_rating >= req_rating: + elif movie_rt_score >= min_req_rt_score: log.info("ADDING: \'%s (%s)\' because its Rotten Tomatoes score of %d%% is above the required score of %d%%.", - movie_title, movie_year, movie_rating, req_rating) + movie_title, movie_year, movie_rt_score, min_req_rt_score) return True diff --git a/misc/config.py b/misc/config.py index 1a1895e..45fa4d4 100644 --- a/misc/config.py +++ b/misc/config.py @@ -81,7 +81,7 @@ class Config(object, metaclass=Singleton): 'blacklisted_tmdb_ids': [], 'allowed_countries': [], 'allowed_languages': [], - 'rating_limit':"" + 'rotten_tomatoes':"" } }, 'automatic': { diff --git a/sample/config.json b/sample/config.json index fc59147..7228b89 100644 --- a/sample/config.json +++ b/sample/config.json @@ -67,7 +67,9 @@ "gb", "ca" ], - "allowed_languages": [], + "allowed_languages": [ + "en" + ], "blacklisted_genres": [ "documentary", "music", @@ -84,11 +86,7 @@ "blacklisted_min_runtime": 60, "blacklisted_min_year": 2000, "blacklisted_max_year": 2019, - "allowed_countries": [ - "us", - "gb", - "ca" - ], + "rotten_tomatoes": 80, "disabled_for": [] } }, diff --git a/traktarr.py b/traktarr.py index cb62d57..4febce7 100755 --- a/traktarr.py +++ b/traktarr.py @@ -51,6 +51,10 @@ def app(config, cachefile, logfile): from misc.config import Config cfg = Config(configfile=config, cachefile=cachefile, logfile=logfile).cfg + # Legacy Support + if cfg.filters.movies.rating_limit: + cfg['filters']['movies']['rotten_tomatoes'] = cfg['filters']['movies']['rating_limit'] + # Load logger from misc.log import logger log = logger.get_logger('Traktarr') @@ -617,7 +621,7 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False): type=click.Choice(['rating', 'release', 'votes']), help='Sort list to process.', show_default=True) @click.option( - '--rating', '-r', + '--rotten_tomatoes', '-rt', default=None, type=int, help='Set a minimum Rotten Tomatoes score.') @@ -666,7 +670,7 @@ def movie(movie_id, folder=None, minimum_availability=None, no_search=False): '--remove-rejected-from-recommended', is_flag=True, help='Removes rejected/existing movies from recommended.') -def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, genre=None, folder=None, +def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rotten_tomatoes=None, genre=None, folder=None, minimum_availability=None, actor=None, include_non_acting_roles=False, no_search=False, notifications=False, authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False): from media.radarr import Radarr @@ -674,7 +678,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen from helpers import misc as misc_helper from helpers import radarr as radarr_helper from helpers import trakt as trakt_helper - from helpers import rating as rating_helper + from helpers import omdb as omdb_helper from helpers import tmdb as tmdb_helper added_movies = 0 @@ -799,9 +803,9 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen log.info("Sorted movies list to process by highest 'votes'") # display specified min RT score - if rating is not None: - if 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']: - log.info("Minimum Rotten Tomatoes score of %d%% requested.", rating) + if rotten_tomatoes is not None: + if cfg.omdb.api_key: + log.info("Minimum Rotten Tomatoes score of %d%% requested.", rotten_tomatoes) else: log.info("Skipping minimum Rotten Tomatoes score check as OMDb API Key is missing.") @@ -839,14 +843,14 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen callback_remove_recommended if remove_rejected_from_recommended else None): - # 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 not rating_helper.does_movie_have_min_req_rating( - cfg['omdb']['api_key'], + # Skip movie if below user specified min RT score + if rotten_tomatoes is not None and cfg.omdb.api_key: + if not omdb_helper.does_movie_have_min_req_rt_score( + cfg.omdb.api_key, movie_title, movie_year, movie_imdb_id, - rating): + rotten_tomatoes): continue log.info("ADDING: \'%s (%s)\' | Country: %s | Language: %s | Genre: %s ", @@ -1060,7 +1064,7 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications= def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications=False, ignore_blacklist=False, - rating_limit=None): + rotten_tomatoes=None): from media.trakt import Trakt total_movies_added = 0 @@ -1097,7 +1101,7 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications added_movies = movies.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, sort=sort, no_search=no_search, notifications=notifications, ignore_blacklist=local_ignore_blacklist, - rating=rating_limit) + rotten_tomatoes=rotten_tomatoes) elif list_type.lower() == 'watchlist': for authenticate_user, limit in value.items(): if limit <= 0: @@ -1116,7 +1120,8 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications added_movies = movies.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, sort=sort, no_search=no_search, notifications=notifications, authenticate_user=authenticate_user, - ignore_blacklist=local_ignore_blacklist, rating=rating_limit) + ignore_blacklist=local_ignore_blacklist, + rotten_tomatoes=rotten_tomatoes) elif list_type.lower() == 'lists': for list_, v in value.items(): if isinstance(v, dict): @@ -1135,7 +1140,8 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications added_movies = movies.callback(list_type=list_, add_limit=limit, add_delay=add_delay, sort=sort, no_search=no_search, notifications=notifications, authenticate_user=authenticate_user, - ignore_blacklist=local_ignore_blacklist, rating=rating_limit) + ignore_blacklist=local_ignore_blacklist, + rotten_tomatoes=rotten_tomatoes) if added_movies is None: log.error("FAILED ADDING movies from Trakt's \'%s\' list", list_type.capitalize()) @@ -1200,7 +1206,7 @@ def run(add_delay=2.5, sort='votes', no_search=False, run_now=False, no_notifica no_search, not no_notifications, ignore_blacklist, - int(cfg.filters.movies.rating_limit) if cfg.filters.movies.rating_limit != "" else None + int(cfg.filters.movies.rotten_tomatoes) if cfg.filters.movies.rotten_tomatoes != "" else None, ) if run_now: movie_schedule.run()