diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index ebc8a89d..8eff1946 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -456,6 +456,34 @@
XBMC Password:
Update XBMC Library
Send Notification to XBMC
+
+ Enable NotifyMyAndroid
+
+
NotifyMyAndroid API Key:
+ Separate multiple api keys with commas
+ Priority:
+ %for x in [-2,-1,0,1,2]:
+ <%
+ if config['nma_priority'] == x:
+ nma_priority_selected = 'selected'
+ else:
+ nma_priority_selected = ''
+
+ if x == -2:
+ nma_priority_value = 'Very Low'
+ elif x == -1:
+ nma_priority_value = 'Moderate'
+ elif x == 0:
+ nma_priority_value = 'Normal'
+ elif x == 1:
+ nma_priority_value = 'High'
+ else:
+ nma_priority_value = 'Emergency'
+ %>
+
+ %endfor
+
+
@@ -610,6 +638,26 @@
}
});
+ if ($("#nma").is(":checked"))
+ {
+ $("#nmaoptions").show();
+ }
+ else
+ {
+ $("#nmaoptions").hide();
+ }
+
+ $("#nma").click(function(){
+ if ($("#nma").is(":checked"))
+ {
+ $("#nmaoptions").show("fast");
+ }
+ else
+ {
+ $("#nmaoptions").hide("fast");
+ }
+ });
+
$("#mirror").change(handleNewSelection);
handleNewSelection.apply($("#mirror"));
diff --git a/headphones/__init__.py b/headphones/__init__.py
index eb14463f..611f568f 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -146,6 +146,9 @@ XBMC_USERNAME = None
XBMC_PASSWORD = None
XBMC_UPDATE = False
XBMC_NOTIFY = False
+NMA_ENABLED = False
+NMA_APIKEY = None
+NMA_PRIORITY = None
MIRRORLIST = ["musicbrainz.org","headphones","tbueter.com","custom"]
MIRROR = None
CUSTOMHOST = None
@@ -215,7 +218,7 @@ def initialize():
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, \
ENCODERLOSSLESS, 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
+ CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY
if __INITIALIZED__:
return False
@@ -229,6 +232,7 @@ def initialize():
CheckSection('Newzbin')
CheckSection('Prowl')
CheckSection('XBMC')
+ CheckSection('NMA')
# Set global variables based on config file or use defaults
CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '0')
@@ -333,6 +337,9 @@ def initialize():
XBMC_UPDATE = bool(check_setting_int(CFG, 'XBMC', 'xbmc_update', 0))
XBMC_NOTIFY = bool(check_setting_int(CFG, 'XBMC', 'xbmc_notify', 0))
+ 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)
MIRROR = check_setting_str(CFG, 'General', 'mirror', 'musicbrainz.org')
CUSTOMHOST = check_setting_str(CFG, 'General', 'customhost', 'localhost')
@@ -542,6 +549,11 @@ def config_write():
new_config['XBMC']['xbmc_update'] = int(XBMC_UPDATE)
new_config['XBMC']['xbmc_notify'] = int(XBMC_NOTIFY)
+ new_config['NMA'] = {}
+ new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
+ new_config['NMA']['nma_apikey'] = NMA_APIKEY
+ new_config['NMA']['nma_priority'] = NMA_PRIORITY
+
new_config['General']['lastfm_username'] = LASTFM_USERNAME
new_config['General']['interface'] = INTERFACE
new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS
diff --git a/headphones/notifiers.py b/headphones/notifiers.py
index 9101d741..2a01874b 100644
--- a/headphones/notifiers.py
+++ b/headphones/notifiers.py
@@ -128,4 +128,46 @@ class XBMC:
request = self._send(notifycommand)
if not request:
- logger.warn('Error sending notification request to XBMC')
\ No newline at end of file
+ logger.warn('Error sending notification request to XBMC')
+
+class NMA:
+
+ def __init__(self):
+
+ self.apikey = headphones.NMA_APIKEY
+ self.priority = headphones.NMA_PRIORITY
+
+ def _send(self, data):
+
+ url_data = urllib.urlencode(data)
+ url = 'https://www.notifymyandroid.com/publicapi/notify'
+
+ req = urllib2.Request(url, url_data)
+
+ try:
+ handle = urllib2.urlopen(req)
+ except Exception, e:
+ logger.warn('Error opening NotifyMyAndroid url: ' % e)
+ return
+
+ response = handle.read().decode(headphones.SYS_ENCODING)
+
+ return response
+
+ def notify(self, artist, album):
+
+ apikey = self.apikey
+ priority = self.priority
+
+ event = artist + ' - ' + album + ' complete!'
+
+ description = "Headphones has downloaded and postprocessed: " + artist + ' [' + album + ']'
+
+ data = { 'apikey': apikey, 'application':'Headphones', 'event': event, 'description': description, 'priority': priority}
+
+ logger.info('Sending notification request to NotifyMyAndroid')
+ request = self._send(data)
+
+ if not request:
+ logger.warn('Error sending notification request to NotifyMyAndroid')
+
\ No newline at end of file
diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py
index 3246bee9..9d6f8e60 100644
--- a/headphones/postprocessor.py
+++ b/headphones/postprocessor.py
@@ -269,6 +269,10 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
xbmc.update()
if headphones.XBMC_NOTIFY:
xbmc.notify(release['ArtistName'], release['AlbumTitle'], album_art_path)
+
+ if headphones.NMA_ENABLED:
+ nma = notifiers.NMA()
+ nma.notify(release['ArtistName'], release['AlbumTitle'])
def embedAlbumArt(artwork, downloaded_track_list):
logger.info('Embedding album art')
diff --git a/headphones/webserve.py b/headphones/webserve.py
index 111bde3e..ba4925c4 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -405,6 +405,9 @@ class WebInterface(object):
"xbmc_password": headphones.XBMC_PASSWORD,
"xbmc_update": checked(headphones.XBMC_UPDATE),
"xbmc_notify": checked(headphones.XBMC_NOTIFY),
+ "nma_enabled": checked(headphones.NMA_ENABLED),
+ "nma_apikey": headphones.NMA_APIKEY,
+ "nma_priority": int(headphones.NMA_PRIORITY),
"mirror_list": headphones.MIRRORLIST,
"mirror": headphones.MIRROR,
"customhost": headphones.CUSTOMHOST,
@@ -425,7 +428,7 @@ class WebInterface(object):
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None,
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=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,
- mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None):
+ nma_enabled=False, nma_apikey=None, nma_priority=0, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None):
headphones.HTTP_HOST = http_host
headphones.HTTP_PORT = http_port
@@ -500,6 +503,9 @@ class WebInterface(object):
headphones.XBMC_PASSWORD = xbmc_password
headphones.XBMC_UPDATE = xbmc_update
headphones.XBMC_NOTIFY = xbmc_notify
+ headphones.NMA_ENABLED = nma_enabled
+ headphones.NMA_APIKEY = nma_apikey
+ headphones.NMA_PRIORITY = nma_priority
headphones.MIRROR = mirror
headphones.CUSTOMHOST = customhost
headphones.CUSTOMPORT = customport