From 2061c2e42ce5f2f3244676e0c83801dcc02e0174 Mon Sep 17 00:00:00 2001 From: Mitchell Klijs Date: Wed, 30 May 2018 18:33:39 +0200 Subject: [PATCH] Add ability to specify blacklist ignore in config --- README.md | 27 +++++++++++++++++++++++++++ misc/config.py | 2 ++ traktarr.py | 42 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b652b01..10e7385 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,7 @@ You can repeat this process for as many users as you like. }, "filters": { "movies": { + "disabled_for": [], "allowed_countries": [ "us", "gb", @@ -215,6 +216,7 @@ You can repeat this process for as many users as you like. "blacklisted_tmdb_ids": [] }, "shows": { + "disabled_for": [], "allowed_countries": [ "us", "gb", @@ -444,6 +446,7 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi ```json "movies": { + "disabled_for": [], "allowed_countries": [ "us", "gb", @@ -466,6 +469,18 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi }, ``` +`disabled_for` - specify for which lists the blacklist must be disabled when running in automatic mode + +Example: + +``` + "disabled_for": [ + "anticipated", + "watchlist:user1", + "list:http://url-to-list" + ], +``` + `allowed_countries` - only add movies from these countries. `allowed_languages` - only add movies with these languages (default/blank=English). @@ -530,6 +545,18 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi } ``` +`disabled_for` - specify for which lists the blacklist must be disabled when running in automatic mode + +Example: + +``` + "disabled_for": [ + "anticipated", + "watchlist:user1", + "list:http://url-to-list" + ], +``` + `allowed_countries` - only add shows from these countries. `allowed_languages` - only add shows with these languages (default/blank=English). diff --git a/misc/config.py b/misc/config.py index f123139..e3fbfba 100644 --- a/misc/config.py +++ b/misc/config.py @@ -57,6 +57,7 @@ class Config(object, metaclass=Singleton): }, 'filters': { 'shows': { + 'disabled_for': [], 'blacklisted_genres': [], 'blacklisted_networks': [], 'allowed_countries': [], @@ -67,6 +68,7 @@ class Config(object, metaclass=Singleton): 'blacklisted_tvdb_ids': [], }, 'movies': { + 'disabled_for': [], 'blacklisted_genres': [], 'blacklisted_min_runtime': 60, 'blacklisted_min_year': 2000, diff --git a/traktarr.py b/traktarr.py index 6a5a34c..3ab9baf 100755 --- a/traktarr.py +++ b/traktarr.py @@ -523,10 +523,15 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False, ignore_ else: log.info("Adding %d shows from Trakt's %s list", limit, list_type) + local_ignore_blacklist = ignore_blacklist + + if list_type.lower() in cfg.filters.shows.disabled_for: + local_ignore_blacklist = True + # run shows added_shows = shows.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications, ignore_blacklist=ignore_blacklist) + notifications=notifications, ignore_blacklist=local_ignore_blacklist) elif list_type.lower() == 'watchlist': for authenticate_user, limit in value.items(): if limit <= 0: @@ -535,11 +540,16 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False, ignore_ else: log.info("Adding %d shows from the %s from %s", limit, list_type, authenticate_user) + local_ignore_blacklist = ignore_blacklist + + if "watchlist:%s".format(authenticate_user) in cfg.filters.shows.disabled_for: + local_ignore_blacklist = True + # 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, - ignore_blacklist=ignore_blacklist) + ignore_blacklist=local_ignore_blacklist) elif list_type.lower() == 'lists': for list, v in value.items(): if isinstance(v, dict): @@ -549,11 +559,16 @@ def automatic_shows(add_delay=2.5, no_search=False, notifications=False, ignore_ authenticate_user = None limit = v + local_ignore_blacklist = ignore_blacklist + + if "list:%s".format(list) in cfg.filters.shows.disabled_for: + local_ignore_blacklist = True + # 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, - ignore_blacklist=ignore_blacklist) + ignore_blacklist=local_ignore_blacklist) if added_shows is None: log.error("Failed adding shows from Trakt's %s list", list_type) @@ -596,10 +611,15 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False, ignore else: log.info("Adding %d movies from Trakt's %s list", limit, list_type) + local_ignore_blacklist = ignore_blacklist + + if list_type.lower() in cfg.filters.movies.disabled_for: + local_ignore_blacklist = True + # run movies added_movies = movies.callback(list_type=list_type, add_limit=limit, add_delay=add_delay, no_search=no_search, - notifications=notifications, ignore_blacklist=ignore_blacklist) + notifications=notifications, ignore_blacklist=local_ignore_blacklist) elif list_type.lower() == 'watchlist': for authenticate_user, limit in value.items(): if limit <= 0: @@ -608,11 +628,16 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False, ignore else: log.info("Adding %d movies from the %s from %s", limit, list_type, authenticate_user) + local_ignore_blacklist = ignore_blacklist + + if "watchlist:%s".format(authenticate_user) in cfg.filters.movies.disabled_for: + local_ignore_blacklist = True + # 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, - ignore_blacklist=ignore_blacklist) + ignore_blacklist=local_ignore_blacklist) elif list_type.lower() == 'lists': for list, v in value.items(): if isinstance(v, dict): @@ -622,11 +647,16 @@ def automatic_movies(add_delay=2.5, no_search=False, notifications=False, ignore authenticate_user = None limit = v + local_ignore_blacklist = ignore_blacklist + + if "list:%s".format(list) in cfg.filters.movies.disabled_for: + local_ignore_blacklist = True + # 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, - ignore_blacklist=ignore_blacklist) + ignore_blacklist=local_ignore_blacklist) if added_movies is None: log.error("Failed adding movies from Trakt's %s list", list_type)