diff --git a/modules/builder.py b/modules/builder.py index d211df1d..7ac0b2b0 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -523,7 +523,7 @@ class CollectionBuilder: final_values = method_data search = os.path.splitext(method_name)[0] valid_values = self.library.validate_search_list(final_values, search) - if valid_values: + if len(valid_values) > 0: self.methods.append(("plex_search", [{method_name: valid_values}])) else: logger.warning(f"Collection Warning: No valid {search} values found in {final_values}") diff --git a/modules/plex.py b/modules/plex.py index f54a5808..e0c65b5f 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -576,11 +576,11 @@ class PlexAPI: logger.error(f"Metadata Error: {attr} attribute only works for show libraries") elif meta[methods[attr]]: method_data = str(meta[methods[attr]]).lower() - if method_data in options and getattr(item, key) != options[method_data]: + if method_data not in options: + logger.error(f"Metadata Error: {meta[methods[attr]]} {attr} attribute invalid") + elif getattr(item, key) != options[method_data]: advance_edits[key] = options[method_data] logger.info(f"Detail: {attr} updated to {method_data}") - else: - logger.error(f"Metadata Error: {meta[methods[attr]]} {attr} attribute invalid") else: logger.error(f"Metadata Error: {attr} attribute is blank") @@ -644,14 +644,22 @@ class PlexAPI: edit_tags("producer", item, movie_library=True) edit_tags("writer", item, movie_library=True) + logger.info(f"{item_type}: {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") + if "seasons" in methods and self.is_show: if meta[methods["seasons"]]: for season_id in meta[methods["seasons"]]: + updated = False logger.info("") logger.info(f"Updating season {season_id} of {mapping_name}...") if isinstance(season_id, int): - try: season = item.season(season_id) - except NotFound: logger.error(f"Metadata Error: Season: {season_id} not found") + season = None + for s in item.seasons(): + if s.index == season_id: + season = s + break + if season is None: + logger.error(f"Metadata Error: Season: {season_id} not found") else: season_dict = meta[methods["seasons"]][season_id] season_methods = {sm.lower(): sm for sm in season_dict} @@ -685,6 +693,7 @@ class PlexAPI: logger.error(f"Season: {season_id} Details Update Failed") else: logger.error(f"Metadata Error: Season: {season_id} invalid, it must be an integer") + logger.info(f"Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") else: logger.error("Metadata Error: seasons attribute is blank") elif "seasons" in methods: @@ -693,10 +702,13 @@ class PlexAPI: if "episodes" in methods and self.is_show: if meta[methods["episodes"]]: for episode_str in meta[methods["episodes"]]: + updated = False logger.info("") match = re.search("[Ss]\\d+[Ee]\\d+", episode_str) if match: output = match.group(0)[1:].split("E" if "E" in match.group(0) else "e") + season_str = output[0] + episode_str = output[1] season_id = int(output[0]) episode_id = int(output[1]) logger.info(f"Updating episode S{episode_id}E{season_id} of {mapping_name}...") @@ -738,13 +750,10 @@ class PlexAPI: logger.error(f"Season: {season_id} Episode: {episode_id} Details Update Failed") edit_tags("director", episode) edit_tags("writer", episode) - + logger.info(f"Episode S{episode_id}E{season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") else: logger.error(f"Metadata Error: episode {episode_str} invalid must have S##E## format") else: logger.error("Metadata Error: episodes attribute is blank") elif "episodes" in methods: logger.error("Metadata Error: episodes attribute only works for show libraries") - - if not updated: - logger.info(f"{item_type}: {mapping_name} Details Update Not Needed") \ No newline at end of file