From 85b5e0185c52ab5b7f5ac2fd6263396ad2ad1832 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 16 Mar 2022 17:03:28 -0400 Subject: [PATCH] [2] add new_version to webhooks --- VERSION | 2 +- docs/config/webhooks.md | 2 ++ modules/config.py | 3 ++- modules/webhooks.py | 10 +++++++--- plex_meta_manager.py | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 909baad7..e75302d3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.2-develop1 +1.16.2-develop2 diff --git a/docs/config/webhooks.md b/docs/config/webhooks.md index 9059603d..40a26420 100644 --- a/docs/config/webhooks.md +++ b/docs/config/webhooks.md @@ -81,6 +81,7 @@ The Run Start notification will be sent at the beginning of every run. ```yaml { "start_time": str, // Time Run is started Format "YY-mm-dd HH:MM:SS" + "new_version": str // New Version or null if version is current } ``` @@ -95,6 +96,7 @@ The Run End notification will be sent at the end of every run with statistics. "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" + "new_version": str, // New Version or null if version is current "collections_created": int, // Number of Collections/Playlists Created "collections_modified": int, // Number of Collections/Playlists Modified "collections_deleted": int, // Number of Collections/Playlists Removed diff --git a/modules/config.py b/modules/config.py index 021361b2..f1682815 100644 --- a/modules/config.py +++ b/modules/config.py @@ -63,6 +63,7 @@ class ConfigFile: self.default_dir = default_dir self.read_only = attrs["read_only"] if "read_only" in attrs else False + self.new_version = attrs["new_version"] if "new_version" in attrs else None self.test_mode = attrs["test"] if "test" in attrs else False self.trace_mode = attrs["trace"] if "trace" in attrs else False self.delete_collections = attrs["delete"] if "delete" in attrs else False @@ -355,7 +356,7 @@ class ConfigFile: self.Webhooks = Webhooks(self, self.webhooks, notifiarr=self.NotifiarrFactory) try: - self.Webhooks.start_time_hooks(self.start_time) + self.Webhooks.start_time_hooks(self.start_time, self.new_version) except Failed as e: logger.stacktrace() logger.error(f"Webhooks Error: {e}") diff --git a/modules/webhooks.py b/modules/webhooks.py index 4aacf518..12f16454 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -44,16 +44,20 @@ class Webhooks: if response.status_code >= 400: raise Failed(f"({response.status_code} [{response.reason}])") - def start_time_hooks(self, start_time): + def start_time_hooks(self, start_time, version): 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, { + "start_time": start_time.strftime("%Y-%m-%d %H:%M:%S"), + "new_version": version + }) - def end_time_hooks(self, start_time, end_time, run_time, stats): + def end_time_hooks(self, start_time, end_time, run_time, stats, version): if self.run_end_webhooks: self._request(self.run_end_webhooks, { "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, + "new_version": version, "collections_created": stats["created"], "collections_modified": stats["modified"], "collections_deleted": stats["deleted"], diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 89ca5544..96d7a4c1 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -149,6 +149,7 @@ def start(attrs): attrs["time"] = start_time.strftime("%H:%M") attrs["time_obj"] = start_time attrs["read_only"] = read_only_config + attrs["new_version"] = new_version logger.separator(debug=True) logger.debug(f"--config (PMM_CONFIG): {config_file}") logger.debug(f"--time (PMM_TIME): {times}") @@ -192,7 +193,7 @@ def start(attrs): run_time = str(end_time - start_time).split('.')[0] if config: try: - config.Webhooks.end_time_hooks(start_time, end_time, run_time, stats) + config.Webhooks.end_time_hooks(start_time, end_time, run_time, stats, new_version) except Failed as e: logger.stacktrace() logger.error(f"Webhooks Error: {e}")