diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index 75219f33..643af20e 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -618,7 +618,10 @@ m<%inherit file="base.html"/>
diff --git a/headphones/__init__.py b/headphones/__init__.py
index 3126e793..0e06ba4c 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -183,6 +183,7 @@ XBMC_NOTIFY = False
NMA_ENABLED = False
NMA_APIKEY = None
NMA_PRIORITY = None
+NMA_ONSNATCH = None
SYNOINDEX_ENABLED = False
MIRRORLIST = ["musicbrainz.org","headphones","custom"]
MIRROR = None
@@ -254,7 +255,7 @@ def initialize():
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, \
ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, \
MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
- XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
+ XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
PREFERRED_BITRATE_LOW_BUFFER
if __INITIALIZED__:
@@ -401,6 +402,7 @@ def initialize():
NMA_ENABLED = bool(check_setting_int(CFG, 'NMA', 'nma_enabled', 0))
NMA_APIKEY = check_setting_str(CFG, 'NMA', 'nma_apikey', '')
NMA_PRIORITY = check_setting_int(CFG, 'NMA', 'nma_priority', 0)
+ NMA_ONSNATCH = bool(check_setting_int(CFG, 'NMA', 'nma_onsnatch', 0))
SYNOINDEX_ENABLED = bool(check_setting_int(CFG, 'Synoindex', 'synoindex_enabled', 0))
@@ -676,6 +678,7 @@ def config_write():
new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
new_config['NMA']['nma_apikey'] = NMA_APIKEY
new_config['NMA']['nma_priority'] = NMA_PRIORITY
+ new_config['NMA']['nma_onsnatch'] = int(PROWL_ONSNATCH)
new_config['Synoindex'] = {}
new_config['Synoindex']['synoindex_enabled'] = int(SYNOINDEX_ENABLED)
diff --git a/headphones/notifiers.py b/headphones/notifiers.py
index 3c16b647..3df88485 100644
--- a/headphones/notifiers.py
+++ b/headphones/notifiers.py
@@ -171,14 +171,17 @@ class NMA:
return response
- def notify(self, artist, album):
+ def notify(self, artist=None, album=None, snatched_nzb=None):
apikey = self.apikey
priority = self.priority
- event = artist + ' - ' + album + ' complete!'
-
- description = "Headphones has downloaded and postprocessed: " + artist + ' [' + album + ']'
+ if snatched_nzb:
+ event = snatched_nzb + " snatched!"
+ description = "Headphones has snatched: " + snatched_nzb + " and has sent it to SABnzbd+"
+ else:
+ event = artist + ' - ' + album + ' complete!'
+ description = "Headphones has downloaded and postprocessed: " + artist + ' [' + album + ']'
data = { 'apikey': apikey, 'application':'Headphones', 'event': event, 'description': description, 'priority': priority}
@@ -223,4 +226,4 @@ class Synoindex:
def notify_multiple(self, path_list):
if isinstance(path_list, list):
for path in path_list:
- self.notify(path)
\ No newline at end of file
+ self.notify(path)
diff --git a/headphones/sab.py b/headphones/sab.py
index 6d57214c..282dd4c3 100644
--- a/headphones/sab.py
+++ b/headphones/sab.py
@@ -118,10 +118,14 @@ def sendNZB(nzb):
if sabText == "ok":
logger.info(u"NZB sent to SAB successfully")
- if headphones.PROWL_ONSNATCH:
- logger.info(u"Prowl request")
+ if headphones.PROWL_ENABLED and headphones.PROWL_ONSNATCH:
+ logger.info(u"Sending Prowl notification")
prowl = notifiers.PROWL()
prowl.notify(nzb.name,"Download started")
+ if headphones.NMA_ENABLED and headphones.NMA_ONSNATCH:
+ logger.debug(u"Sending NMA notification")
+ nma = notifiers.NMA()
+ nma.notify(snatched_nzb=nzb.name)
return True
elif sabText == "Missing authentication":
diff --git a/headphones/webserve.py b/headphones/webserve.py
index 14f29a80..799d84f3 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -511,6 +511,7 @@ class WebInterface(object):
"nma_enabled": checked(headphones.NMA_ENABLED),
"nma_apikey": headphones.NMA_APIKEY,
"nma_priority": int(headphones.NMA_PRIORITY),
+ "nma_onsnatch": checked(headphones.NMA_ONSNATCH),
"synoindex_enabled": checked(headphones.SYNOINDEX_ENABLED),
"mirror_list": headphones.MIRRORLIST,
"mirror": headphones.MIRROR,
@@ -550,7 +551,7 @@ class WebInterface(object):
interface=None, log_dir=None, music_encoder=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None,
encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, delete_lossless_files=0, prowl_enabled=0, prowl_onsnatch=0,
prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None, xbmc_update=0, xbmc_notify=0, nma_enabled=False,
- nma_apikey=None, nma_priority=0, synoindex_enabled=False, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None,
+ nma_apikey=None, nma_priority=0, nma_onsnatch=0, synoindex_enabled=False, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None,
preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, **kwargs):
headphones.HTTP_HOST = http_host
@@ -639,6 +640,7 @@ class WebInterface(object):
headphones.NMA_ENABLED = nma_enabled
headphones.NMA_APIKEY = nma_apikey
headphones.NMA_PRIORITY = nma_priority
+ headphones.NMA_ONSNATCH = nma_onsnatch
headphones.SYNOINDEX_ENABLED = synoindex_enabled
headphones.MIRROR = mirror
headphones.CUSTOMHOST = customhost