pull/1392/head
Nelson Gibson 2 years ago
commit ed87909966

@ -1 +1 @@
1.19.0-develop23 1.19.0-develop24

@ -309,6 +309,7 @@ html_theme_options = {
("Audio/Subtitle Language Flags", "defaults/overlays/languages"), ("Audio/Subtitle Language Flags", "defaults/overlays/languages"),
("Languages", "defaults/overlays/languages"), ("Languages", "defaults/overlays/languages"),
("MediaStinger", "defaults/overlays/mediastinger"), ("MediaStinger", "defaults/overlays/mediastinger"),
("Networks", "defaults/overlays/network"),
("Ratings", "defaults/overlays/ratings"), ("Ratings", "defaults/overlays/ratings"),
("Resolution/Edition", "defaults/overlays/resolution"), ("Resolution/Edition", "defaults/overlays/resolution"),
("Ribbon", "defaults/overlays/ribbon"), ("Ribbon", "defaults/overlays/ribbon"),

@ -36,37 +36,38 @@ class Webhooks:
elif webhook.startswith("https://hooks.slack.com/services"): elif webhook.startswith("https://hooks.slack.com/services"):
json = self.slack(json) json = self.slack(json)
response = self.config.post(webhook, json=json) response = self.config.post(webhook, json=json)
try: if response is not None:
response_json = response.json() try:
logger.trace(f"Response: {response_json}") response_json = response.json()
if webhook == "notifiarr" and self.notifiarr and response.status_code == 400: logger.trace(f"Response: {response_json}")
def remove_from_config(text, hook_cat): if webhook == "notifiarr" and self.notifiarr and response.status_code == 400:
if response_json["details"]["response"] == text: def remove_from_config(text, hook_cat):
yaml = YAML(self.config.config_path) if response_json["details"]["response"] == text:
changed = False yaml = YAML(self.config.config_path)
if hook_cat in yaml.data and yaml.data["webhooks"][hook_cat]: changed = False
if isinstance(yaml.data["webhooks"][hook_cat], list) and "notifiarr" in yaml.data["webhooks"][hook_cat]: if hook_cat in yaml.data and yaml.data["webhooks"][hook_cat]:
changed = True if isinstance(yaml.data["webhooks"][hook_cat], list) and "notifiarr" in yaml.data["webhooks"][hook_cat]:
yaml.data["webhooks"][hook_cat].pop("notifiarr") changed = True
elif yaml.data["webhooks"][hook_cat] == "notifiarr": yaml.data["webhooks"][hook_cat].pop("notifiarr")
changed = True elif yaml.data["webhooks"][hook_cat] == "notifiarr":
yaml.data["webhooks"][hook_cat] = None changed = True
if changed: yaml.data["webhooks"][hook_cat] = None
yaml.save() if changed:
remove_from_config("PMM updated trigger is not enabled", "changes") yaml.save()
remove_from_config("PMM created trigger is not enabled", "changes") remove_from_config("PMM updated trigger is not enabled", "changes")
remove_from_config("PMM deleted trigger is not enabled", "changes") remove_from_config("PMM created trigger is not enabled", "changes")
remove_from_config("PMM failure trigger is not enabled", "error") remove_from_config("PMM deleted trigger is not enabled", "changes")
remove_from_config("PMM start/complete trigger is not enabled", "run_start") remove_from_config("PMM failure trigger is not enabled", "error")
remove_from_config("PMM start/complete trigger is not enabled", "run_end") remove_from_config("PMM start/complete trigger is not enabled", "run_start")
remove_from_config("PMM app updates trigger is not enabled", "version") remove_from_config("PMM start/complete trigger is not enabled", "run_end")
if "result" in response_json and response_json["result"] == "error" and "details" in response_json and "response" in response_json["details"]: remove_from_config("PMM app updates trigger is not enabled", "version")
raise Failed(f"Notifiarr Error: {response_json['details']['response']}") if "result" in response_json and response_json["result"] == "error" and "details" in response_json and "response" in response_json["details"]:
if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"): raise Failed(f"Notifiarr Error: {response_json['details']['response']}")
raise Failed(f"({response.status_code} [{response.reason}]) {response_json}") if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"):
except JSONDecodeError: raise Failed(f"({response.status_code} [{response.reason}]) {response_json}")
if response.status_code >= 400: except JSONDecodeError:
raise Failed(f"({response.status_code} [{response.reason}])") 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):
if self.run_start_webhooks: if self.run_start_webhooks:

Loading…
Cancel
Save