OMDB: Renamed ratings to rotten_tomatoes.

pull/105/head
desimaniac 5 years ago
parent 805adc0ede
commit 62746f2f7a

@ -246,7 +246,9 @@ You can repeat this process for as many users as you like.
"gb", "gb",
"ca" "ca"
], ],
"allowed_languages": [], "allowed_languages": [
"en"
],
"blacklist_title_keywords": [ "blacklist_title_keywords": [
"untitled", "untitled",
"barbie", "barbie",
@ -261,7 +263,7 @@ You can repeat this process for as many users as you like.
"blacklisted_min_runtime": 60, "blacklisted_min_runtime": 60,
"blacklisted_min_year": 2000, "blacklisted_min_year": 2000,
"blacklisted_tmdb_ids": [], "blacklisted_tmdb_ids": [],
"rating_limit": "" "rotten_tomatoes": ""
}, },
"shows": { "shows": {
"disabled_for": [], "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_runtime": 60,
"blacklisted_min_year": 2000, "blacklisted_min_year": 2000,
"blacklisted_tmdb_ids": [], "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 ### 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. - 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 # Usage
@ -1171,7 +1173,7 @@ Options:
-d, --add-delay FLOAT Seconds between each add request to Radarr. [default: 2.5] -d, --add-delay FLOAT Seconds between each add request to Radarr. [default: 2.5]
-s, --sort [rating|release|votes] -s, --sort [rating|release|votes]
Sort list to process. [default: 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 -g, --genre TEXT Only add movies from this genre to Radarr. Only one genre can be
specified. specified.
Use 'ignore' to add movies from any genre, including Use 'ignore' to add movies from any genre, including
@ -1227,9 +1229,9 @@ Options:
- Example: `-s release` - 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. `-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 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. - Add movies, with actor 'Keanu Reeves', limited to 10 items.

@ -5,7 +5,7 @@ import requests
log = logger.get_logger(__name__) 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 Lookup movie ratings via OMDb
@ -57,20 +57,20 @@ def get_rating(omdb_api_key, movie_title, movie_year, movie_imdb_id):
return False 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 # 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, log.info("SKIPPING: \'%s (%s)\' because a Rotten Tomatoes score could not be found.", movie_title,
movie_year) movie_year)
return False 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%%.", 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 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%%.", 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 return True

@ -81,7 +81,7 @@ class Config(object, metaclass=Singleton):
'blacklisted_tmdb_ids': [], 'blacklisted_tmdb_ids': [],
'allowed_countries': [], 'allowed_countries': [],
'allowed_languages': [], 'allowed_languages': [],
'rating_limit':"" 'rotten_tomatoes':""
} }
}, },
'automatic': { 'automatic': {

@ -67,7 +67,9 @@
"gb", "gb",
"ca" "ca"
], ],
"allowed_languages": [], "allowed_languages": [
"en"
],
"blacklisted_genres": [ "blacklisted_genres": [
"documentary", "documentary",
"music", "music",
@ -84,11 +86,7 @@
"blacklisted_min_runtime": 60, "blacklisted_min_runtime": 60,
"blacklisted_min_year": 2000, "blacklisted_min_year": 2000,
"blacklisted_max_year": 2019, "blacklisted_max_year": 2019,
"allowed_countries": [ "rotten_tomatoes": 80,
"us",
"gb",
"ca"
],
"disabled_for": [] "disabled_for": []
} }
}, },

@ -51,6 +51,10 @@ def app(config, cachefile, logfile):
from misc.config import Config from misc.config import Config
cfg = Config(configfile=config, cachefile=cachefile, logfile=logfile).cfg 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 # Load logger
from misc.log import logger from misc.log import logger
log = logger.get_logger('Traktarr') 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']), type=click.Choice(['rating', 'release', 'votes']),
help='Sort list to process.', show_default=True) help='Sort list to process.', show_default=True)
@click.option( @click.option(
'--rating', '-r', '--rotten_tomatoes', '-rt',
default=None, default=None,
type=int, type=int,
help='Set a minimum Rotten Tomatoes score.') 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', '--remove-rejected-from-recommended',
is_flag=True, is_flag=True,
help='Removes rejected/existing movies from recommended.') 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, 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): authenticate_user=None, ignore_blacklist=False, remove_rejected_from_recommended=False):
from media.radarr import Radarr 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 misc as misc_helper
from helpers import radarr as radarr_helper from helpers import radarr as radarr_helper
from helpers import trakt as trakt_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 from helpers import tmdb as tmdb_helper
added_movies = 0 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'") log.info("Sorted movies list to process by highest 'votes'")
# display specified min RT score # display specified min RT score
if rating is not None: if rotten_tomatoes is not None:
if 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']: if cfg.omdb.api_key:
log.info("Minimum Rotten Tomatoes score of %d%% requested.", rating) log.info("Minimum Rotten Tomatoes score of %d%% requested.", rotten_tomatoes)
else: else:
log.info("Skipping minimum Rotten Tomatoes score check as OMDb API Key is missing.") 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 callback_remove_recommended if remove_rejected_from_recommended
else None): else None):
# Skip movie if below user specified min RT rating # Skip movie if below user specified min RT score
if rating is not None and 'omdb' in cfg and 'api_key' in cfg['omdb'] and cfg['omdb']['api_key']: if rotten_tomatoes is not None and cfg.omdb.api_key:
if not rating_helper.does_movie_have_min_req_rating( if not omdb_helper.does_movie_have_min_req_rt_score(
cfg['omdb']['api_key'], cfg.omdb.api_key,
movie_title, movie_title,
movie_year, movie_year,
movie_imdb_id, movie_imdb_id,
rating): rotten_tomatoes):
continue continue
log.info("ADDING: \'%s (%s)\' | Country: %s | Language: %s | Genre: %s ", 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, 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 from media.trakt import Trakt
total_movies_added = 0 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, added_movies = movies.callback(list_type=list_type, add_limit=limit,
add_delay=add_delay, sort=sort, no_search=no_search, add_delay=add_delay, sort=sort, no_search=no_search,
notifications=notifications, ignore_blacklist=local_ignore_blacklist, notifications=notifications, ignore_blacklist=local_ignore_blacklist,
rating=rating_limit) rotten_tomatoes=rotten_tomatoes)
elif list_type.lower() == 'watchlist': elif list_type.lower() == 'watchlist':
for authenticate_user, limit in value.items(): for authenticate_user, limit in value.items():
if limit <= 0: 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, added_movies = movies.callback(list_type=list_type, add_limit=limit,
add_delay=add_delay, sort=sort, no_search=no_search, add_delay=add_delay, sort=sort, no_search=no_search,
notifications=notifications, authenticate_user=authenticate_user, 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': elif list_type.lower() == 'lists':
for list_, v in value.items(): for list_, v in value.items():
if isinstance(v, dict): 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, added_movies = movies.callback(list_type=list_, add_limit=limit,
add_delay=add_delay, sort=sort, no_search=no_search, add_delay=add_delay, sort=sort, no_search=no_search,
notifications=notifications, authenticate_user=authenticate_user, 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: if added_movies is None:
log.error("FAILED ADDING movies from Trakt's \'%s\' list", list_type.capitalize()) 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, no_search,
not no_notifications, not no_notifications,
ignore_blacklist, 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: if run_now:
movie_schedule.run() movie_schedule.run()

Loading…
Cancel
Save