diff --git a/README.md b/README.md index 02ab983..4aa48c4 100644 --- a/README.md +++ b/README.md @@ -249,19 +249,19 @@ You can repeat this process for as many users as you like. "allowed_languages": [ "en" ], - "blacklist_title_keywords": [ - "untitled", - "barbie", - "ufc" - ], "blacklisted_genres": [ "documentary", "music", "animation" ], - "blacklisted_max_year": 2019, "blacklisted_min_runtime": 60, + "blacklisted_max_year": 2019, "blacklisted_min_year": 2000, + "blacklisted_title_keywords": [ + "untitled", + "barbie", + "ufc" + ], "blacklisted_tmdb_ids": [], "rotten_tomatoes": "" }, @@ -285,9 +285,6 @@ You can repeat this process for as many users as you like. "documentary", "special-interest" ], - "blacklisted_max_year": 2019, - "blacklisted_min_runtime": 15, - "blacklisted_min_year": 2000, "blacklisted_networks": [ "twitch", "youtube", @@ -304,6 +301,10 @@ You can repeat this process for as many users as you like. "yahoo!", "fox sports" ], + "blacklisted_max_year": 2019, + "blacklisted_min_runtime": 15, + "blacklisted_min_year": 2000, + "blacklisted_title_keywords": [], "blacklisted_tvdb_ids": [] } }, @@ -536,10 +537,6 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi "ca" ], "allowed_languages": [], - "blacklist_title_keywords": [ - "untitled", - "barbie" - ], "blacklisted_genres": [ "documentary", "music", @@ -548,6 +545,10 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi "blacklisted_max_year": 2019, "blacklisted_min_runtime": 60, "blacklisted_min_year": 2000, + "blacklisted_title_keywords": [ + "untitled", + "barbie" + ], "blacklisted_tmdb_ids": [], "rotten_tomatoes": "" }, @@ -587,8 +588,6 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi - [List of available language codes](assets/list_of_language_codes.md). -`blacklist_title_keywords` - blacklist certain words in titles. - `blacklisted_genres` - Blacklist certain genres. - [List of available movie genres](assets/list_of_movie_genres.md). @@ -609,6 +608,8 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi `blacklisted_min_year` - Blacklist release dates before specified year. +`blacklisted_title_keywords` - Blacklist certain words in titles. + `blacklisted_tmdb_ids` - Blacklist certain movies with their TMDB IDs. - Example: @@ -644,9 +645,6 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi "documentary", "special-interest" ], - "blacklisted_max_year": 2019, - "blacklisted_min_runtime": 15, - "blacklisted_min_year": 2000, "blacklisted_networks": [ "twitch", "youtube", @@ -663,6 +661,10 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi "yahoo!", "fox sports" ], + "blacklisted_min_runtime": 15, + "blacklisted_max_year": 2019, + "blacklisted_min_year": 2000, + "blacklisted_title_keywords": [], "blacklisted_tvdb_ids": [] } ``` @@ -715,13 +717,15 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi - No other list item should be present. -`blacklisted_max_year` - Blacklist release dates after specified year. +`blacklisted_networks` - Blacklist certain network. `blacklisted_min_runtime` - Blacklist runtime duration lower than specified time (in minutes). +`blacklisted_max_year` - Blacklist release dates after specified year. + `blacklisted_min_year` - Blacklist release dates before specified year. -`blacklisted_networks` - Blacklist certain network. +`blacklisted_title_keywords` - Blacklist certain words in titles. `blacklisted_tvdb_ids` - Blacklist certain shows with their TVDB IDs. diff --git a/helpers/trakt.py b/helpers/trakt.py index e93b1a7..6ba20e7 100644 --- a/helpers/trakt.py +++ b/helpers/trakt.py @@ -32,12 +32,19 @@ def blacklisted_show_id(show, blacklisted_ids): return blacklisted -def blacklisted_show_title(show): +def blacklisted_show_title(show, blacklisted_keywords): blacklisted = False try: if not show['show']['title']: log.debug("Blacklisted Titles Check | Blacklisted show because it had no title: %s", show) blacklisted = True + else: + for keyword in blacklisted_keywords: + if keyword.lower() in show['show']['title'].lower(): + log.debug("\'%s\' | Blacklisted Titles Check | Blacklisted because it had the title keyword: %s", + show['show']['title'], keyword) + blacklisted = True + break except Exception: log.exception("Exception determining if show had a blacklisted title %s: ", show) return blacklisted @@ -194,7 +201,7 @@ def is_show_blacklisted(show, blacklist_settings, ignore_blacklist, callback=Non try: if blacklisted_show_id(show, blacklist_settings.blacklisted_tvdb_ids): blacklisted = True - if blacklisted_show_title(show): + if blacklisted_show_title(show, blacklist_settings.blacklisted_title_keywords): blacklisted = True if blacklisted_show_year(show, blacklist_settings.blacklisted_min_year, blacklist_settings.blacklisted_max_year): @@ -240,7 +247,7 @@ def blacklisted_movie_title(movie, blacklisted_keywords): else: for keyword in blacklisted_keywords: if keyword.lower() in movie['movie']['title'].lower(): - log.debug("\'%s\' | Blacklisted Titles Check | Blacklisted because it had title keyword: %s", + log.debug("\'%s\' | Blacklisted Titles Check | Blacklisted because it had the title keyword: %s", movie['movie']['title'], keyword) blacklisted = True break @@ -381,7 +388,7 @@ def is_movie_blacklisted(movie, blacklist_settings, ignore_blacklist, callback=N try: if blacklisted_movie_id(movie, blacklist_settings.blacklisted_tmdb_ids): blacklisted = True - if blacklisted_movie_title(movie, blacklist_settings.blacklist_title_keywords): + if blacklisted_movie_title(movie, blacklist_settings.blacklisted_title_keywords): blacklisted = True if blacklisted_movie_year(movie, blacklist_settings.blacklisted_min_year, blacklist_settings.blacklisted_max_year): diff --git a/misc/config.py b/misc/config.py index 45fa4d4..e3bf3c0 100644 --- a/misc/config.py +++ b/misc/config.py @@ -62,26 +62,27 @@ class Config(object, metaclass=Singleton): 'filters': { 'shows': { 'disabled_for': [], - 'blacklisted_genres': [], - 'blacklisted_networks': [], 'allowed_countries': [], 'allowed_languages': [], + 'blacklisted_genres': [], + 'blacklisted_networks': [], 'blacklisted_min_runtime': 15, 'blacklisted_min_year': 2000, 'blacklisted_max_year': 2019, + 'blacklisted_title_keywords': [], 'blacklisted_tvdb_ids': [], }, 'movies': { 'disabled_for': [], + 'allowed_countries': [], + 'allowed_languages': [], 'blacklisted_genres': [], 'blacklisted_min_runtime': 60, 'blacklisted_min_year': 2000, 'blacklisted_max_year': 2019, - 'blacklist_title_keywords': [], + 'blacklisted_title_keywords': [], 'blacklisted_tmdb_ids': [], - 'allowed_countries': [], - 'allowed_languages': [], - 'rotten_tomatoes':"" + 'rotten_tomatoes': "" } }, 'automatic': { diff --git a/sample/config.json b/sample/config.json index 7228b89..4d503dd 100644 --- a/sample/config.json +++ b/sample/config.json @@ -21,16 +21,42 @@ "verbose": false }, "filters": { + "movies": { + "disabled_for": [], + "allowed_countries": [ + "us", + "gb", + "ca" + ], + "allowed_languages": [ + "en" + ], + "blacklisted_genres": [ + "documentary", + "music", + "short", + "sporting-event", + "film-noir", + "fan-film" + ], + "blacklisted_min_runtime": 60, + "blacklisted_min_year": 2000, + "blacklisted_max_year": 2019, + "blacklisted_title_keywords": [ + "untitled", + "barbie", + "ufc" + ], + "rotten_tomatoes": 80 + }, "shows": { + "disabled_for": [], "allowed_countries": [ "us", "gb", "ca" ], "allowed_languages": [], - "blacklisted_min_runtime": 15, - "blacklisted_min_year": 2010, - "blacklisted_max_year": 2019, "blacklisted_genres": [ "animation", "game-show", @@ -59,35 +85,10 @@ "fox sports", "yahoo!" ], - "disabled_for": [] - }, - "movies": { - "allowed_countries": [ - "us", - "gb", - "ca" - ], - "allowed_languages": [ - "en" - ], - "blacklisted_genres": [ - "documentary", - "music", - "short", - "sporting-event", - "film-noir", - "fan-film" - ], - "blacklist_title_keywords": [ - "untitled", - "barbie", - "ufc" - ], - "blacklisted_min_runtime": 60, - "blacklisted_min_year": 2000, + "blacklisted_min_runtime": 15, + "blacklisted_min_year": 2010, "blacklisted_max_year": 2019, - "rotten_tomatoes": 80, - "disabled_for": [] + "blacklisted_title_keywords": [] } }, "radarr": { diff --git a/traktarr.py b/traktarr.py index 4febce7..2bd4411 100755 --- a/traktarr.py +++ b/traktarr.py @@ -52,6 +52,8 @@ def app(config, cachefile, logfile): cfg = Config(configfile=config, cachefile=cachefile, logfile=logfile).cfg # Legacy Support + if cfg.filters.movies.blacklist_title_keywords: + cfg['filters']['movies']['blacklisted_title_keywords'] = cfg['filters']['movies']['blacklist_title_keywords'] if cfg.filters.movies.rating_limit: cfg['filters']['movies']['rotten_tomatoes'] = cfg['filters']['movies']['rating_limit']