mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Pushalot Service Added
This commit is contained in:
@@ -839,7 +839,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h3>Pushalot</h3>
|
||||
<div class="checkbox row">
|
||||
<input type="checkbox" name="pushalot_enabled" id="pushalot" value="1" ${config['pushalot_enabled']} /><label>Enable Pushalot</label>
|
||||
</div>
|
||||
<div id="pushalotoptions">
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="pushalot_onsnatch" value="1" ${config['pushalot_onsnatch']} /><label>Notify on snatch?</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Pushalot API Key</label>
|
||||
<input type="text" name="pushalot_apikey" value="${config['pushalot_apikey']}" size="30">
|
||||
<small>Separate multiple api keys with commas</small>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<h3>Synology NAS</h3>
|
||||
<div class="checkbox row">
|
||||
@@ -1117,6 +1132,27 @@
|
||||
$("#nmaoptions").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#pushalot").is(":checked"))
|
||||
{
|
||||
$("#pushalotoptions").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#pushalotoptions").hide();
|
||||
}
|
||||
|
||||
$("#pushalot").click(function(){
|
||||
if ($("#pushalot").is(":checked"))
|
||||
{
|
||||
$("#pushalotoptions").slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#pushalotoptions").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#pushover").is(":checked"))
|
||||
{
|
||||
$("#pushoveroptions").show();
|
||||
|
||||
@@ -233,6 +233,9 @@ NMA_ENABLED = False
|
||||
NMA_APIKEY = None
|
||||
NMA_PRIORITY = None
|
||||
NMA_ONSNATCH = None
|
||||
PUSHALOT_ENABLED = False
|
||||
PUSHALOT_APIKEY = None
|
||||
PUSHALOT_ONSNATCH = None
|
||||
SYNOINDEX_ENABLED = False
|
||||
PUSHOVER_ENABLED = True
|
||||
PUSHOVER_PRIORITY = 1
|
||||
@@ -318,7 +321,8 @@ def initialize():
|
||||
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, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB, JOURNAL_MODE, UMASK, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY
|
||||
PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB, JOURNAL_MODE, UMASK, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
|
||||
PUSHALOT_ENABLED, PUSHALOT_APIKEY, PUSHALOT_ONSNATCH
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
@@ -341,6 +345,7 @@ def initialize():
|
||||
CheckSection('Pushover')
|
||||
CheckSection('XBMC')
|
||||
CheckSection('NMA')
|
||||
CheckSection('Pushalot')
|
||||
CheckSection('Synoindex')
|
||||
CheckSection('Advanced')
|
||||
|
||||
@@ -520,6 +525,10 @@ def initialize():
|
||||
NMA_PRIORITY = check_setting_int(CFG, 'NMA', 'nma_priority', 0)
|
||||
NMA_ONSNATCH = bool(check_setting_int(CFG, 'NMA', 'nma_onsnatch', 0))
|
||||
|
||||
PUSHALOT_ENABLED = bool(check_setting_int(CFG, 'Pushalot', 'pushalot_enabled', 0))
|
||||
PUSHALOT_APIKEY = check_setting_str(CFG, 'Pushalot', 'pushalot_apikey', '')
|
||||
PUSHALOT_ONSNATCH = bool(check_setting_int(CFG, 'Pushalot', 'pushalot_onsnatch', 0))
|
||||
|
||||
SYNOINDEX_ENABLED = bool(check_setting_int(CFG, 'Synoindex', 'synoindex_enabled', 0))
|
||||
|
||||
PUSHOVER_ENABLED = bool(check_setting_int(CFG, 'Pushover', 'pushover_enabled', 0))
|
||||
@@ -885,7 +894,12 @@ 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['NMA']['nma_onsnatch'] = int(NMA_ONSNATCH)
|
||||
|
||||
new_config['Pushalot'] = {}
|
||||
new_config['Pushalot']['pushalot_enabled'] = int(PUSHALOT_ENABLED)
|
||||
new_config['Pushalot']['pushalot_apikey'] = PUSHALOT_APIKEY
|
||||
new_config['Pushalot']['pushalot_onsnatch'] = int(PUSHALOT_ONSNATCH)
|
||||
|
||||
new_config['Pushover'] = {}
|
||||
new_config['Pushover']['pushover_enabled'] = int(PUSHOVER_ENABLED)
|
||||
|
||||
@@ -227,6 +227,44 @@ class NMA:
|
||||
if not request:
|
||||
logger.warn('Error sending notification request to NotifyMyAndroid')
|
||||
|
||||
class PUSHALOT:
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.PUSHALOT_ENABLED:
|
||||
return
|
||||
|
||||
pushalot_authorizationtoken = headphones.PUSHALOT_APIKEY
|
||||
|
||||
logger.debug(u"Pushalot event: " + event)
|
||||
logger.debug(u"Pushalot message: " + message)
|
||||
logger.debug(u"Pushalot api: " + pushalot_authorizationtoken)
|
||||
|
||||
http_handler = HTTPSConnection("pushalot.com")
|
||||
|
||||
data = {'AuthorizationToken': pushalot_authorizationtoken,
|
||||
'Title': event.encode('utf-8'),
|
||||
'Body': message.encode("utf-8") }
|
||||
|
||||
http_handler.request("POST",
|
||||
"/api/sendmessage",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
||||
body = urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
logger.debug(u"Pushalot response status: %r" % request_status)
|
||||
logger.debug(u"Pushalot response headers: %r" % response.getheaders())
|
||||
logger.debug(u"Pushalot response body: %r" % response.read())
|
||||
|
||||
if request_status == 200:
|
||||
logger.info(u"Pushalot notifications sent.")
|
||||
return True
|
||||
elif request_status == 410:
|
||||
logger.info(u"Pushalot auth failed: %s" % response.reason)
|
||||
return False
|
||||
else:
|
||||
logger.info(u"Pushalot notification failed.")
|
||||
return False
|
||||
|
||||
class Synoindex:
|
||||
def __init__(self, util_loc='/usr/syno/bin/synoindex'):
|
||||
|
||||
@@ -424,6 +424,12 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(release['ArtistName'], release['AlbumTitle'])
|
||||
|
||||
if headphones.PUSHALOT_ENABLED:
|
||||
pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle']
|
||||
logger.info(u"Pushalot request")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(pushmessage,"Download and Postprocessing completed")
|
||||
|
||||
if headphones.SYNOINDEX_ENABLED:
|
||||
syno = notifiers.Synoindex()
|
||||
for albumpath in albumpaths:
|
||||
|
||||
@@ -131,6 +131,10 @@ def sendNZB(nzb):
|
||||
logger.debug(u"Sending NMA notification")
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(snatched_nzb=nzb.name)
|
||||
if headphones.PUSHALOT_ENABLED and headphones.PUSHALOT_ONSNATCH:
|
||||
logger.info(u"Sending Pushalot notification")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(nzb.name,"Download started")
|
||||
|
||||
return True
|
||||
elif sabText == "Missing authentication":
|
||||
|
||||
@@ -52,6 +52,10 @@ def addTorrent(link):
|
||||
logger.debug(u"Sending NMA notification")
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(snatched_nzb=name)
|
||||
if headphones.PUSHALOT_ENABLED and headphones.PUSHALOT_ONSNATCH:
|
||||
logger.info(u"Sending Pushalot notification")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(name,"Download started")
|
||||
|
||||
return response['arguments']['torrent-added']['id']
|
||||
|
||||
|
||||
@@ -937,6 +937,9 @@ class WebInterface(object):
|
||||
"nma_apikey": headphones.NMA_APIKEY,
|
||||
"nma_priority": int(headphones.NMA_PRIORITY),
|
||||
"nma_onsnatch": checked(headphones.NMA_ONSNATCH),
|
||||
"pushalot_enabled": checked(headphones.PUSHALOT_ENABLED),
|
||||
"pushalot_apikey": headphones.PUSHALOT_APIKEY,
|
||||
"pushalot_onsnatch": checked(headphones.PUSHALOT_ONSNATCH),
|
||||
"synoindex_enabled": checked(headphones.SYNOINDEX_ENABLED),
|
||||
"pushover_enabled": checked(headphones.PUSHOVER_ENABLED),
|
||||
"pushover_onsnatch": checked(headphones.PUSHOVER_ONSNATCH),
|
||||
@@ -983,7 +986,7 @@ class WebInterface(object):
|
||||
remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=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,
|
||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushalot_enabled=False, pushalot_apikey=None, pushalot_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, preferred_bitrate_allow_lossless=0, cache_sizemb=None,
|
||||
enable_https=0, https_cert=None, https_key=None, file_permissions=None, folder_permissions=None, **kwargs):
|
||||
@@ -1109,6 +1112,9 @@ class WebInterface(object):
|
||||
headphones.NMA_APIKEY = nma_apikey
|
||||
headphones.NMA_PRIORITY = nma_priority
|
||||
headphones.NMA_ONSNATCH = nma_onsnatch
|
||||
headphones.PUSHALOT_ENABLED = pushalot_enabled
|
||||
headphones.PUSHALOT_APIKEY = pushalot_apikey
|
||||
headphones.PUSHALOT_ONSNATCH = pushalot_onsnatch
|
||||
headphones.SYNOINDEX_ENABLED = synoindex_enabled
|
||||
headphones.PUSHOVER_ENABLED = pushover_enabled
|
||||
headphones.PUSHOVER_ONSNATCH = pushover_onsnatch
|
||||
|
||||
Reference in New Issue
Block a user