From af96c2544a3a29b75020f0e90adb7ca2d935dc49 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 8 Dec 2021 23:57:00 -0500 Subject: [PATCH] added deleted to the collection webhook --- modules/builder.py | 3 +++ modules/webhooks.py | 3 ++- plex_meta_manager.py | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/builder.py b/modules/builder.py index 9c8127c0..6e72ea22 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -213,6 +213,7 @@ class CollectionBuilder: self.current_year = self.current_time.year self.exists = False self.created = False + self.deleted = False methods = {m.lower(): m for m in self.data} @@ -444,6 +445,7 @@ class CollectionBuilder: try: self.obj = self.library.get_collection(self.name) self.delete_collection() + self.deleted = True suffix = f" and was deleted" except Failed: suffix = f" and could not be found to delete" @@ -2180,6 +2182,7 @@ class CollectionBuilder: self.details["collection_changes_webhooks"], self.obj, created=self.created, + deleted=self.deleted, additions=self.notification_additions, removals=self.notification_removals ) diff --git a/modules/webhooks.py b/modules/webhooks.py index 3a67e7c0..c7cfe135 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -70,7 +70,7 @@ class Webhooks: json["collection"] = str(collection) self._request(self.error_webhooks, json) - def collection_hooks(self, webhooks, collection, created=False, additions=None, removals=None): + def collection_hooks(self, webhooks, collection, created=False, deleted=False, additions=None, removals=None): if self.library: thumb = None if collection.thumb and next((f for f in collection.fields if f.name == "thumb"), None): @@ -84,6 +84,7 @@ class Webhooks: "type": "movie" if self.library.is_movie else "show", "collection": collection.title, "created": created, + "deleted": deleted, "poster": thumb, "background": art } diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 7b06e942..cd43667c 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -679,7 +679,7 @@ def run_collection(config, library, metadata, requested_collections): logger.info(f"Collection Minimum: {builder.minimum} not met for {mapping_name} Collection") if builder.details["delete_below_minimum"] and builder.obj: builder.delete_collection() - stats["deleted"] += 1 + builder.deleted = True logger.info("") logger.info(f"Collection {builder.obj.title} deleted") @@ -711,6 +711,9 @@ def run_collection(config, library, metadata, requested_collections): library.run_sort.append(builder) # builder.sort_collection() + if builder.deleted: + stats["deleted"] += 1 + if builder.server_preroll is not None: library.set_server_preroll(builder.server_preroll) logger.info("")