mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Merge remote-tracking branch 'brycied00d/Pushover' into develop
This commit is contained in:
@@ -715,6 +715,26 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h3>Pushover</h3>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="pushover_enabled" id="pushover" value="1" ${config['pushover_enabled']} /><label>Enable Pushover Notifications</label>
|
||||
</div>
|
||||
<div id="pushoveroptions">
|
||||
<div class="row">
|
||||
<label>User key</label><input type="text" name="pushover_keys" value="${config['pushover_keys']}" size="50">
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="pushover_onsnatch" value="1" ${config['pushover_onsnatch']} /><label>Notify on snatch?</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Priority (-1,0, or 1):</label>
|
||||
<input type="text" name="pushover_priority" value="${config['pushover_priority']}" size="2">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<fieldset>
|
||||
<legend>Musicbrainz</legend>
|
||||
<div class="row">
|
||||
@@ -928,6 +948,26 @@
|
||||
$("#nmaoptions").slideUp();
|
||||
}
|
||||
});
|
||||
if ($("#pushover").is(":checked"))
|
||||
{
|
||||
$("#pushoveroptions").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#pushoveroptions").hide();
|
||||
}
|
||||
|
||||
$("#pushover").click(function(){
|
||||
if ($("#pushover").is(":checked"))
|
||||
{
|
||||
$("#pushoveroptions").slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#pushoveroptions").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#preferred_bitrate").is(":checked"))
|
||||
{
|
||||
$("#preferred_bitrate_options").show();
|
||||
|
||||
@@ -194,6 +194,10 @@ NMA_APIKEY = None
|
||||
NMA_PRIORITY = None
|
||||
NMA_ONSNATCH = None
|
||||
SYNOINDEX_ENABLED = False
|
||||
PUSHOVER_ENABLED = True
|
||||
PUSHOVER_PRIORITY = 1
|
||||
PUSHOVER_KEYS = None
|
||||
PUSHOVER_ONSNATCH = True
|
||||
MIRRORLIST = ["musicbrainz.org","headphones","custom"]
|
||||
MIRROR = None
|
||||
CUSTOMHOST = None
|
||||
@@ -265,7 +269,8 @@ def initialize():
|
||||
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\
|
||||
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
||||
ENCODERFOLDER, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, \
|
||||
ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, \
|
||||
ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, \
|
||||
PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_KEYS, PUSHOVER_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, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
|
||||
PREFERRED_BITRATE_LOW_BUFFER,CACHE_SIZEMB
|
||||
@@ -284,6 +289,7 @@ def initialize():
|
||||
CheckSection('Rutracker')
|
||||
CheckSection('What.cd')
|
||||
CheckSection('Prowl')
|
||||
CheckSection('Pushover')
|
||||
CheckSection('XBMC')
|
||||
CheckSection('NMA')
|
||||
CheckSection('Synoindex')
|
||||
@@ -431,6 +437,11 @@ def initialize():
|
||||
|
||||
SYNOINDEX_ENABLED = bool(check_setting_int(CFG, 'Synoindex', 'synoindex_enabled', 0))
|
||||
|
||||
PUSHOVER_ENABLED = bool(check_setting_int(CFG, 'Pushover', 'pushover_enabled', 0))
|
||||
PUSHOVER_KEYS = check_setting_str(CFG, 'Pushover', 'pushover_keys', '')
|
||||
PUSHOVER_ONSNATCH = bool(check_setting_int(CFG, 'Pushover', 'pushover_onsnatch', 0))
|
||||
PUSHOVER_PRIORITY = check_setting_int(CFG, 'Pushover', 'pushover_priority', 0)
|
||||
|
||||
MIRROR = check_setting_str(CFG, 'General', 'mirror', 'musicbrainz.org')
|
||||
CUSTOMHOST = check_setting_str(CFG, 'General', 'customhost', 'localhost')
|
||||
CUSTOMPORT = check_setting_int(CFG, 'General', 'customport', 5000)
|
||||
@@ -720,6 +731,12 @@ def config_write():
|
||||
new_config['NMA']['nma_priority'] = NMA_PRIORITY
|
||||
new_config['NMA']['nma_onsnatch'] = int(PROWL_ONSNATCH)
|
||||
|
||||
new_config['Pushover'] = {}
|
||||
new_config['Pushover']['pushover_enabled'] = int(PUSHOVER_ENABLED)
|
||||
new_config['Pushover']['pushover_keys'] = PUSHOVER_KEYS
|
||||
new_config['Pushover']['pushover_onsnatch'] = int(PUSHOVER_ONSNATCH)
|
||||
new_config['Pushover']['pushover_priority'] = int(PUSHOVER_PRIORITY)
|
||||
|
||||
new_config['Synoindex'] = {}
|
||||
new_config['Synoindex']['synoindex_enabled'] = int(SYNOINDEX_ENABLED)
|
||||
|
||||
|
||||
@@ -263,3 +263,62 @@ class Synoindex:
|
||||
if isinstance(path_list, list):
|
||||
for path in path_list:
|
||||
self.notify(path)
|
||||
class PUSHOVER:
|
||||
|
||||
application_token = "LdPCoy0dqC21ktsbEyAVCcwvQiVlsz"
|
||||
keys = []
|
||||
priority = []
|
||||
|
||||
def __init__(self):
|
||||
self.enabled = headphones.PUSHOVER_ENABLED
|
||||
self.keys = headphones.PUSHOVER_KEYS
|
||||
self.priority = headphones.PUSHOVER_PRIORITY
|
||||
pass
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('Pushover', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.PUSHOVER_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.pushover.net")
|
||||
|
||||
data = {'token': self.application_token,
|
||||
'user': headphones.PUSHOVER_KEYS,
|
||||
'title': event,
|
||||
'message': message.encode("utf-8"),
|
||||
'priority': headphones.PUSHOVER_PRIORITY }
|
||||
|
||||
http_handler.request("POST",
|
||||
"/1/messages.json",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
||||
body = urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
logger.debug(u"Pushover response status: %r" % request_status)
|
||||
logger.debug(u"Pushover response headers: %r" % response.getheaders())
|
||||
logger.debug(u"Pushover response body: %r" % response.read())
|
||||
|
||||
if request_status == 200:
|
||||
logger.info(u"Pushover notifications sent.")
|
||||
return True
|
||||
elif request_status >= 400 and request_status < 500:
|
||||
logger.info(u"Pushover request failed: %s" % response.reason)
|
||||
return False
|
||||
else:
|
||||
logger.info(u"Pushover notification failed.")
|
||||
return False
|
||||
|
||||
def updateLibrary(self):
|
||||
#For uniformity reasons not removed
|
||||
return
|
||||
|
||||
def test(self, keys, priority):
|
||||
|
||||
self.enabled = True
|
||||
self.keys = keys
|
||||
self.priority = priority
|
||||
|
||||
self.notify('Main Screen Activate', 'Test Message')
|
||||
|
||||
|
||||
@@ -395,6 +395,12 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
for albumpath in albumpaths:
|
||||
syno.notify(albumpath)
|
||||
|
||||
if headphones.PUSHOVER_ENABLED:
|
||||
pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle']
|
||||
logger.info(u"Pushover request")
|
||||
pushover = notifiers.PUSHOVER()
|
||||
pushover.notify(pushmessage,"Download and Postprocessing completed")
|
||||
|
||||
def embedAlbumArt(artwork, downloaded_track_list):
|
||||
logger.info('Embedding album art')
|
||||
|
||||
|
||||
@@ -128,6 +128,10 @@ def sendNZB(nzb):
|
||||
logger.info(u"Sending Prowl notification")
|
||||
prowl = notifiers.PROWL()
|
||||
prowl.notify(nzb.name,"Download started")
|
||||
if headphones.PUSHOVER_ENABLED and headphones.PUSHOVER_ONSNATCH:
|
||||
logger.info(u"Sending Pushover notification")
|
||||
prowl = notifiers.PUSHOVER()
|
||||
prowl.notify(nzb.name,"Download started")
|
||||
if headphones.NMA_ENABLED and headphones.NMA_ONSNATCH:
|
||||
logger.debug(u"Sending NMA notification")
|
||||
nma = notifiers.NMA()
|
||||
|
||||
@@ -649,6 +649,10 @@ class WebInterface(object):
|
||||
"nma_priority": int(headphones.NMA_PRIORITY),
|
||||
"nma_onsnatch": checked(headphones.NMA_ONSNATCH),
|
||||
"synoindex_enabled": checked(headphones.SYNOINDEX_ENABLED),
|
||||
"pushover_enabled": checked(headphones.PUSHOVER_ENABLED),
|
||||
"pushover_onsnatch": checked(headphones.PUSHOVER_ONSNATCH),
|
||||
"pushover_keys": headphones.PUSHOVER_KEYS,
|
||||
"pushover_priority": headphones.PUSHOVER_PRIORITY,
|
||||
"mirror_list": headphones.MIRRORLIST,
|
||||
"mirror": headphones.MIRROR,
|
||||
"customhost": headphones.CUSTOMHOST,
|
||||
@@ -688,7 +692,8 @@ class WebInterface(object):
|
||||
remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=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, nma_onsnatch=0, synoindex_enabled=False, mirror=None, customhost=None, customport=None,
|
||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, synoindex_enabled=False,
|
||||
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, mirror=None, customhost=None, customport=None,
|
||||
customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, cache_sizemb=None, **kwargs):
|
||||
|
||||
headphones.HTTP_HOST = http_host
|
||||
@@ -787,6 +792,10 @@ class WebInterface(object):
|
||||
headphones.NMA_PRIORITY = nma_priority
|
||||
headphones.NMA_ONSNATCH = nma_onsnatch
|
||||
headphones.SYNOINDEX_ENABLED = synoindex_enabled
|
||||
headphones.PUSHOVER_ENABLED = pushover_enabled
|
||||
headphones.PUSHOVER_ONSNATCH = pushover_onsnatch
|
||||
headphones.PUSHOVER_KEYS = pushover_keys
|
||||
headphones.PUSHOVER_PRIORITY = pushover_priority
|
||||
headphones.MIRROR = mirror
|
||||
headphones.CUSTOMHOST = customhost
|
||||
headphones.CUSTOMPORT = customport
|
||||
|
||||
Reference in New Issue
Block a user