From ee4f832839639907b34b1cf1e1dbe3ca4839d5dc Mon Sep 17 00:00:00 2001 From: jz1 Date: Wed, 24 Apr 2024 19:20:36 +0200 Subject: [PATCH] Fix for non_item_remove_label to always run when defined It need's to run even when there's no collection items, to remove the labels. Matches every movie/show that has the given label and is not in the collection and removes the label --- kometa.py | 3 +++ modules/builder.py | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/kometa.py b/kometa.py index 21f775f2..28dca055 100644 --- a/kometa.py +++ b/kometa.py @@ -885,6 +885,9 @@ def run_collection(config, library, metadata, requested_collections): except NonExisting as e: logger.warning(e) library.status[str(mapping_name)]["status"] = "Ignored" + if builder.item_details: + no_items = True + builder.update_item_details(no_items) except NotScheduled as e: logger.info(e) if str(e).endswith("and was deleted"): diff --git a/modules/builder.py b/modules/builder.py index 93cd5e87..58e7775a 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -3153,10 +3153,19 @@ class CollectionBuilder: if not self.items: raise Failed(f"Plex Error: No {self.Type} items found") - def update_item_details(self): - logger.info("") - logger.separator(f"Updating Metadata of the Items in {self.name} {self.Type}", space=False, border=False) - logger.info("") + def update_item_details(self, no_items=False): + if (no_items and "non_item_remove_label" in self.item_details) or not no_items: + logger.info("") + logger.separator(f"Updating Metadata of the Items in {self.name} {self.Type}", space=False, border=False) + logger.info("") + + if "non_item_remove_label" in self.item_details: + rk_compare = [item.ratingKey for item in self.items] + for non_item in self.library.search(label=self.item_details["non_item_remove_label"], libtype=self.builder_level): + if non_item.ratingKey not in rk_compare: + self.library.edit_tags("label", non_item, remove_tags=self.item_details["non_item_remove_label"]) + if no_items: + return add_tags = self.item_details["item_label"] if "item_label" in self.item_details else None remove_tags = self.item_details["item_label.remove"] if "item_label.remove" in self.item_details else None @@ -3166,12 +3175,6 @@ class CollectionBuilder: remove_genres = self.item_details["item_genre.remove"] if "item_genre.remove" in self.item_details else None sync_genres = self.item_details["item_genre.sync"] if "item_genre.sync" in self.item_details else None - if "non_item_remove_label" in self.item_details: - rk_compare = [item.ratingKey for item in self.items] - for non_item in self.library.search(label=self.item_details["non_item_remove_label"], libtype=self.builder_level): - if non_item.ratingKey not in rk_compare: - self.library.edit_tags("label", non_item, remove_tags=self.item_details["non_item_remove_label"]) - tmdb_paths = [] tvdb_paths = [] for item in self.items: