mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-09-20 06:22:07 +00:00
catch webhook errors
This commit is contained in:
parent
d223da35cf
commit
7fac92652c
4 changed files with 30 additions and 14 deletions
|
@ -2123,13 +2123,19 @@ class CollectionBuilder:
|
|||
(self.details["collection_removal_webhooks"] and len(self.notification_removals) > 0)
|
||||
):
|
||||
self.obj.reload()
|
||||
self.library.Webhooks.collection_hooks(
|
||||
self.details["collection_creation_webhooks"] + self.details["collection_addition_webhooks"] + self.details["collection_removal_webhooks"],
|
||||
self.obj,
|
||||
created=self.created,
|
||||
additions=self.notification_additions,
|
||||
removals=self.notification_removals
|
||||
)
|
||||
try:
|
||||
self.library.Webhooks.collection_hooks(
|
||||
self.details["collection_creation_webhooks"] +
|
||||
self.details["collection_addition_webhooks"] +
|
||||
self.details["collection_removal_webhooks"],
|
||||
self.obj,
|
||||
created=self.created,
|
||||
additions=self.notification_additions,
|
||||
removals=self.notification_removals
|
||||
)
|
||||
except Failed as e:
|
||||
util.print_stacktrace()
|
||||
logger.error(f"Webhooks Error: {e}")
|
||||
|
||||
def run_collections_again(self):
|
||||
self.obj = self.library.get_collection(self.name)
|
||||
|
|
|
@ -125,7 +125,8 @@ class Config:
|
|||
else: endline = ""
|
||||
yaml.round_trip_dump(loaded_config, open(self.config_path, "w"), indent=None, block_seq_indent=2)
|
||||
elif data[attribute] is None:
|
||||
if default_is_none is True: return None
|
||||
if default_is_none and var_type == "list": return []
|
||||
elif default_is_none: return None
|
||||
else: message = f"{text} is blank"
|
||||
elif var_type == "url":
|
||||
if data[attribute].endswith(("\\", "/")): return data[attribute][:-1]
|
||||
|
@ -229,7 +230,11 @@ class Config:
|
|||
logger.warning("notifiarr attribute not found")
|
||||
|
||||
self.Webhooks = Webhooks(self, self.webhooks, notifiarr=self.NotifiarrFactory)
|
||||
self.Webhooks.start_time_hooks(self.run_start_time)
|
||||
try:
|
||||
self.Webhooks.start_time_hooks(self.run_start_time)
|
||||
except Failed as e:
|
||||
util.print_stacktrace()
|
||||
logger.error(f"Webhooks Error: {e}")
|
||||
|
||||
self.errors = []
|
||||
|
||||
|
@ -604,7 +609,11 @@ class Config:
|
|||
|
||||
def notify(self, text, library=None, collection=None, critical=True):
|
||||
for error in util.get_list(text, split=False):
|
||||
self.Webhooks.error_hooks(error, library=library, collection=collection, critical=critical)
|
||||
try:
|
||||
self.Webhooks.error_hooks(error, library=library, collection=collection, critical=critical)
|
||||
except Failed as e:
|
||||
util.print_stacktrace()
|
||||
logger.error(f"Webhooks Error: {e}")
|
||||
|
||||
def get_html(self, url, headers=None, params=None):
|
||||
return html.fromstring(self.get(url, headers=headers, params=params).content)
|
||||
|
|
|
@ -183,9 +183,6 @@ class Library(ABC):
|
|||
self.config.Cache.update_image_map(item.ratingKey, f"{self.image_table_name}_backgrounds", item.art, background.compare)
|
||||
|
||||
def notify(self, text, collection=None, critical=True):
|
||||
for error in util.get_list(text, split=False):
|
||||
self.Webhooks.error_hooks(error, library=self, collection=collection, critical=critical)
|
||||
|
||||
self.config.notify(text, library=self, collection=collection, critical=critical)
|
||||
|
||||
@abstractmethod
|
||||
|
|
|
@ -154,7 +154,11 @@ def start(attrs):
|
|||
logger.info("")
|
||||
run_time = str(datetime.now() - start_time).split('.')[0]
|
||||
if config:
|
||||
config.Webhooks.end_time_hooks(start_time, run_time, stats)
|
||||
try:
|
||||
config.Webhooks.end_time_hooks(start_time, run_time, stats)
|
||||
except Failed as e:
|
||||
util.print_stacktrace()
|
||||
logger.error(f"Webhooks Error: {e}")
|
||||
util.separator(f"Finished {start_type}Run\nRun Time: {run_time}")
|
||||
logger.removeHandler(file_handler)
|
||||
|
||||
|
|
Loading…
Reference in a new issue