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
pull/2001/head
jz1 7 months ago
parent 62795840f7
commit ee4f832839

@ -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"):

@ -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:

Loading…
Cancel
Save