From 0077a8e5182892183845f18ead1c95ef40c60404 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Sat, 3 May 2014 23:57:34 -0400 Subject: [PATCH] Fix the Plex notifier Previously, the fix would cause the Plex notifier not to work except in test mode or when the XBMC notifier was enabled. This fixes that. --- sickbeard/notifiers/plex.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sickbeard/notifiers/plex.py b/sickbeard/notifiers/plex.py index 4c9a2aee..2b4dd9eb 100644 --- a/sickbeard/notifiers/plex.py +++ b/sickbeard/notifiers/plex.py @@ -34,20 +34,36 @@ from xml.dom import minidom class PLEXNotifier(XBMCNotifier): + def _notify_pmc(self, message, title="Sick Beard", host=None, username=None, password=None, force=False): + # fill in omitted parameters + if not host: + host = sickbeard.PLEX_HOST + if not username: + username = sickbeard.PLEX_USERNAME + if not password: + password = sickbeard.PLEX_PASSWORD + + # suppress notifications if the notifier is disabled but the notify options are checked + if not sickbeard.USE_PLEX and not force: + logger.log("Notification for Plex not enabled, skipping this notification", logger.DEBUG) + return False + + return self._notify_xbmc(message=message, title=title, host=host, username=username, password=password, force=True) + def notify_snatch(self, ep_name): if sickbeard.PLEX_NOTIFY_ONSNATCH: - self._notify_xbmc(ep_name, common.notifyStrings[common.NOTIFY_SNATCH]) + self._notify_pmc(ep_name, common.notifyStrings[common.NOTIFY_SNATCH]) def notify_download(self, ep_name): if sickbeard.PLEX_NOTIFY_ONDOWNLOAD: - self._notify_xbmc(ep_name, common.notifyStrings[common.NOTIFY_DOWNLOAD]) + self._notify_pmc(ep_name, common.notifyStrings[common.NOTIFY_DOWNLOAD]) def notify_subtitle_download(self, ep_name, lang): if sickbeard.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD: - self._notify_xbmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD]) + self._notify_pmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD]) def test_notify(self, host, username, password): - return self._notify_xbmc("Testing Plex notifications from Sick Beard", "Test Notification", host, username, + return self._notify_pmc("Testing Plex notifications from Sick Beard", "Test Notification", host, username, password, force=True) def update_library(self):