From 73081cca1fc7dac621a63b07932e9f59f6cb2937 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 28 Dec 2022 15:32:13 -0500 Subject: [PATCH] [9] add event to webhooks --- CHANGELOG | 5 ++++- VERSION | 2 +- docs/config/webhooks.md | 9 +++++++++ modules/webhooks.py | 10 ++++++---- plex_meta_manager.py | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index eb714bbd..4787a476 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,9 @@ # New Features Added new collection_order `custom.desc` ([FR](https://features.metamanager.wiki/features/p/reverse-sort-collectionorder-custom)) Added webp Image Support ([FR](https://features.metamanager.wiki/features/p/support-webp-image-extensions)) +Added Spanish Defaults Translation +Added Delete Webhooks # Bug Fixes -Fixed Italian Translation \ No newline at end of file +Fixed Italian Defaults Translation +Fixed TMDb Modified Filters \ No newline at end of file diff --git a/VERSION b/VERSION index 338b9d2a..0be49cb3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.1-develop8 +1.18.1-develop9 diff --git a/docs/config/webhooks.md b/docs/config/webhooks.md index 6682d32a..f24b05fe 100644 --- a/docs/config/webhooks.md +++ b/docs/config/webhooks.md @@ -37,6 +37,7 @@ The Error notification will be sent whenever an error occurs. The payload that i ```yaml { + "event": "error", // Event "error": str, // Error Message "critical": bool // Critical Error } @@ -46,6 +47,7 @@ The Error notification will be sent whenever an error occurs. The payload that i ```yaml { + "event": "error", // Event "error": str, // Error Message "critical": bool, // Critical Error "server_name": str, // Server Name @@ -57,6 +59,7 @@ The Error notification will be sent whenever an error occurs. The payload that i ```yaml { + "event": "error", // Event "error": str, // Error Message "critical": bool, // Critical Error "server_name": str, // Server Name @@ -69,6 +72,7 @@ The Error notification will be sent whenever an error occurs. The payload that i ```yaml { + "event": "error", // Event "error": str, // Error Message "critical": bool, // Critical Error "server_name": str, // Server Name @@ -85,6 +89,7 @@ The Version notification will be sent at the beginning of a run if there is a ne ```yaml { + "event": "version", // Event "current": str, // Current Version "latest": str, // Latest Version "notes": str // Sends the lateset release notes or new commits to develop since your version @@ -99,6 +104,7 @@ The Run Start notification will be sent at the beginning of every run. ```yaml { + "event": "run_start", // Event "start_time": str, // Time Run is started Format "YY-mm-dd HH:MM:SS" } ``` @@ -111,6 +117,7 @@ The Run End notification will be sent at the end of every run with statistics. ```yaml { + "event": "run_end", // Event "start_time": str, // Time Run started Format "YY-mm-dd HH:MM:SS" "end_time": str, // Time Run ended Format "YY-mm-dd HH:MM:SS" "run_time": str, // Time Run took to complete Format "HH:MM" @@ -136,6 +143,7 @@ The Delete Notification will be sent whenever a collection/playlist is deleted c ```yaml { + "event": "delete", // Event "message": str, // Status Message "server_name": str, // Server Name "library_name": str, // Library Name (Only if a Collection is deleted) @@ -150,6 +158,7 @@ The Changes Notification will be sent after each collection/playlist containing ```yaml { + "event": "changes", // Event "server_name": str, // Server Name "library_name": str, // Library Name "collection": str, // Collection Name only in payload for a collection diff --git a/modules/webhooks.py b/modules/webhooks.py index de88d519..97e536ab 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -70,7 +70,7 @@ class Webhooks: def start_time_hooks(self, start_time): if self.run_start_webhooks: - self._request(self.run_start_webhooks, {"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S")}) + self._request(self.run_start_webhooks, {"event": "run_start", "start_time": start_time.strftime("%Y-%m-%d %H:%M:%S")}) def version_hooks(self, version, latest_version): if self.version_webhooks: @@ -79,11 +79,12 @@ class Webhooks: notes = self.config.GitHub.latest_release_notes() elif version[2] and version[2] < latest_version[2]: notes = self.config.GitHub.get_commits(version[2], nightly=self.config.check_nightly) - self._request(self.version_webhooks, {"current": version[0], "latest": latest_version[0], "notes": notes}) + self._request(self.version_webhooks, {"event": "version", "current": version[0], "latest": latest_version[0], "notes": notes}) def end_time_hooks(self, start_time, end_time, run_time, stats): if self.run_end_webhooks: self._request(self.run_end_webhooks, { + "event": "run_end", "start_time": start_time.strftime("%Y-%m-%d %H:%M:%S"), "end_time": end_time.strftime("%Y-%m-%d %H:%M:%S"), "run_time": run_time, @@ -99,7 +100,7 @@ class Webhooks: def error_hooks(self, text, server=None, library=None, collection=None, playlist=None, critical=True): if self.error_webhooks: - json = {"error": str(text), "critical": critical} + json = {"event": "error", "error": str(text), "critical": critical} if server: json["server_name"] = str(server) if library: json["library_name"] = str(library) if collection: json["collection"] = str(collection) @@ -108,7 +109,7 @@ class Webhooks: def delete_hooks(self, message, server=None, library=None): if self.delete_webhooks: - json = {"message": message} + json = {"event": "delete", "message": message} if server: json["server_name"] = str(server) if library: json["library_name"] = str(library) self._request(self.delete_webhooks, json) @@ -123,6 +124,7 @@ class Webhooks: if not playlist and not background_url and collection.art and next((f for f in collection.fields if f.name == "art"), None): art = self.config.get_image_encoded(f"{self.library.url}{collection.art}?X-Plex-Token={self.library.token}") self._request(webhooks, { + "event": "changes", "server_name": self.library.PlexServer.friendlyName, "library_name": self.library.name, "playlist" if playlist else "collection": collection.title, diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 95821908..a31ac9ab 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -634,7 +634,7 @@ def run_collection(config, library, metadata, requested_collections): else: raise Failed(e) - if not builder.found_items and builder.ignore_blank_results: + if not builder.found_items and not builder.ignore_blank_results: raise NonExisting(f"{builder.Type} Warning: No items found") builder.display_filters()