From 5170444ffc9a445b28f58cd51f4aa43539df8d3f Mon Sep 17 00:00:00 2001 From: sysmoon14 <61550824+sysmoon14@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:41:19 +0000 Subject: [PATCH] Update builder.py to pass parameters for batch edits Moved alter_collections call and passed through items_added and items_removed so that batchEdits can be used in plex.py --- modules/builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/builder.py b/modules/builder.py index a537e7e9..3c4e0eeb 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -2515,8 +2515,6 @@ class CollectionBuilder: amount_unchanged += 1 else: items_added.append(item) - if not self.playlist: - self.library.alter_collection(item, name, smart_label_collection=self.smart_label_collection) amount_added += 1 if self.details["changes_webhooks"]: self.notification_additions.append(util.item_set(item, self.library.get_id_from_maps(item.ratingKey))) @@ -2526,6 +2524,8 @@ class CollectionBuilder: logger.info(f"Playlist: {self.name} created") elif self.playlist and items_added: self.obj.addItems(items_added) + elif items_added: + self.library.alter_collection(items_added, name, smart_label_collection=self.smart_label_collection) if self.do_report and items_added: self.library.add_additions(self.name, [(i.title, self.library.get_id_from_maps(i.ratingKey)) for i in items_added], self.library.is_movie) logger.exorcise() @@ -2548,14 +2548,14 @@ class CollectionBuilder: number_text = f"{i}/{total}" logger.info(f"{number_text:>{spacing}} | {self.name} {self.Type} | - | {util.item_title(item)}") items_removed.append(item) - if not self.playlist: - self.library.alter_collection(item, self.name, smart_label_collection=self.smart_label_collection, add=False) amount_removed += 1 if self.details["changes_webhooks"]: self.notification_removals.append(util.item_set(item, self.library.get_id_from_maps(item.ratingKey))) if self.playlist and items_removed: self.library._reload(self.obj) self.obj.removeItems(items_removed) + elif items_removed: + self.library.alter_collection(items_removed, self.name, smart_label_collection=self.smart_label_collection, add=False) if self.do_report and items_removed: self.library.add_removed(self.name, [(i.title, self.library.get_id_from_maps(i.ratingKey)) for i in items_removed], self.library.is_movie) logger.info("")