fix for all movies being added to radarr

pull/240/head
meisnate12 4 years ago
parent 753f98659e
commit 380ab73f52

@ -207,8 +207,8 @@ class CollectionBuilder:
self.methods = [] self.methods = []
self.filters = [] self.filters = []
self.rating_keys = [] self.rating_keys = []
self.missing_movies = [] self.run_again_movies = []
self.missing_shows = [] self.run_again_shows = []
self.posters = {} self.posters = {}
self.backgrounds = {} self.backgrounds = {}
self.summaries = {} self.summaries = {}
@ -1343,7 +1343,7 @@ class CollectionBuilder:
elif "trakt" in method: check_map(self.config.Trakt.get_items(method, value, self.library.is_movie)) elif "trakt" in method: check_map(self.config.Trakt.get_items(method, value, self.library.is_movie))
else: logger.error(f"Collection Error: {method} method not supported") else: logger.error(f"Collection Error: {method} method not supported")
def add_to_collection(self, movie_map, show_map): def add_to_collection(self, movie_map):
name, collection_items = self.library.get_collection_name_and_items(self.obj if self.obj else self.name, self.smart_label_collection) name, collection_items = self.library.get_collection_name_and_items(self.obj if self.obj else self.name, self.smart_label_collection)
total = len(self.rating_keys) total = len(self.rating_keys)
max_length = len(str(total)) max_length = len(str(total))
@ -1466,15 +1466,15 @@ class CollectionBuilder:
media_type = f"{'Movie' if self.library.is_movie else 'Show'}{'s' if total > 1 else ''}" media_type = f"{'Movie' if self.library.is_movie else 'Show'}{'s' if total > 1 else ''}"
util.print_end(length, f"{total} {media_type} Processed") util.print_end(length, f"{total} {media_type} Processed")
def run_missing(self, missing_movies, missing_shows): def run_missing(self):
logger.info("") logger.info("")
arr_filters = [] arr_filters = []
for filter_method, filter_data in self.filters: for filter_method, filter_data in self.filters:
if (filter_method.startswith("original_language") and self.library.is_movie) or filter_method.startswith("tmdb_vote_count"): if (filter_method.startswith("original_language") and self.library.is_movie) or filter_method.startswith("tmdb_vote_count"):
arr_filters.append((filter_method, filter_data)) arr_filters.append((filter_method, filter_data))
if len(missing_movies) > 0: if len(self.missing_movies) > 0:
missing_movies_with_names = [] missing_movies_with_names = []
for missing_id in missing_movies: for missing_id in self.missing_movies:
try: try:
movie = self.config.TMDb.get_movie(missing_id) movie = self.config.TMDb.get_movie(missing_id)
except Failed as e: except Failed as e:
@ -1505,10 +1505,10 @@ class CollectionBuilder:
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
if self.run_again: if self.run_again:
self.missing_movies.extend(missing_tmdb_ids) self.run_again_movies.extend(missing_tmdb_ids)
if len(missing_shows) > 0 and self.library.is_show: if len(self.missing_shows) > 0 and self.library.is_show:
missing_shows_with_names = [] missing_shows_with_names = []
for missing_id in missing_shows: for missing_id in self.missing_shows:
try: try:
title = str(self.config.TVDb.get_series(self.library.Plex.language, missing_id).title.encode("ascii", "replace").decode()) title = str(self.config.TVDb.get_series(self.library.Plex.language, missing_id).title.encode("ascii", "replace").decode())
except Failed as e: except Failed as e:
@ -1539,7 +1539,7 @@ class CollectionBuilder:
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
if self.run_again: if self.run_again:
self.missing_shows.extend(missing_tvdb_ids) self.run_again_shows.extend(missing_tvdb_ids)
def sync_collection(self): def sync_collection(self):
logger.info("") logger.info("")
@ -1739,11 +1739,11 @@ class CollectionBuilder:
self.obj = self.library.get_collection(self.name) self.obj = self.library.get_collection(self.name)
name, collection_items = self.library.get_collection_name_and_items(self.obj, self.smart_label_collection) name, collection_items = self.library.get_collection_name_and_items(self.obj, self.smart_label_collection)
rating_keys = [] rating_keys = []
for mm in self.missing_movies: for mm in self.run_again_movies:
if mm in movie_map: if mm in movie_map:
rating_keys.extend(movie_map[mm]) rating_keys.extend(movie_map[mm])
if self.library.is_show: if self.library.is_show:
for sm in self.missing_shows: for sm in self.run_again_shows:
if sm in show_map: if sm in show_map:
rating_keys.extend(show_map[sm]) rating_keys.extend(show_map[sm])
if len(rating_keys) > 0: if len(rating_keys) > 0:
@ -1762,9 +1762,9 @@ class CollectionBuilder:
logger.info(f"{name} Collection | + | {current.title}") logger.info(f"{name} Collection | + | {current.title}")
logger.info(f"{len(rating_keys)} {'Movie' if self.library.is_movie else 'Show'}{'s' if len(rating_keys) > 1 else ''} Processed") logger.info(f"{len(rating_keys)} {'Movie' if self.library.is_movie else 'Show'}{'s' if len(rating_keys) > 1 else ''} Processed")
if len(self.missing_movies) > 0: if len(self.run_again_movies) > 0:
logger.info("") logger.info("")
for missing_id in self.missing_movies: for missing_id in self.run_again_movies:
if missing_id not in movie_map: if missing_id not in movie_map:
try: try:
movie = self.config.TMDb.get_movie(missing_id) movie = self.config.TMDb.get_movie(missing_id)
@ -1774,11 +1774,11 @@ class CollectionBuilder:
if self.details["show_missing"] is True: if self.details["show_missing"] is True:
logger.info(f"{name} Collection | ? | {movie.title} (TMDb: {missing_id})") logger.info(f"{name} Collection | ? | {movie.title} (TMDb: {missing_id})")
logger.info("") logger.info("")
logger.info(f"{len(self.missing_movies)} Movie{'s' if len(self.missing_movies) > 1 else ''} Missing") logger.info(f"{len(self.run_again_movies)} Movie{'s' if len(self.run_again_movies) > 1 else ''} Missing")
if len(self.missing_shows) > 0 and self.library.is_show: if len(self.run_again_shows) > 0 and self.library.is_show:
logger.info("") logger.info("")
for missing_id in self.missing_shows: for missing_id in self.run_again_shows:
if missing_id not in show_map: if missing_id not in show_map:
try: try:
title = str(self.config.TVDb.get_series(self.library.Plex.language, missing_id).title.encode("ascii", "replace").decode()) title = str(self.config.TVDb.get_series(self.library.Plex.language, missing_id).title.encode("ascii", "replace").decode())
@ -1787,4 +1787,4 @@ class CollectionBuilder:
continue continue
if self.details["show_missing"] is True: if self.details["show_missing"] is True:
logger.info(f"{name} Collection | ? | {title} (TVDb: {missing_id})") logger.info(f"{name} Collection | ? | {title} (TVDb: {missing_id})")
logger.info(f"{len(self.missing_shows)} Show{'s' if len(self.missing_shows) > 1 else ''} Missing") logger.info(f"{len(self.run_again_shows)} Show{'s' if len(self.run_again_shows) > 1 else ''} Missing")

@ -308,7 +308,7 @@ class Convert:
else: else:
tmdb_id = self.imdb_to_tmdb(imdb_id) tmdb_id = self.imdb_to_tmdb(imdb_id)
if not tmdb_id: if not tmdb_id:
raise Failed(f"Unable to convert IMDb ID: {imdb_id} to TMDb ID") raise Failed(f"Unable to convert IMDb ID: {util.compile_list(imdb_id)} to TMDb ID")
if not anidb_id and not tvdb_id and tmdb_id and library.is_show: if not anidb_id and not tvdb_id and tmdb_id and library.is_show:
if isinstance(tmdb_id, list): if isinstance(tmdb_id, list):
tvdb_id = [] tvdb_id = []
@ -320,7 +320,7 @@ class Convert:
else: else:
tvdb_id = self.tmdb_to_tvdb(tmdb_id) tvdb_id = self.tmdb_to_tvdb(tmdb_id)
if not tvdb_id: if not tvdb_id:
raise Failed(f"Unable to convert TMDb ID: {tmdb_id} to TVDb ID") raise Failed(f"Unable to convert TMDb ID: {util.compile_list(tmdb_id)} to TVDb ID")
if tvdb_id: if tvdb_id:
if isinstance(tvdb_id, list): if isinstance(tvdb_id, list):

@ -368,16 +368,16 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
builder.collect_rating_keys(movie_map, show_map) builder.collect_rating_keys(movie_map, show_map)
logger.info("") logger.info("")
if len(builder.rating_keys) > 0: if len(builder.rating_keys) > 0:
builder.add_to_collection(movie_map, show_map) builder.add_to_collection(movie_map)
if len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0: if len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0:
builder.run_missing(movie_map, show_map) builder.run_missing()
if builder.sync and len(builder.rating_keys) > 0: if builder.sync and len(builder.rating_keys) > 0:
builder.sync_collection() builder.sync_collection()
logger.info("") logger.info("")
builder.update_details() builder.update_details()
if builder.run_again and (len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0): if builder.run_again and (len(builder.run_again_movies) > 0 or len(builder.run_again_shows) > 0):
library.run_again.append(builder) library.run_again.append(builder)
except Failed as e: except Failed as e:

Loading…
Cancel
Save