|
|
@ -4,29 +4,32 @@ from misc.log import logger
|
|
|
|
log = logger.get_logger(__name__)
|
|
|
|
log = logger.get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_show_genre(show, genres):
|
|
|
|
def extract_list_user_and_key_from_url(list_url):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
list_user = re.search('\/users\/([^/]*)', list_url).group(1)
|
|
|
|
|
|
|
|
list_key = re.search('\/lists\/([^/]*)', list_url).group(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list_user, list_key
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
log.error('The URL "%s" is not in the correct format', list_url)
|
|
|
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_show_id(show, blacklisted_ids):
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
|
|
|
|
blacklisted_ids = sorted(map(int, blacklisted_ids))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# ["ignore"] - add show item even if it is missing a genre
|
|
|
|
if not show['show']['ids']['tvdb'] or not isinstance(show['show']['ids']['tvdb'], int):
|
|
|
|
if len(genres) == 1 and genres[0].lower() == 'ignore':
|
|
|
|
log.debug("\'%s\' was blacklisted because it had an invalid TVDB ID", show['show']['title'])
|
|
|
|
log.debug("Skipping valid genre check for: \'%s\'", show['show']['title'])
|
|
|
|
blacklisted = True
|
|
|
|
elif not show['show']['genres']:
|
|
|
|
elif show['show']['ids']['tvdb'] in blacklisted_ids:
|
|
|
|
log.debug("\'%s\' was blacklisted because it had no genre", show['show']['title'])
|
|
|
|
log.debug("\'%s\' was blacklisted because it had a blacklisted TVDB ID of: %d", show['show']['title'],
|
|
|
|
|
|
|
|
show['show']['ids']['tvdb'])
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
# [] - add show item with any valid genre
|
|
|
|
|
|
|
|
elif not genres:
|
|
|
|
|
|
|
|
log.debug("Skipping blacklisted genre check for: \'%s\'", show['show']['title'])
|
|
|
|
|
|
|
|
# List provided - skip adding show item if the genre is blacklisted
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for genre in genres:
|
|
|
|
|
|
|
|
if genre.lower() in show['show']['genres']:
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it was from the genre: %s", show['show']['title'],
|
|
|
|
|
|
|
|
genre.title())
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
log.exception("Exception determining if show has a blacklisted genre %s: ", show)
|
|
|
|
log.exception("Exception determining if show had a blacklisted TVDB ID %s: ", show)
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,6 +49,25 @@ def blacklisted_show_year(show, earliest_year, latest_year):
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_show_network(show, networks):
|
|
|
|
|
|
|
|
blacklisted = False
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if not show['show']['network']:
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it had no network", show['show']['title'])
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
for network in networks:
|
|
|
|
|
|
|
|
if network.lower() in show['show']['network'].lower():
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it's from the network: %s", show['show']['title'],
|
|
|
|
|
|
|
|
show['show']['network'])
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
log.exception("Exception determining if show is from a blacklisted network %s: ", show)
|
|
|
|
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_show_country(show, allowed_countries):
|
|
|
|
def blacklisted_show_country(show, allowed_countries):
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -70,22 +92,29 @@ def blacklisted_show_country(show, allowed_countries):
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_show_network(show, networks):
|
|
|
|
def blacklisted_show_genre(show, genres):
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if not show['show']['network']:
|
|
|
|
# ["ignore"] - add show item even if it is missing a genre
|
|
|
|
log.debug("\'%s\' was blacklisted because it had no network", show['show']['title'])
|
|
|
|
if len(genres) == 1 and genres[0].lower() == 'ignore':
|
|
|
|
|
|
|
|
log.debug("Skipping valid genre check for: \'%s\'", show['show']['title'])
|
|
|
|
|
|
|
|
elif not show['show']['genres']:
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it had no genre", show['show']['title'])
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
# [] - add show item with any valid genre
|
|
|
|
|
|
|
|
elif not genres:
|
|
|
|
|
|
|
|
log.debug("Skipping blacklisted genre check for: \'%s\'", show['show']['title'])
|
|
|
|
|
|
|
|
# List provided - skip adding show item if the genre is blacklisted
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for network in networks:
|
|
|
|
for genre in genres:
|
|
|
|
if network.lower() in show['show']['network'].lower():
|
|
|
|
if genre.lower() in show['show']['genres']:
|
|
|
|
log.debug("\'%s\' was blacklisted because it's from the network: %s", show['show']['title'],
|
|
|
|
log.debug("\'%s\' was blacklisted because it was from the genre: %s", show['show']['title'],
|
|
|
|
show['show']['network'])
|
|
|
|
genre.title())
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
log.exception("Exception determining if show is from a blacklisted network %s: ", show)
|
|
|
|
log.exception("Exception determining if show has a blacklisted genre %s: ", show)
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -105,42 +134,25 @@ def blacklisted_show_runtime(show, lowest_runtime):
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_show_id(show, blacklisted_ids):
|
|
|
|
|
|
|
|
blacklisted = False
|
|
|
|
|
|
|
|
blacklisted_ids = sorted(map(int, blacklisted_ids))
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if not show['show']['ids']['tvdb'] or not isinstance(show['show']['ids']['tvdb'], int):
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it had an invalid TVDB ID", show['show']['title'])
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
elif show['show']['ids']['tvdb'] in blacklisted_ids:
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it had a blacklisted TVDB ID of: %d", show['show']['title'],
|
|
|
|
|
|
|
|
show['show']['ids']['tvdb'])
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
log.exception("Exception determining if show had a blacklisted TVDB ID %s: ", show)
|
|
|
|
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_show_blacklisted(show, blacklist_settings, ignore_blacklist, callback=None):
|
|
|
|
def is_show_blacklisted(show, blacklist_settings, ignore_blacklist, callback=None):
|
|
|
|
if ignore_blacklist:
|
|
|
|
if ignore_blacklist:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
if blacklisted_show_id(show, blacklist_settings.blacklisted_tvdb_ids):
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_show_year(show, blacklist_settings.blacklisted_min_year,
|
|
|
|
if blacklisted_show_year(show, blacklist_settings.blacklisted_min_year,
|
|
|
|
blacklist_settings.blacklisted_max_year):
|
|
|
|
blacklist_settings.blacklisted_max_year):
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
if blacklisted_show_network(show, blacklist_settings.blacklisted_networks):
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_show_country(show, blacklist_settings.allowed_countries):
|
|
|
|
if blacklisted_show_country(show, blacklist_settings.allowed_countries):
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_show_genre(show, blacklist_settings.blacklisted_genres):
|
|
|
|
if blacklisted_show_genre(show, blacklist_settings.blacklisted_genres):
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_show_network(show, blacklist_settings.blacklisted_networks):
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
if blacklisted_show_runtime(show, blacklist_settings.blacklisted_min_runtime):
|
|
|
|
if blacklisted_show_runtime(show, blacklist_settings.blacklisted_min_runtime):
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_show_id(show, blacklist_settings.blacklisted_tvdb_ids):
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if blacklisted and callback:
|
|
|
|
if blacklisted and callback:
|
|
|
|
callback('show', show)
|
|
|
|
callback('show', show)
|
|
|
@ -150,29 +162,36 @@ def is_show_blacklisted(show, blacklist_settings, ignore_blacklist, callback=Non
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_movie_genre(movie, genres):
|
|
|
|
def blacklisted_movie_id(movie, blacklisted_ids):
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
|
|
|
|
blacklisted_ids = sorted(map(int, blacklisted_ids))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# ["ignore"] - add movie item even if it is missing a genre
|
|
|
|
if movie['movie']['ids']['tmdb'] in blacklisted_ids:
|
|
|
|
if len(genres) == 1 and genres[0].lower() == 'ignore':
|
|
|
|
log.debug("\'%s\' was blacklisted because it had a blacklisted TMDb ID of: %d", movie['movie']['title'],
|
|
|
|
log.debug("Skipping valid genre check for: \'%s\'", movie['movie']['title'])
|
|
|
|
movie['movie']['ids']['tmdb'])
|
|
|
|
elif not movie['movie']['genres']:
|
|
|
|
blacklisted = True
|
|
|
|
log.debug("\'%s\' was blacklisted because it had no genre", movie['movie']['title'])
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
log.exception("Exception determining if movie had a blacklisted TMDb ID %s: ", movie)
|
|
|
|
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_movie_title(movie, blacklisted_keywords):
|
|
|
|
|
|
|
|
blacklisted = False
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if not movie['movie']['title']:
|
|
|
|
|
|
|
|
log.debug("Blacklisted movie because it had no title: %s", movie)
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
# [] - add movie item with any valid genre
|
|
|
|
|
|
|
|
elif not genres:
|
|
|
|
|
|
|
|
log.debug("Skipping blacklisted genre check for: \'%s\'", movie['movie']['title'])
|
|
|
|
|
|
|
|
# List provided - skip adding movie item if the genre is blacklisted
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for genre in genres:
|
|
|
|
for keyword in blacklisted_keywords:
|
|
|
|
if genre.lower() in movie['movie']['genres']:
|
|
|
|
if keyword.lower() in movie['movie']['title'].lower():
|
|
|
|
log.debug("%s was blacklisted because it was from the genre: %s", movie['movie']['title'],
|
|
|
|
log.debug("\'%s\' was blacklisted because it had title keyword: %s", movie['movie']['title'],
|
|
|
|
genre.title())
|
|
|
|
keyword)
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
log.exception("Exception determining if movie has a blacklisted genre %s: ", movie)
|
|
|
|
log.exception("Exception determining if movie had a blacklisted title %s: ", movie)
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -215,22 +234,29 @@ def blacklisted_movie_country(movie, allowed_countries):
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_movie_title(movie, blacklisted_keywords):
|
|
|
|
def blacklisted_movie_genre(movie, genres):
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if not movie['movie']['title']:
|
|
|
|
# ["ignore"] - add movie item even if it is missing a genre
|
|
|
|
log.debug("Blacklisted movie because it had no title: %s", movie)
|
|
|
|
if len(genres) == 1 and genres[0].lower() == 'ignore':
|
|
|
|
|
|
|
|
log.debug("Skipping valid genre check for: \'%s\'", movie['movie']['title'])
|
|
|
|
|
|
|
|
elif not movie['movie']['genres']:
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it had no genre", movie['movie']['title'])
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
# [] - add movie item with any valid genre
|
|
|
|
|
|
|
|
elif not genres:
|
|
|
|
|
|
|
|
log.debug("Skipping blacklisted genre check for: \'%s\'", movie['movie']['title'])
|
|
|
|
|
|
|
|
# List provided - skip adding movie item if the genre is blacklisted
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for keyword in blacklisted_keywords:
|
|
|
|
for genre in genres:
|
|
|
|
if keyword.lower() in movie['movie']['title'].lower():
|
|
|
|
if genre.lower() in movie['movie']['genres']:
|
|
|
|
log.debug("\'%s\' was blacklisted because it had title keyword: %s", movie['movie']['title'],
|
|
|
|
log.debug("%s was blacklisted because it was from the genre: %s", movie['movie']['title'],
|
|
|
|
keyword)
|
|
|
|
genre.title())
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
log.exception("Exception determining if movie had a blacklisted title %s: ", movie)
|
|
|
|
log.exception("Exception determining if movie has a blacklisted genre %s: ", movie)
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -250,26 +276,14 @@ def blacklisted_movie_runtime(movie, lowest_runtime):
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def blacklisted_movie_id(movie, blacklisted_ids):
|
|
|
|
|
|
|
|
blacklisted = False
|
|
|
|
|
|
|
|
blacklisted_ids = sorted(map(int, blacklisted_ids))
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if movie['movie']['ids']['tmdb'] in blacklisted_ids:
|
|
|
|
|
|
|
|
log.debug("\'%s\' was blacklisted because it had a blacklisted TMDb ID of: %d", movie['movie']['title'],
|
|
|
|
|
|
|
|
movie['movie']['ids']['tmdb'])
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
log.exception("Exception determining if movie had a blacklisted TMDb ID %s: ", movie)
|
|
|
|
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_movie_blacklisted(movie, blacklist_settings, ignore_blacklist, callback=None):
|
|
|
|
def is_movie_blacklisted(movie, blacklist_settings, ignore_blacklist, callback=None):
|
|
|
|
if ignore_blacklist:
|
|
|
|
if ignore_blacklist:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
blacklisted = False
|
|
|
|
blacklisted = False
|
|
|
|
try:
|
|
|
|
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.blacklist_title_keywords):
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_movie_year(movie, blacklist_settings.blacklisted_min_year,
|
|
|
|
if blacklisted_movie_year(movie, blacklist_settings.blacklisted_min_year,
|
|
|
@ -281,8 +295,6 @@ def is_movie_blacklisted(movie, blacklist_settings, ignore_blacklist, callback=N
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_movie_runtime(movie, blacklist_settings.blacklisted_min_runtime):
|
|
|
|
if blacklisted_movie_runtime(movie, blacklist_settings.blacklisted_min_runtime):
|
|
|
|
blacklisted = True
|
|
|
|
blacklisted = True
|
|
|
|
if blacklisted_movie_id(movie, blacklist_settings.blacklisted_tmdb_ids):
|
|
|
|
|
|
|
|
blacklisted = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if blacklisted and callback:
|
|
|
|
if blacklisted and callback:
|
|
|
|
callback('movie', movie)
|
|
|
|
callback('movie', movie)
|
|
|
@ -290,15 +302,3 @@ def is_movie_blacklisted(movie, blacklist_settings, ignore_blacklist, callback=N
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
log.exception("Exception determining if movie was blacklisted %s: ", movie)
|
|
|
|
log.exception("Exception determining if movie was blacklisted %s: ", movie)
|
|
|
|
return blacklisted
|
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def extract_list_user_and_key_from_url(list_url):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
list_user = re.search('\/users\/([^/]*)', list_url).group(1)
|
|
|
|
|
|
|
|
list_key = re.search('\/lists\/([^/]*)', list_url).group(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list_user, list_key
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
log.error('The URL "%s" is not in the correct format', list_url)
|
|
|
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|