1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Send notifications to all enabled notifiers upon SickRage update.

This commit is contained in:
Mark Rawson 2014-07-03 07:43:48 +01:00
parent 36e12a5d4d
commit 6aa149752b
22 changed files with 149 additions and 6 deletions

View File

@ -50,11 +50,15 @@ SEASON_RESULT = -2
NOTIFY_SNATCH = 1
NOTIFY_DOWNLOAD = 2
NOTIFY_SUBTITLE_DOWNLOAD = 3
NOTIFY_SICKRAGE_UPDATE = 4
NOTIFY_SICKRAGE_UPDATE_TEXT = 5
notifyStrings = {}
notifyStrings[NOTIFY_SNATCH] = "Started Download"
notifyStrings[NOTIFY_DOWNLOAD] = "Download Finished"
notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD] = "Subtitle Download Finished"
notifyStrings[NOTIFY_SICKRAGE_UPDATE] = "SickRage Updated"
notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT] = "SickRage updated to version: "
### Episode statuses
UNKNOWN = -1 # should never happen

View File

@ -101,3 +101,7 @@ def notify_subtitle_download(ep_name, lang):
def notify_snatch(ep_name):
for n in notifiers:
n.notify_snatch(ep_name)
def notify_sickrage_update(new_version = ""):
for n in notifiers:
n.notify_sickrage_update(new_version)

View File

@ -23,7 +23,7 @@ import time
import sickbeard
from sickbeard import logger
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_SICKRAGE_UPDATE, NOTIFY_SICKRAGE_UPDATE_TEXT
from sickbeard.exceptions import ex
API_URL = "https://boxcar.io/devices/providers/fWc4sgSmpcN6JujtBmR6/notifications"
@ -122,6 +122,12 @@ class BoxcarNotifier:
def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]):
if sickbeard.BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notifyBoxcar(title, ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_BOXCAR:
update_text=notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT]
title=notifyStrings[NOTIFY_SICKRAGE_UPDATE]
self._notifyBoxcar(title, update_text + new_version)
def _notifyBoxcar(self, title, message, username=None, force=False):
"""

View File

@ -24,7 +24,7 @@ import time
import sickbeard
from sickbeard import logger
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_SICKRAGE_UPDATE, NOTIFY_SICKRAGE_UPDATE_TEXT
from sickbeard.exceptions import ex
API_URL = "https://new.boxcar.io/api/notifications"
@ -96,6 +96,12 @@ class Boxcar2Notifier:
def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]):
if sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notifyBoxcar2(title, ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_BOXCAR2:
update_text=notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT]
title=notifyStrings[NOTIFY_SICKRAGE_UPDATE]
self._notifyBoxcar2(title, update_text + new_version)
def _notifyBoxcar2(self, title, message, accesstoken=None):
"""

View File

@ -27,7 +27,7 @@ import re
import sickbeard
from sickbeard import logger
from sickbeard import logger, common
from sickbeard import db
from sickbeard.exceptions import ex
@ -141,6 +141,37 @@ class EmailNotifier:
logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
else:
logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
def notify_sickrage_update(self, new_version = "??"):
"""
Send a notification that an updated version of SickRage has been installed
"""
if sickbeard.USE_EMAIL:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
to = self._generate_recepients(show)
if len(to) == 0:
logger.log('Skipping email notify because there are no configured recepients', logger.WARNING)
else:
try:
msg = MIMEMultipart('alternative')
msg.attach(MIMEText(
"<body style='font-family:Helvetica, Arial, sans-serif;'><h3>SickRage Notification - " + title + "</h3>\n<p>" + update_text + new_version + "</p>\n\n<footer style='margin-top: 2.5em; padding: .7em 0; color: #777; border-top: #BBB solid 1px;'>Powered by SickRage.</footer></body>",
'html'))
except:
logger.log("SickRage update notification ERROR: %s" % self.last_err, logger.ERROR)
msg['Subject'] = lang + ' Subtitle Downloaded: ' + ep_name
msg['From'] = sickbeard.EMAIL_FROM
msg['To'] = ','.join(to)
if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS,
sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
else:
logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
def _generate_recepients(self, show):
addrs = []

View File

@ -43,6 +43,12 @@ class GrowlNotifier:
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD:
self._sendGrowl(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_GROWL:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._sendGrowl(title, update_text + new_version)
def _send_growl(self, options, message=None):

View File

@ -92,6 +92,11 @@ class LibnotifyNotifier:
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notify(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_LIBNOTIFY:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT], title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._notify(title, update_text + new_version)
def test_notify(self):
return self._notify('Test notification', "This is a test notification from SickRage", force=True)

View File

@ -23,6 +23,12 @@ class NMA_Notifier:
if sickbeard.NMA_NOTIFY_ONSUBTITLEDOWNLOAD:
self._sendNMA(nma_api=None, nma_priority=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD],
message=ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_NMA:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._sendNMA(nma_api=None, nma_priority=None, event=title, message=update_text + new_version)
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False):

View File

@ -96,6 +96,10 @@ class NMJNotifier:
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.USE_NMJ:
self._notifyNMJ()
def notify_sickrage_update(self, new_version):
return False
# Not implemented, no reason to start scanner.
def test_notify(self, host, database, mount):
return self._sendNMJ(host, database, mount)

View File

@ -42,6 +42,10 @@ class NMJv2Notifier:
def notify_subtitle_download(self, ep_name, lang):
self._notifyNMJ()
def notify_sickrage_update(self, new_version):
return False
# Not implemented, no reason to start scanner.
def test_notify(self, host):
return self._sendNMJ(host)

View File

@ -65,6 +65,12 @@ class PLEXNotifier(XBMCNotifier):
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notify_pmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_PLEX:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._notify_pmc(update_text + new_version, title)
def test_notify(self, host, username, password):
return self._notify_pmc("Testing Plex notifications from SickRage", "Test Notification", host, username,

View File

@ -51,6 +51,13 @@ class ProwlNotifier:
if sickbeard.PROWL_NOTIFY_ONSUBTITLEDOWNLOAD:
self._sendProwl(prowl_api=None, prowl_priority=None,
event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], message=ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_PROWL:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._sendProwl(prowl_api=None, prowl_priority=None,
event=title, message=update_text + new_version)
def _sendProwl(self, prowl_api=None, prowl_priority=None, event=None, message=None, force=False):

View File

@ -45,6 +45,14 @@ class PushalotNotifier:
self._sendPushalot(pushalot_authorizationtoken=None,
event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD],
message=ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_PUSHALOT:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._sendPushalot(pushalot_authorizationtoken=None,
event=title,
message=update_text + new_version)
def _sendPushalot(self, pushalot_authorizationtoken=None, event=None, message=None, force=False):

View File

@ -48,6 +48,12 @@ class PushbulletNotifier:
if sickbeard.PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD:
self._sendPushbullet(pushbullet_api=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + " : " + ep_name + " : " + lang,
message=ep_name + ": " + lang, notificationType="note", method="POST")
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_PUSHBULLET:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._sendPushbullet(pushbullet_api=None, event=title, message=update_text + new_version, method="POST")
def _sendPushbullet(self, pushbullet_api=None, pushbullet_device=None, event=None, message=None,
notificationType=None, method=None, force=False):

View File

@ -23,7 +23,7 @@ import time
import sickbeard
from sickbeard import logger
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_SICKRAGE_UPDATE, NOTIFY_SICKRAGE_UPDATE_TEXT
from sickbeard.exceptions import ex
API_URL = "https://api.pushover.net/1/messages.json"
@ -119,6 +119,12 @@ class PushoverNotifier:
def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]):
if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notifyPushover(title, ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_PUSHOVER:
update_text=notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT]
title=notifyStrings[NOTIFY_SICKRAGE_UPDATE]
self._notifyPushover(title, update_text + new_version)
def _notifyPushover(self, title, message, userKey=None, apiKey=None, force=False):
"""

View File

@ -36,6 +36,9 @@ class pyTivoNotifier:
def notify_subtitle_download(self, ep_name, lang):
pass
def notify_sickrage_update(self, new_version):
pass
def update_library(self, ep_obj):

View File

@ -37,6 +37,9 @@ class synoIndexNotifier:
def notify_subtitle_download(self, ep_name, lang):
pass
def notify_sickrage_update(self, new_version):
pass
def moveFolder(self, old_path, new_path):
self.moveObject(old_path, new_path)

View File

@ -40,6 +40,12 @@ class synologyNotifier:
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD:
self._send_synologyNotifier(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_SYNOLOGYNOTIFIER:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._send_synologyNotifier(update_text + new_version, title)
def _send_synologyNotifier(self, message, title):
synodsmnotify_cmd = ["/usr/syno/bin/synodsmnotify", "@administrators", title, message]

View File

@ -34,6 +34,9 @@ class TraktNotifier:
def notify_subtitle_download(self, ep_name, lang):
pass
def notify_sickrage_update(self, new_version):
pass
def update_library(self, ep_obj):
"""

View File

@ -51,6 +51,12 @@ class TwitterNotifier:
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notifyTwitter(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + ' ' + ep_name + ": " + lang)
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_TWITTER:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._notifyTwitter(title + " - " + update_text + new_version)
def test_notify(self):
return self._notifyTwitter("This is a test notification from SickRage", force=True)

View File

@ -512,6 +512,12 @@ class XBMCNotifier:
def notify_subtitle_download(self, ep_name, lang):
if sickbeard.XBMC_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notify_xbmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
def notify_sickrage_update(self, new_version = "??"):
if sickbeard.USE_XBMC:
update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT]
title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE]
self._notify_xbmc(update_text + new_version, title)
def test_notify(self, host, username, password):
return self._notify_xbmc("Testing XBMC notifications from SickRage", "Test Notification", host, username,

View File

@ -30,7 +30,7 @@ import gh_api as github
import threading
import sickbeard
from sickbeard import helpers
from sickbeard import helpers, notifiers
from sickbeard import version, ui
from sickbeard import logger
from sickbeard.exceptions import ex
@ -260,6 +260,9 @@ class WindowsUpdateManager(UpdateManager):
new_update_path = os.path.join(sickbeard.PROG_DIR, u'updater.exe')
logger.log(u"Copying new update.exe file from " + old_update_path + " to " + new_update_path)
shutil.move(old_update_path, new_update_path)
# Notify update successful
notifiers.notify_sickrage_update(sickbeard.NEWEST_VERSION_STRING)
except Exception, e:
logger.log(u"Error while trying to update: " + ex(e), logger.ERROR)
@ -412,7 +415,6 @@ class GitUpdateManager(UpdateManager):
commit hash. If there is a newer version it sets _num_commits_behind.
"""
self._newest_commit_hash = None
self._num_commits_behind = 0
self._num_commits_ahead = 0
@ -510,6 +512,8 @@ class GitUpdateManager(UpdateManager):
output, err, exit_status = self._run_git(self._git_path, 'pull origin ' + self.branch) # @UnusedVariable
if exit_status == 0:
# Notify update successful
notifiers.notify_sickrage_update(self._newest_commit_hash[:10])
return True
return False
@ -715,4 +719,7 @@ class SourceUpdateManager(UpdateManager):
logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG)
return False
# Notify update successful
notifiers.notify_sickrage_update(sickbeard.NEWEST_VERSION_STRING)
return True