Skip to content

Commit

Permalink
#5 Works with multiple versions of a movie
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Apr 22, 2021
1 parent 66e6e42 commit 93c3120
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
18 changes: 12 additions & 6 deletions modules/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,14 +1009,16 @@ def check_map(input_ids):
items_found_inside += len(movie_ids)
for movie_id in movie_ids:
if movie_id in movie_map:
items.append(movie_map[movie_id])
items.extend(movie_map[movie_id])
else:
missing_movies.append(movie_id)
if len(show_ids) > 0:
items_found_inside += len(show_ids)
for show_id in show_ids:
if show_id in show_map: items.append(show_map[show_id])
else: missing_shows.append(show_id)
if show_id in show_map:
items.extend(show_map[show_id])
else:
missing_shows.append(show_id)
return items_found_inside
logger.info("")
logger.debug(f"Value: {value}")
Expand Down Expand Up @@ -1325,10 +1327,14 @@ def set_image(image_method, images, is_background=False):
def run_collections_again(self, collection_obj, movie_map, show_map):
collection_items = collection_obj.items() if isinstance(collection_obj, Collections) else []
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:
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:
for rating_key in rating_keys:
try:
Expand Down
37 changes: 28 additions & 9 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,10 @@ def update_libraries(self, test, requested_collections, resume_from):
util.print_stacktrace()
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():
folder = os.path.basename(os.path.dirname(item.locations[0]) if library.is_movie else item.locations[0])
for ad in library.asset_directory:
Expand Down Expand Up @@ -797,13 +800,13 @@ def mass_metadata(self, library, movie_map, show_map):
if self.Cache:
ids, expired = self.Cache.get_ids("movie" if library.is_movie else "show", plex_guid=item.guid)
elif library.is_movie:
for tmdb in movie_map:
if movie_map[tmdb] == item.ratingKey:
for tmdb, rating_keys in movie_map.items():
if item.ratingKey in rating_keys:
ids["tmdb"] = tmdb
break
else:
for tvdb in show_map:
if show_map[tvdb] == item.ratingKey:
for tvdb, rating_keys in show_map.items():
if item.ratingKey in rating_keys:
ids["tvdb"] = tvdb
break

Expand Down Expand Up @@ -859,12 +862,28 @@ def map_guids(self, library):
continue
if isinstance(main_id, list):
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: show_map[m] = item.ratingKey
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": movie_map[main_id] = item.ratingKey
elif id_type == "show": show_map[main_id] = item.ratingKey
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":
if main_id in show_map:
show_map[main_id].append(item.ratingKey)
else:
show_map[main_id] = [item.ratingKey]
util.print_end(length, f"Processed {len(items)} {'Movies' if library.is_movie else 'Shows'}")
return movie_map, show_map

Expand Down
4 changes: 2 additions & 2 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def add_to_collection(self, collection, items, filters, show_filtered, rating_ke
elif method_name == "original_language":
movie = None
for key, value in movie_map.items():
if current.ratingKey == value:
if current.ratingKey in value:
try:
movie = self.TMDb.get_movie(key)
break
Expand Down Expand Up @@ -445,7 +445,7 @@ def add_to_collection(self, collection, items, filters, show_filtered, rating_ke
if method_name == "vote_count":
tmdb_item = None
for key, value in movie_map.items():
if current.ratingKey == value:
if current.ratingKey in value:
try:
tmdb_item = self.TMDb.get_movie(key) if self.is_movie else self.TMDb.get_show(key)
break
Expand Down
2 changes: 1 addition & 1 deletion plex_meta_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def fmt_filter(record):
util.centered("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | ")
util.centered("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| ")
util.centered(" |___/ ")
util.centered(" Version: 1.7.2-Beta9 ")
util.centered(" Version: 1.7.2-Beta10 ")
util.separator()

if my_tests:
Expand Down

0 comments on commit 93c3120

Please sign in to comment.