Merge pull request #32 from mitchellklijs/ignoreBlacklist

Ignore blacklist (issue #31)
pull/54/head
James 7 years ago committed by desimaniac
commit f63f4009e3

@ -193,6 +193,7 @@ You can repeat this process for as many users as you like.
}, },
"filters": { "filters": {
"movies": { "movies": {
"disabled_for": [],
"allowed_countries": [ "allowed_countries": [
"us", "us",
"gb", "gb",
@ -215,6 +216,7 @@ You can repeat this process for as many users as you like.
"blacklisted_tmdb_ids": [] "blacklisted_tmdb_ids": []
}, },
"shows": { "shows": {
"disabled_for": [],
"allowed_countries": [ "allowed_countries": [
"us", "us",
"gb", "gb",
@ -445,6 +447,7 @@ Use filters to specify the movie/shows's country of origin or blacklist (i.e. fi
```json ```json
"movies": { "movies": {
"disabled_for": [],
"allowed_countries": [ "allowed_countries": [
"us", "us",
"gb", "gb",
@ -467,6 +470,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_countries` - only add movies from these countries.
`allowed_languages` - only add movies with these languages (default/blank=English). `allowed_languages` - only add movies with these languages (default/blank=English).
@ -531,6 +546,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_countries` - only add shows from these countries.
`allowed_languages` - only add shows with these languages (default/blank=English). `allowed_languages` - only add shows with these languages (default/blank=English).
@ -730,6 +757,7 @@ You can customize how the scheduled traktarr is ran by editing the `traktarr.ser
--no-search Disable search when adding to Sonarr / Radarr. --no-search Disable search when adding to Sonarr / Radarr.
--run-now Do a first run immediately without waiting. --run-now Do a first run immediately without waiting.
--no-notifications Disable notifications. --no-notifications Disable notifications.
--ignore-blacklist Ignores the blacklist when running the command.
--help Show this message and exit. --help Show this message and exit.
``` ```
@ -813,6 +841,7 @@ Options:
-f, --folder TEXT Add movies with this root folder to Radarr. -f, --folder TEXT Add movies with this root folder to Radarr.
--no-search Disable search when adding movies to Radarr. --no-search Disable search when adding movies to Radarr.
--notifications Send notifications. --notifications Send notifications.
--ignore-blacklist Ignores the blacklist when running the command.
--authenticate-user TEXT Specify which user to authenticate with to --authenticate-user TEXT Specify which user to authenticate with to
retrieve Trakt lists. Default: first user in the retrieve Trakt lists. Default: first user in the
config. config.
@ -865,6 +894,7 @@ Options:
-f, --folder TEXT Add shows with this root folder to Sonarr. -f, --folder TEXT Add shows with this root folder to Sonarr.
--no-search Disable search when adding shows to Sonarr. --no-search Disable search when adding shows to Sonarr.
--notifications Send notifications. --notifications Send notifications.
--ignore-blacklist Ignores the blacklist when running the command.
--authenticate-user TEXT Specify which user to authenticate with to --authenticate-user TEXT Specify which user to authenticate with to
retrieve Trakt lists. Default: first user in the retrieve Trakt lists. Default: first user in the
config config

@ -106,7 +106,10 @@ def blacklisted_show_id(show, blacklisted_ids):
return blacklisted 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 blacklisted = False
try: try:
if blacklisted_show_year(show, blacklist_settings.blacklisted_min_year, if blacklisted_show_year(show, blacklist_settings.blacklisted_min_year,
@ -228,7 +231,10 @@ def blacklisted_movie_id(movie, blacklisted_ids):
return blacklisted 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 blacklisted = False
try: try:
if blacklisted_movie_title(movie, blacklist_settings.blacklist_title_keywords): if blacklisted_movie_title(movie, blacklist_settings.blacklist_title_keywords):

@ -57,6 +57,7 @@ class Config(object, metaclass=Singleton):
}, },
'filters': { 'filters': {
'shows': { 'shows': {
'disabled_for': [],
'blacklisted_genres': [], 'blacklisted_genres': [],
'blacklisted_networks': [], 'blacklisted_networks': [],
'allowed_countries': [], 'allowed_countries': [],
@ -67,6 +68,7 @@ class Config(object, metaclass=Singleton):
'blacklisted_tvdb_ids': [], 'blacklisted_tvdb_ids': [],
}, },
'movies': { 'movies': {
'disabled_for': [],
'blacklisted_genres': [], 'blacklisted_genres': [],
'blacklisted_min_runtime': 60, 'blacklisted_min_runtime': 60,
'blacklisted_min_year': 2000, 'blacklisted_min_year': 2000,

@ -183,8 +183,9 @@ def show(show_id, folder=None, no_search=False):
@click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--notifications', is_flag=True, help='Send notifications.')
@click.option('--authenticate-user', @click.option('--authenticate-user',
help='Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config') 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, sort='votes', genre=None, folder=None, no_search=False, def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folder=None, no_search=False,
notifications=False, authenticate_user=None): notifications=False, authenticate_user=None, ignore_blacklist=False):
from media.sonarr import Sonarr from media.sonarr import Sonarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import misc as misc_helper from helpers import misc as misc_helper
@ -269,7 +270,7 @@ def shows(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folde
continue continue
# check if series passes out blacklist criteria inspection # 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'], log.info("Adding: %s | Genres: %s | Network: %s | Country: %s", series['show']['title'],
', '.join(series['show']['genres']), series['show']['network'], ', '.join(series['show']['genres']), series['show']['network'],
series['show']['country'].upper()) series['show']['country'].upper())
@ -369,8 +370,9 @@ def movie(movie_id, folder=None, no_search=False):
@click.option('--notifications', is_flag=True, help='Send notifications.') @click.option('--notifications', is_flag=True, help='Send notifications.')
@click.option('--authenticate-user', @click.option('--authenticate-user',
help='Specify which user to authenticate with to retrieve Trakt lists. Default: first user in the config.') 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, sort='votes', genre=None, folder=None, no_search=False, def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, folder=None, no_search=False,
notifications=False, authenticate_user=None): notifications=False, authenticate_user=None, ignore_blacklist=False):
from media.radarr import Radarr from media.radarr import Radarr
from media.trakt import Trakt from media.trakt import Trakt
from helpers import misc as misc_helper from helpers import misc as misc_helper
@ -456,7 +458,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', genre=None, fold
continue continue
# check if movie passes out blacklist criteria inspection # 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'], log.info("Adding: %s (%d) | Genres: %s | Country: %s", movie['movie']['title'], movie['movie']['year'],
', '.join(movie['movie']['genres']), movie['movie']['country'].upper()) ', '.join(movie['movie']['genres']), movie['movie']['country'].upper())
# add movie to radarr # add movie to radarr
@ -517,7 +519,7 @@ def callback_notify(data):
return return
def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=False): def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=False, ignore_blacklist=False):
from media.trakt import Trakt from media.trakt import Trakt
total_shows_added = 0 total_shows_added = 0
@ -539,10 +541,15 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
else: else:
log.info("Adding %d shows from Trakt's %s list", limit, list_type) 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 # run shows
added_shows = shows.callback(list_type=list_type, add_limit=limit, added_shows = shows.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) notifications=notifications, ignore_blacklist=local_ignore_blacklist)
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:
@ -551,10 +558,16 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
else: else:
log.info("Adding %d shows from the %s from %s", limit, list_type, authenticate_user) 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 # run shows
added_shows = shows.callback(list_type=list_type, add_limit=limit, added_shows = shows.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)
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):
@ -564,10 +577,16 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
authenticate_user = None authenticate_user = None
limit = v limit = v
local_ignore_blacklist = ignore_blacklist
if "list:%s".format(list) in cfg.filters.shows.disabled_for:
local_ignore_blacklist = True
# run shows # run shows
added_shows = shows.callback(list_type=list, add_limit=limit, added_shows = shows.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)
if added_shows is None: if added_shows is None:
log.error("Failed adding shows from Trakt's %s list", list_type) log.error("Failed adding shows from Trakt's %s list", list_type)
@ -588,7 +607,7 @@ def automatic_shows(add_delay=2.5, sort='votes', no_search=False, notifications=
return return
def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications=False): def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications=False, ignore_blacklist=False):
from media.trakt import Trakt from media.trakt import Trakt
total_movies_added = 0 total_movies_added = 0
@ -610,6 +629,11 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
else: else:
log.info("Adding %d movies from Trakt's %s list", limit, list_type) 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 # run movies
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,
@ -622,10 +646,16 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
else: else:
log.info("Adding %d movies from the %s from %s", limit, list_type, authenticate_user) 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 # run movies
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)
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):
@ -635,10 +665,16 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
authenticate_user = None authenticate_user = None
limit = v limit = v
local_ignore_blacklist = ignore_blacklist
if "list:%s".format(list) in cfg.filters.movies.disabled_for:
local_ignore_blacklist = True
# run shows # run shows
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)
if added_movies is None: if added_movies is None:
log.error("Failed adding movies from Trakt's %s list", list_type) log.error("Failed adding movies from Trakt's %s list", list_type)
@ -667,7 +703,8 @@ def automatic_movies(add_delay=2.5, sort='votes', no_search=False, notifications
@click.option('--no-search', is_flag=True, help='Disable search when adding to Sonarr / Radarr.') @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('--run-now', is_flag=True, help="Do a first run immediately without waiting.")
@click.option('--no-notifications', is_flag=True, help="Disable notifications.") @click.option('--no-notifications', is_flag=True, help="Disable notifications.")
def run(add_delay=2.5, sort='votes', 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, sort='votes', no_search=False, run_now=False, no_notifications=False, ignore_blacklist=False):
log.info("Automatic mode is now running...") log.info("Automatic mode is now running...")
# Add tasks to schedule and do first run if enabled # Add tasks to schedule and do first run if enabled
@ -677,7 +714,8 @@ def run(add_delay=2.5, sort='votes', no_search=False, run_now=False, no_notifica
add_delay, add_delay,
sort, sort,
no_search, no_search,
not no_notifications not no_notifications,
ignore_blacklist
) )
if run_now: if run_now:
movie_schedule.run() movie_schedule.run()
@ -691,7 +729,8 @@ def run(add_delay=2.5, sort='votes', no_search=False, run_now=False, no_notifica
add_delay, add_delay,
sort, sort,
no_search, no_search,
not no_notifications not no_notifications,
ignore_blacklist
) )
if run_now: if run_now:
shows_schedule.run() shows_schedule.run()

Loading…
Cancel
Save