From 97d833c3463ee9211903160a0270abdfd37c66a8 Mon Sep 17 00:00:00 2001 From: Stefan Cosma Date: Wed, 31 May 2023 14:10:25 +0300 Subject: [PATCH] Fixes Pushbullet check --- plexorcist.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plexorcist.py b/plexorcist.py index b3bd8bf..f3682ce 100755 --- a/plexorcist.py +++ b/plexorcist.py @@ -28,7 +28,11 @@ def __init__(self): self._set_config() self._set_logging() - self.pushbullet = Pushbullet(self.config["pushbullet_key"]) + # Check if the Pushbullet key has been set before making requests + match = re.match(r"^[A-Za-z0-9_.]+", self.config["pushbullet_key"]) + + if match: + self.pushbullet = Pushbullet(self.config["pushbullet_key"]) def _set_files(self): """Set all needed file paths and read config file""" @@ -337,10 +341,8 @@ def send_notification(self, deleted_titles, reclaimed_gb): else: logging.info(self.config["i18n"]["ifttt_error"]) - # Check if the Pushbullet key has been set before making requests - match = re.match(r"^[A-Za-z0-9_.]+", self.config["pushbullet_key"]) - - if match: + # Send notification via Pushbullet + if self.pushbullet: self.pushbullet.push_note("Plexorcist", payload)