#5 Works with multiple versions of a movie

pull/211/head
meisnate12 4 years ago
parent 66e6e42acd
commit 93c3120090

@ -1009,14 +1009,16 @@ class CollectionBuilder:
items_found_inside += len(movie_ids) items_found_inside += len(movie_ids)
for movie_id in movie_ids: for movie_id in movie_ids:
if movie_id in movie_map: if movie_id in movie_map:
items.append(movie_map[movie_id]) items.extend(movie_map[movie_id])
else: else:
missing_movies.append(movie_id) missing_movies.append(movie_id)
if len(show_ids) > 0: if len(show_ids) > 0:
items_found_inside += len(show_ids) items_found_inside += len(show_ids)
for show_id in show_ids: for show_id in show_ids:
if show_id in show_map: items.append(show_map[show_id]) if show_id in show_map:
else: missing_shows.append(show_id) items.extend(show_map[show_id])
else:
missing_shows.append(show_id)
return items_found_inside return items_found_inside
logger.info("") logger.info("")
logger.debug(f"Value: {value}") logger.debug(f"Value: {value}")
@ -1325,10 +1327,14 @@ class CollectionBuilder:
def run_collections_again(self, collection_obj, movie_map, show_map): def run_collections_again(self, collection_obj, movie_map, show_map):
collection_items = collection_obj.items() if isinstance(collection_obj, Collections) else [] collection_items = collection_obj.items() if isinstance(collection_obj, Collections) else []
name = collection_obj.title if isinstance(collection_obj, Collections) else collection_obj name = collection_obj.title if isinstance(collection_obj, Collections) else collection_obj
rating_keys = [movie_map[mm] for mm in self.missing_movies if mm in movie_map] rating_keys = []
for mm in self.missing_movies:
if mm in movie_map:
rating_keys.extend(movie_map[mm])
if self.library.is_show: if self.library.is_show:
rating_keys.extend([show_map[sm] for sm in self.missing_shows if sm in show_map]) for sm in self.missing_shows:
if sm in show_map:
rating_keys.extend(show_map[sm])
if len(rating_keys) > 0: if len(rating_keys) > 0:
for rating_key in rating_keys: for rating_key in rating_keys:
try: try:

@ -553,7 +553,10 @@ class Config:
util.print_stacktrace() util.print_stacktrace()
logger.error(f"Unknown Error: {e}") logger.error(f"Unknown Error: {e}")
if library.assets_for_all: if library.assets_for_all is True and not test and not requested_collections:
logger.info("")
util.separator(f"All {'Movies' if library.is_movie else 'Shows'} Assets Check for {library.name} Library")
logger.info("")
for item in library.get_all(): for item in library.get_all():
folder = os.path.basename(os.path.dirname(item.locations[0]) if library.is_movie else item.locations[0]) folder = os.path.basename(os.path.dirname(item.locations[0]) if library.is_movie else item.locations[0])
for ad in library.asset_directory: for ad in library.asset_directory:
@ -797,13 +800,13 @@ class Config:
if self.Cache: if self.Cache:
ids, expired = self.Cache.get_ids("movie" if library.is_movie else "show", plex_guid=item.guid) ids, expired = self.Cache.get_ids("movie" if library.is_movie else "show", plex_guid=item.guid)
elif library.is_movie: elif library.is_movie:
for tmdb in movie_map: for tmdb, rating_keys in movie_map.items():
if movie_map[tmdb] == item.ratingKey: if item.ratingKey in rating_keys:
ids["tmdb"] = tmdb ids["tmdb"] = tmdb
break break
else: else:
for tvdb in show_map: for tvdb, rating_keys in show_map.items():
if show_map[tvdb] == item.ratingKey: if item.ratingKey in rating_keys:
ids["tvdb"] = tvdb ids["tvdb"] = tvdb
break break
@ -859,12 +862,28 @@ class Config:
continue continue
if isinstance(main_id, list): if isinstance(main_id, list):
if id_type == "movie": if id_type == "movie":
for m in main_id: movie_map[m] = item.ratingKey for m in main_id:
if m in movie_map:
movie_map[m].append(item.ratingKey)
else:
movie_map[m] = [item.ratingKey]
elif id_type == "show":
for m in main_id:
if m in show_map:
show_map[m].append(item.ratingKey)
else:
show_map[m] = [item.ratingKey]
else:
if id_type == "movie":
if main_id in movie_map:
movie_map[main_id].append(item.ratingKey)
else:
movie_map[main_id] = [item.ratingKey]
elif id_type == "show": elif id_type == "show":
for m in main_id: show_map[m] = item.ratingKey if main_id in show_map:
show_map[main_id].append(item.ratingKey)
else: else:
if id_type == "movie": movie_map[main_id] = item.ratingKey show_map[main_id] = [item.ratingKey]
elif id_type == "show": show_map[main_id] = item.ratingKey
util.print_end(length, f"Processed {len(items)} {'Movies' if library.is_movie else 'Shows'}") util.print_end(length, f"Processed {len(items)} {'Movies' if library.is_movie else 'Shows'}")
return movie_map, show_map return movie_map, show_map

@ -413,7 +413,7 @@ class PlexAPI:
elif method_name == "original_language": elif method_name == "original_language":
movie = None movie = None
for key, value in movie_map.items(): for key, value in movie_map.items():
if current.ratingKey == value: if current.ratingKey in value:
try: try:
movie = self.TMDb.get_movie(key) movie = self.TMDb.get_movie(key)
break break
@ -445,7 +445,7 @@ class PlexAPI:
if method_name == "vote_count": if method_name == "vote_count":
tmdb_item = None tmdb_item = None
for key, value in movie_map.items(): for key, value in movie_map.items():
if current.ratingKey == value: if current.ratingKey in value:
try: try:
tmdb_item = self.TMDb.get_movie(key) if self.is_movie else self.TMDb.get_show(key) tmdb_item = self.TMDb.get_movie(key) if self.is_movie else self.TMDb.get_show(key)
break break

@ -89,7 +89,7 @@ util.centered("| |_) | |/ _ \\ \\/ / | |\\/| |/ _ \\ __/ _` | | |\\/| |/ _` | '_
util.centered("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | ") util.centered("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | ")
util.centered("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| ") util.centered("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| ")
util.centered(" |___/ ") util.centered(" |___/ ")
util.centered(" Version: 1.7.2-Beta9 ") util.centered(" Version: 1.7.2-Beta10 ")
util.separator() util.separator()
if my_tests: if my_tests:

Loading…
Cancel
Save