From 03e77ab2acdd057788bf04f352fc431967a00e16 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Wed, 1 Dec 2021 00:38:20 -0500 Subject: [PATCH] update webhook start and end payloads --- .github/workflows/latest.yml | 2 -- modules/config.py | 4 ++-- modules/webhooks.py | 7 ++++--- plex_meta_manager.py | 6 ++++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index c458a431..1ca8f595 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -3,8 +3,6 @@ name: Docker Latest Release on: push: branches: [ master ] - pull_request: - branches: [ master ] jobs: diff --git a/modules/config.py b/modules/config.py index 987c2533..b855f9e5 100644 --- a/modules/config.py +++ b/modules/config.py @@ -44,7 +44,7 @@ class Config: self.default_dir = default_dir self.test_mode = attrs["test"] if "test" in attrs else False self.trace_mode = attrs["trace"] if "trace" in attrs else False - self.run_start_time = attrs["time"] + self.start_time = attrs["time_obj"] self.run_hour = datetime.strptime(attrs["time"], "%H:%M").hour self.requested_collections = util.get_list(attrs["collections"]) if "collections" in attrs else None self.requested_libraries = util.get_list(attrs["libraries"]) if "libraries" in attrs else None @@ -231,7 +231,7 @@ class Config: self.Webhooks = Webhooks(self, self.webhooks, notifiarr=self.NotifiarrFactory) try: - self.Webhooks.start_time_hooks(self.run_start_time) + self.Webhooks.start_time_hooks(self.start_time) except Failed as e: util.print_stacktrace() logger.error(f"Webhooks Error: {e}") diff --git a/modules/webhooks.py b/modules/webhooks.py index d7889bb2..3a67e7c0 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -43,12 +43,13 @@ class Webhooks: def start_time_hooks(self, start_time): if self.run_start_webhooks: - self._request(self.run_start_webhooks, {"start_time": start_time}) + self._request(self.run_start_webhooks, {"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S")}) - def end_time_hooks(self, start_time, run_time, stats): + def end_time_hooks(self, start_time, end_time, run_time, stats): if self.run_end_webhooks: self._request(self.run_end_webhooks, { - "start_time": start_time.strftime("%Y-%m-%dT%H:%M:%SZ"), + "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, "collections_created": stats["created"], "collections_modified": stats["modified"], diff --git a/plex_meta_manager.py b/plex_meta_manager.py index f6e73550..fdc687fb 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -135,6 +135,7 @@ def start(attrs): start_time = datetime.now() if "time" not in attrs: attrs["time"] = start_time.strftime("%H:%M") + attrs["time_obj"] = start_time util.separator(f"Starting {start_type}Run") config = None global stats @@ -152,10 +153,11 @@ def start(attrs): util.print_stacktrace() util.print_multiline(e, critical=True) logger.info("") - run_time = str(datetime.now() - start_time).split('.')[0] + end_time = datetime.now() + run_time = str(end_time - start_time).split('.')[0] if config: try: - config.Webhooks.end_time_hooks(start_time, run_time, stats) + config.Webhooks.end_time_hooks(start_time, end_time, run_time, stats) except Failed as e: util.print_stacktrace() logger.error(f"Webhooks Error: {e}")