From df7365e270fa1625494e032411abdedc84d5b978 Mon Sep 17 00:00:00 2001 From: Mitchell Klijs Date: Wed, 30 May 2018 18:04:21 +0200 Subject: [PATCH] Add option to ignore blacklist --- README.md | 3 +++ helpers/trakt.py | 10 ++++++++-- traktarr.py | 39 ++++++++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1c58e2e..b652b01 100644 --- a/README.md +++ b/README.md @@ -726,6 +726,7 @@ You can customize how the scheduled traktarr is ran by editing the `traktarr.ser --no-search Disable search when adding to Sonarr / Radarr. --run-now Do a first run immediately without waiting. --no-notifications Disable notifications. + --ignore-blacklist Ignores the blacklist when running the command. --help Show this message and exit. ``` @@ -809,6 +810,7 @@ Options: -f, --folder TEXT Add movies with this root folder to Radarr. --no-search Disable search when adding movies to Radarr. --notifications Send notifications. + --ignore-blacklist Ignores the blacklist when running the command. --authenticate-user TEXT Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config. @@ -861,6 +863,7 @@ Options: -f, --folder TEXT Add shows with this root folder to Sonarr. --no-search Disable search when adding shows to Sonarr. --notifications Send notifications. + --ignore-blacklist Ignores the blacklist when running the command. --authenticate-user TEXT Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config diff --git a/helpers/trakt.py b/helpers/trakt.py index 6e65ccb..484d28a 100644 --- a/helpers/trakt.py +++ b/helpers/trakt.py @@ -106,7 +106,10 @@ def blacklisted_show_id(show, blacklisted_ids): return blacklisted -def is_show_blacklisted(show, blacklist_settings): +def is_show_blacklisted(show, blacklist_settings, ignore_blacklist): + if ignore_blacklist: + return False + blacklisted = False try: if blacklisted_show_year(show, blacklist_settings.blacklisted_min_year, @@ -228,7 +231,10 @@ def blacklisted_movie_id(movie, blacklisted_ids): return blacklisted -def is_movie_blacklisted(movie, blacklist_settings): +def is_movie_blacklisted(movie, blacklist_settings, ignore_blacklist): + if ignore_blacklist: + return False + blacklisted = False try: if blacklisted_movie_title(movie, blacklist_settings.blacklist_title_keywords): diff --git a/traktarr.py b/traktarr.py index 4718e74..6a5a34c 100755 --- a/traktarr.py +++ b/traktarr.py @@ -181,8 +181,9 @@ def show(show_id, folder=None, no_search=False): @click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--authenticate-user', help='Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config') +@click.option('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.') def shows(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_search=False, notifications=False, - authenticate_user=None): + authenticate_user=None, ignore_blacklist=False): from media.sonarr import Sonarr from media.trakt import Trakt from helpers import misc as misc_helper @@ -260,7 +261,7 @@ def shows(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_sea continue # check if series passes out blacklist criteria inspection - if not trakt_helper.is_show_blacklisted(series, cfg.filters.shows): + if not trakt_helper.is_show_blacklisted(series, cfg.filters.shows, ignore_blacklist): log.info("Adding: %s | Genres: %s | Network: %s | Country: %s", series['show']['title'], ', '.join(series['show']['genres']), series['show']['network'], series['show']['country'].upper()) @@ -358,8 +359,9 @@ def movie(movie_id, folder=None, no_search=False): @click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--authenticate-user', help='Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config.') +@click.option('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.') def movies(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_search=False, notifications=False, - authenticate_user=None): + authenticate_user=None, ignore_blacklist=False): from media.radarr import Radarr from media.trakt import Trakt from helpers import misc as misc_helper @@ -438,7 +440,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_se continue # check if movie passes out blacklist criteria inspection - if not trakt_helper.is_movie_blacklisted(movie, cfg.filters.movies): + if not trakt_helper.is_movie_blacklisted(movie, cfg.filters.movies, ignore_blacklist): log.info("Adding: %s (%d) | Genres: %s | Country: %s", movie['movie']['title'], movie['movie']['year'], ', '.join(movie['movie']['genres']), movie['movie']['country'].upper()) # add movie to radarr @@ -499,7 +501,7 @@ def callback_notify(data): return -def automatic_shows(add_delay=2.5, no_search=False, notifications=False): +def automatic_shows(add_delay=2.5, no_search=False, notifications=False, ignore_blacklist=False): from media.trakt import Trakt total_shows_added = 0 @@ -524,7 +526,7 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False): # run shows added_shows = shows.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications) + notifications=notifications, ignore_blacklist=ignore_blacklist) elif list_type.lower() == 'watchlist': for authenticate_user, limit in value.items(): if limit <= 0: @@ -536,7 +538,8 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False): # run shows added_shows = shows.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications, authenticate_user=authenticate_user) + notifications=notifications, authenticate_user=authenticate_user, + ignore_blacklist=ignore_blacklist) elif list_type.lower() == 'lists': for list, v in value.items(): if isinstance(v, dict): @@ -549,7 +552,8 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False): # run shows added_shows = shows.callback(list_type=list, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications, authenticate_user=authenticate_user) + notifications=notifications, authenticate_user=authenticate_user, + ignore_blacklist=ignore_blacklist) if added_shows is None: log.error("Failed adding shows from Trakt's %s list", list_type) @@ -570,7 +574,7 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False): return -def automatic_movies(add_delay=2.5, no_search=False, notifications=False): +def automatic_movies(add_delay=2.5, no_search=False, notifications=False, ignore_blacklist=False): from media.trakt import Trakt total_movies_added = 0 @@ -595,7 +599,7 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False): # run movies added_movies = movies.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications) + notifications=notifications, ignore_blacklist=ignore_blacklist) elif list_type.lower() == 'watchlist': for authenticate_user, limit in value.items(): if limit <= 0: @@ -607,7 +611,8 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False): # run movies added_movies = movies.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications, authenticate_user=authenticate_user) + notifications=notifications, authenticate_user=authenticate_user, + ignore_blacklist=ignore_blacklist) elif list_type.lower() == 'lists': for list, v in value.items(): if isinstance(v, dict): @@ -620,7 +625,8 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False): # run shows added_movies = movies.callback(list_type=list, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications, authenticate_user=authenticate_user) + notifications=notifications, authenticate_user=authenticate_user, + ignore_blacklist=ignore_blacklist) if added_movies is None: log.error("Failed adding movies from Trakt's %s list", list_type) @@ -647,7 +653,8 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False): @click.option('--no-search', is_flag=True, help='Disable search when adding to Sonarr / Radarr.') @click.option('--run-now', is_flag=True, help="Do a first run immediately without waiting.") @click.option('--no-notifications', is_flag=True, help="Disable notifications.") -def run(add_delay=2.5, no_search=False, run_now=False, no_notifications=False): +@click.option('--ignore-blacklist', is_flag=True, help='Ignores the blacklist when running the command.') +def run(add_delay=2.5, no_search=False, run_now=False, no_notifications=False, ignore_blacklist=False): log.info("Automatic mode is now running...") # Add tasks to schedule and do first run if enabled @@ -656,7 +663,8 @@ def run(add_delay=2.5, no_search=False, run_now=False, no_notifications=False): automatic_movies, add_delay, no_search, - not no_notifications + not no_notifications, + ignore_blacklist ) if run_now: movie_schedule.run() @@ -669,7 +677,8 @@ def run(add_delay=2.5, no_search=False, run_now=False, no_notifications=False): automatic_shows, add_delay, no_search, - not no_notifications + not no_notifications, + ignore_blacklist ) if run_now: shows_schedule.run()