added blacklisted_max_year to exclude movies/shows beyond this year

pull/54/head
l3uddz 7 years ago
parent be0e500af5
commit 018dc5cda4

@ -38,12 +38,14 @@ base_config = {
'fox sports'], 'fox sports'],
'allowed_countries': ['us', 'gb', 'ca'], 'allowed_countries': ['us', 'gb', 'ca'],
'blacklisted_min_runtime': 15, 'blacklisted_min_runtime': 15,
'blacklisted_min_year': 2000 'blacklisted_min_year': 2000,
'blacklisted_max_year': 2019
}, },
'movies': { 'movies': {
'blacklisted_genres': ['documentary', 'music'], 'blacklisted_genres': ['documentary', 'music'],
'blacklisted_min_runtime': 60, 'blacklisted_min_runtime': 60,
'blacklisted_min_year': 2000, 'blacklisted_min_year': 2000,
'blacklisted_max_year': 2019,
'blacklist_title_keywords': ['untitled', 'barbie'], 'blacklist_title_keywords': ['untitled', 'barbie'],
'allowed_countries': ['us', 'gb', 'ca'] 'allowed_countries': ['us', 'gb', 'ca']
} }

@ -85,7 +85,7 @@ def trakt_blacklisted_show_genre(show, genres):
return blacklisted return blacklisted
def trakt_blacklisted_show_year(show, earliest_year): def trakt_blacklisted_show_year(show, earliest_year, latest_year):
blacklisted = False blacklisted = False
try: try:
year = misc_str.get_year_from_timestamp(show['show']['first_aired']) year = misc_str.get_year_from_timestamp(show['show']['first_aired'])
@ -93,11 +93,11 @@ def trakt_blacklisted_show_year(show, earliest_year):
log.debug("%s was blacklisted due to having an unknown first_aired date", show['show']['title']) log.debug("%s was blacklisted due to having an unknown first_aired date", show['show']['title'])
blacklisted = True blacklisted = True
else: else:
if year < earliest_year: if year < earliest_year or year > latest_year:
log.debug("%s was blacklisted because it first aired in: %d", show['show']['title'], year) log.debug("%s was blacklisted because it first aired in: %d", show['show']['title'], year)
blacklisted = True blacklisted = True
except Exception: except Exception:
log.exception("Exception determining if show is before earliest_year %s:", show) log.exception("Exception determining if show is within min_year and max_year range %s:", show)
return blacklisted return blacklisted
@ -156,7 +156,8 @@ def trakt_blacklisted_show_runtime(show, lowest_runtime):
def trakt_is_show_blacklisted(show, blacklist_settings): def trakt_is_show_blacklisted(show, blacklist_settings):
blacklisted = False blacklisted = False
try: try:
if trakt_blacklisted_show_year(show, blacklist_settings.blacklisted_min_year): if trakt_blacklisted_show_year(show, blacklist_settings.blacklisted_min_year,
blacklist_settings.blacklisted_max_year):
blacklisted = True blacklisted = True
if trakt_blacklisted_show_country(show, blacklist_settings.allowed_countries): if trakt_blacklisted_show_country(show, blacklist_settings.allowed_countries):
blacklisted = True blacklisted = True
@ -240,7 +241,7 @@ def trakt_blacklisted_movie_genre(movie, genres):
return blacklisted return blacklisted
def trakt_blacklisted_movie_year(movie, earliest_year): def trakt_blacklisted_movie_year(movie, earliest_year, latest_year):
blacklisted = False blacklisted = False
try: try:
year = movie['movie']['year'] year = movie['movie']['year']
@ -248,11 +249,11 @@ def trakt_blacklisted_movie_year(movie, earliest_year):
log.debug("%s was blacklisted due to having an unknown year", movie['movie']['title']) log.debug("%s was blacklisted due to having an unknown year", movie['movie']['title'])
blacklisted = True blacklisted = True
else: else:
if int(year) < earliest_year: if int(year) < earliest_year or int(year) > latest_year:
log.debug("%s was blacklisted because it's year is: %d", movie['movie']['title'], int(year)) log.debug("%s was blacklisted because it's year is: %d", movie['movie']['title'], int(year))
blacklisted = True blacklisted = True
except Exception: except Exception:
log.exception("Exception determining if movie is before earliest_year %s:", movie) log.exception("Exception determining if movie is within min_year and max_year ranger %s:", movie)
return blacklisted return blacklisted
@ -312,7 +313,8 @@ def trakt_is_movie_blacklisted(movie, blacklist_settings):
try: try:
if trakt_blacklisted_movie_title(movie, blacklist_settings.blacklist_title_keywords): if trakt_blacklisted_movie_title(movie, blacklist_settings.blacklist_title_keywords):
blacklisted = True blacklisted = True
if trakt_blacklisted_movie_year(movie, blacklist_settings.blacklisted_min_year): if trakt_blacklisted_movie_year(movie, blacklist_settings.blacklisted_min_year,
blacklist_settings.blacklisted_max_year):
blacklisted = True blacklisted = True
if trakt_blacklisted_movie_country(movie, blacklist_settings.allowed_countries): if trakt_blacklisted_movie_country(movie, blacklist_settings.allowed_countries):
blacklisted = True blacklisted = True

Loading…
Cancel
Save