Permalink
Browse files

Add Synology DSM Notifier

  • Loading branch information...
1 parent c0d9950 commit a4b501444fa3777742c09305567749f07df3a886 @guillaume86 committed Apr 23, 2012
@@ -258,6 +258,50 @@
<div class="component-group clearfix">
<div class="component-group-desc">
+ <h3><a href="http://synology.com/" onclick="window.open(this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/synoindex.gif" alt="" title="Synology Indexer" width="16" height="16" /> Synology DSM </a></h3>
+ <p>Synology DSM is the web interface on the synology NAS.</p>
+ </div>
+
+ <fieldset class="component-group-list">
+ <div class="field-pair">
+ <input type="checkbox" class="enabler" name="use_synoindex" id="use_synodsm" #if $sickbeard.USE_SYNODSM then "checked=\"checked\"" else ""# />
+ <label class="clearfix" for="use_synodsm">
+ <span class="component-title">Enable</span>
+ <span class="component-desc">Should Sick Beard send notifications to the Synology NAS DSM?<br /><br />
+ </span>
+ </label>
+ <label class="nocheck clearfix" for="use_synodsm">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">Note: Requires SB to be running on your Synology NAS.</span>
+ </label>
+ </div>
+
+ <div id="content_use_synodsm">
+ <div class="field-pair">
+ <input type="checkbox" name="xbmc_notify_onsnatch" id="synodsm_notify_onsnatch" #if $sickbeard.SYNODSM_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
+ <label class="clearfix" for="xbmc_notify_onsnatch">
+ <span class="component-title">Notify on Snatch</span>
+ <span class="component-desc">Send notification when we start a download?</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <input type="checkbox" name="xbmc_notify_ondownload" id="synodsm_notify_ondownload" #if $sickbeard.SYNODSM_NOTIFY_ONDOWNLOAD then "checked=\"checked\"" else ""# />
+ <label class="clearfix" for="xbmc_notify_ondownload">
+ <span class="component-title">Notify on Download</span>
+ <span class="component-desc">Send notification when we finish a download?</span>
+ </label>
+ </div>-
+ <div class="testNotification" id="testSYNODSM-result">Click below to test.</div>
+ <input type="button" value="Test" id="testSYNODSM" />
+ <input type="submit" class="config_submitter" value="Save Changes" />
+ </div><!-- /content_use_synodsm //-->
+
+ </fieldset>
+ </div><!-- /synodsm component-group //-->
+
+
+ <div class="component-group clearfix">
+ <div class="component-group-desc">
<h3><a href="http://synology.com/" onclick="window.open(this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/synoindex.gif" alt="" title="Synology Indexer" width="16" height="16" /> Synology Indexer </a></h3>
<p>Synology Indexer is the daemon running on the Synology NAS to build its media database.</p>
</div>
@@ -32,6 +32,7 @@
import trakt
import pytivo
import nma
+import synodsm
from sickbeard.common import *
@@ -49,6 +50,7 @@
trakt_notifier = trakt.TraktNotifier()
pytivo_notifier = pytivo.pyTivoNotifier()
nma_notifier = nma.NMA_Notifier()
+synodsm_notifier = synodsm.synoDsmNotifier()
notifiers = [
# Libnotify notifier goes first because it doesn't involve blocking on
@@ -66,6 +68,7 @@
trakt_notifier,
pytivo_notifier,
nma_notifier,
+ synodsm_notifier,
]
def notify_download(ep_name):
@@ -0,0 +1,39 @@
+# Author: Guillaume Lecomte <guillaume86@gmail.com>
+
+import os
+import subprocess
+
+import sickbeard
+
+from sickbeard import logger
+from sickbeard.exceptions import ex
+
+class synoDsmNotifier:
+
+ def notify_snatch(self, ep_name):
+ if sickbeard.SYNODSM_NOTIFY_ONSNATCH:
+ self._notify(common.notifyStrings[common.NOTIFY_SNATCH], ep_name)
+
+ def notify_download(self, ep_name):
+ if sickbeard.SYNODSM_NOTIFY_ONDOWNLOAD:
+ self._notify(common.notifyStrings[common.NOTIFY_DOWNLOAD], ep_name)
+
+ def test_notify(self):
+ return self._notify('Test notification', "This is a test notification from Sick Beard", force=True)
+
+ def _notify(self, title, message, force=False):
+ if not sickbeard.USE_SYNODSM and not force:
+ return False
+
+ synonotify_cmd = ['/usr/syno/bin/synodsmnotify', '@users', title, message]
+ logger.log(u"Executing command "+str(synonotify_cmd))
+ logger.log(u"Absolute path to command: "+ek.ek(os.path.abspath, synonotify_cmd[0]), logger.DEBUG)
+ try:
+ p = subprocess.Popen(synonotify_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=sickbeard.PROG_DIR)
+ out, err = p.communicate() #@UnusedVariable
+ logger.log(u"Script result: "+str(out), logger.DEBUG)
+ except OSError, e:
+ logger.log(u"Unable to run synodsmnotify: "+ex(e))
+
+
+notifier = synoDsmNotifier
View
@@ -1217,7 +1217,8 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
use_trakt=None, trakt_username=None, trakt_password=None, trakt_api=None,
use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None, pytivo_update_library=None,
pytivo_host=None, pytivo_share_name=None, pytivo_tivo_name=None,
- use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_api=None, nma_priority=0 ):
+ use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_api=None, nma_priority=0,
+ use_synodsm=None, synodsm_notify_onsnatch=None, synodsm_notify_ondownload=None, ):
results = []
@@ -1400,6 +1401,22 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
nma_notify_ondownload = 1
else:
nma_notify_ondownload = 0
+
+
+ if use_synodsm == "on":
+ use_synodsm = 1
+ else:
+ use_synodsm = 0
+
+ if synodsm_notify_onsnatch == "on":
+ synodsm_notify_onsnatch = 1
+ else:
+ synodsm_notify_onsnatch = 0
+
+ if synodsm_notify_ondownload == "on":
+ synodsm_notify_ondownload = 1
+ else:
+ synodsm_notify_ondownload = 0
sickbeard.USE_XBMC = use_xbmc
sickbeard.XBMC_NOTIFY_ONSNATCH = xbmc_notify_onsnatch
@@ -1480,6 +1497,10 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
sickbeard.NMA_NOTIFY_ONDOWNLOAD = nma_notify_ondownload
sickbeard.NMA_API = nma_api
sickbeard.NMA_PRIORITY = nma_priority
+
+ sickbeard.USE_SYNODSM = use_synodsm
+ sickbeard.SYNODSM_NOTIFY_ONSNATCH = synodsm_notify_onsnatch
+ sickbeard.SYNODSM_NOTIFY_ONDOWNLOAD = synodsm_notify_ondownload
sickbeard.save_config()

0 comments on commit a4b5014

Please sign in to comment.