improved genre unblacklist & check when -g is supplied.

pull/54/head
James 7 years ago
parent 9bed56c90d
commit fdd44f5475

@ -44,3 +44,22 @@ def dict_merge(dct, merge_dct):
dct[k] = merge_dct[k] dct[k] = merge_dct[k]
return dct return dct
def unblacklist_genres(genre, blacklisted_genres):
genres = genre.split(',')
for allow_genre in genres:
if allow_genre in blacklisted_genres:
blacklisted_genres.remove(allow_genre)
return
def allowed_genres(genre, object_type, trakt_object):
allowed_object = False
genres = genre.split(',')
for item in genres:
if item.lower() in trakt_object[object_type]['genres']:
allowed_object = True
break
return allowed_object

@ -184,14 +184,15 @@ def shows(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_sea
authenticate_user=None): authenticate_user=None):
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 sonarr as sonarr_helper from helpers import sonarr as sonarr_helper
from helpers import trakt as trakt_helper from helpers import trakt as trakt_helper
added_shows = 0 added_shows = 0
# remove genre from shows blacklisted_genres if supplied # remove genre from shows blacklisted_genres if supplied
if genre and genre in cfg.filters.shows.blacklisted_genres: if genre:
cfg['filters']['shows']['blacklisted_genres'].remove(genre) misc_helper.unblacklist_genres(genre, cfg['filters']['shows']['blacklisted_genres'])
# replace sonarr root_folder if folder is supplied # replace sonarr root_folder if folder is supplied
if folder: if folder:
@ -253,8 +254,8 @@ def shows(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_sea
for series in sorted_series_list: for series in sorted_series_list:
try: try:
# check if genre matches genre supplied via argument # check if genre matches genre supplied via argument
if genre and genre.lower() not in series['show']['genres']: if genre and not misc_helper.allowed_genres(genre, 'show', series):
log.debug("Skipping: %s because it was not from %s genre", series['show']['title'], genre.lower()) log.debug("Skipping: %s because it was not from %s genre(s)", series['show']['title'], genre.lower())
continue continue
# check if series passes out blacklist criteria inspection # check if series passes out blacklist criteria inspection
@ -360,14 +361,15 @@ def movies(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_se
authenticate_user=None): authenticate_user=None):
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 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
added_movies = 0 added_movies = 0
# remove genre from movies blacklisted_genres if supplied # remove genre from movies blacklisted_genres if supplied
if genre and genre in cfg.filters.movies.blacklisted_genres: if genre:
cfg['filters']['movies']['blacklisted_genres'].remove(genre) misc_helper.unblacklist_genres(genre, cfg['filters']['movies']['blacklisted_genres'])
# replace radarr root_folder if folder is supplied # replace radarr root_folder if folder is supplied
if folder: if folder:
@ -430,8 +432,8 @@ def movies(list_type, add_limit=0, add_delay=2.5, genre=None, folder=None, no_se
for movie in sorted_movies_list: for movie in sorted_movies_list:
try: try:
# check if genre matches genre supplied via argument # check if genre matches genre supplied via argument
if genre and genre.lower() not in movie['movie']['genres']: if genre and not misc_helper.allowed_genres(genre, 'movie', movie):
log.debug("Skipping: %s because it was not from %s genre", movie['movie']['title'], genre.lower()) log.debug("Skipping: %s because it was not from %s genre(s)", movie['movie']['title'], genre.lower())
continue continue
# check if movie passes out blacklist criteria inspection # check if movie passes out blacklist criteria inspection

Loading…
Cancel
Save