mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-21 12:19:27 +00:00
Added NMA on snatch option
This commit is contained in:
@@ -618,7 +618,10 @@ m<%inherit file="base.html"/>
|
||||
</div>
|
||||
<div id="nmaoptions">
|
||||
<div class="row">
|
||||
<label>NotifyMyAndroid API Key</label>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="nma_onsnatch" value="1" ${config['nma_onsnatch']} /><label>Notify on snatch?</label>
|
||||
</div>
|
||||
<label>NotifyMyAndroid API Key</label>
|
||||
<input type="text" name="nma_apikey" value="${config['nma_apikey']}" size="30">
|
||||
<small>Separate multiple api keys with commas</small>
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
self.notify(path)
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user