From cfc30c1234f9e79a6183bf15a9155003f99b8981 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Mon, 11 Nov 2019 15:41:11 -0800 Subject: [PATCH] Add optional headers parameter for webhooks in notify API command --- API.md | 1 + plexpy/api2.py | 1 + plexpy/helpers.py | 1 + plexpy/notifiers.py | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index 2bef996e..20825dd7 100644 --- a/API.md +++ b/API.md @@ -2459,6 +2459,7 @@ Required parameters: body (str): The body of the message Optional parameters: + headers (str): The JSON headers for webhook notifications script_args (str): The arguments for script notifications Returns: diff --git a/plexpy/api2.py b/plexpy/api2.py index 092d2a52..8d23982d 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -421,6 +421,7 @@ class API2: body (str): The body of the message Optional parameters: + headers (str): The JSON headers for webhook notifications script_args (str): The arguments for script notifications Returns: diff --git a/plexpy/helpers.py b/plexpy/helpers.py index 54330e4f..f5ec2052 100644 --- a/plexpy/helpers.py +++ b/plexpy/helpers.py @@ -1179,6 +1179,7 @@ def split_args(args=None): for arg in shlex.split(args.encode(plexpy.SYS_ENCODING, 'ignore'))] return [] + def mask_config_passwords(config): if isinstance(config, list): for cfg in config: diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index f88b8eeb..e2dad604 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -3613,6 +3613,7 @@ class WEBHOOK(Notifier): } def agent_notify(self, subject='', body='', action='', **kwargs): + subject = kwargs.get('headers', subject) if subject: try: webhook_headers = json.loads(subject) @@ -3631,7 +3632,7 @@ class WEBHOOK(Notifier): else: webhook_body = None - headers = {'Content-type': 'application/json'} + headers = {'Content-Type': 'application/json'} if webhook_headers: headers.update(webhook_headers)