mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 11:32:20 -05:00
Add UI option to input users own Pushover API key
This commit is contained in:
parent
4513525cc4
commit
764be940ac
@ -745,6 +745,16 @@
|
|||||||
<span class="component-desc">User key of your Pushover account</span>
|
<span class="component-desc">User key of your Pushover account</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field-pair">
|
||||||
|
<label class="nocheck clearfix">
|
||||||
|
<span class="component-title">Pushover API Key</span>
|
||||||
|
<input type="text" name="pushover_apikey" id="pushover_apikey" value="$sickbeard.PUSHOVER_APIKEY" size="35" />
|
||||||
|
</label>
|
||||||
|
<label class="nocheck clearfix">
|
||||||
|
<span class="component-title"> </span>
|
||||||
|
<span class="component-desc">Leave blank to use default API key</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="testNotification" id="testPushover-result">Click below to test.</div>
|
<div class="testNotification" id="testPushover-result">Click below to test.</div>
|
||||||
<input class="btn" type="button" value="Test Pushover" id="testPushover" />
|
<input class="btn" type="button" value="Test Pushover" id="testPushover" />
|
||||||
<input type="submit" class="config_submitter btn" value="Save Changes" />
|
<input type="submit" class="config_submitter btn" value="Save Changes" />
|
||||||
|
@ -57,7 +57,8 @@ $(document).ready(function(){
|
|||||||
$('#testPushover').click(function() {
|
$('#testPushover').click(function() {
|
||||||
$('#testPushover-result').html(loading);
|
$('#testPushover-result').html(loading);
|
||||||
var pushover_userkey = $("#pushover_userkey").val();
|
var pushover_userkey = $("#pushover_userkey").val();
|
||||||
$.get(sbRoot + "/home/testPushover", {'userKey': pushover_userkey},
|
var pushover_apikey = $("#pushover_apikey").val();
|
||||||
|
$.get(sbRoot + "/home/testPushover", {'userKey': pushover_userkey, 'apiKey': pushover_apikey},
|
||||||
function (data) { $('#testPushover-result').html(data); });
|
function (data) { $('#testPushover-result').html(data); });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -313,6 +313,7 @@ PUSHOVER_NOTIFY_ONSNATCH = False
|
|||||||
PUSHOVER_NOTIFY_ONDOWNLOAD = False
|
PUSHOVER_NOTIFY_ONDOWNLOAD = False
|
||||||
PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = False
|
PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = False
|
||||||
PUSHOVER_USERKEY = None
|
PUSHOVER_USERKEY = None
|
||||||
|
PUSHOVER_APIKEY = None
|
||||||
|
|
||||||
USE_LIBNOTIFY = False
|
USE_LIBNOTIFY = False
|
||||||
LIBNOTIFY_NOTIFY_ONSNATCH = False
|
LIBNOTIFY_NOTIFY_ONSNATCH = False
|
||||||
@ -463,7 +464,7 @@ def initialize(consoleLogging=True):
|
|||||||
EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, DAILYSEARCH_FREQUENCY, \
|
EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, DAILYSEARCH_FREQUENCY, \
|
||||||
USE_BOXCAR, BOXCAR_USERNAME, BOXCAR_PASSWORD, BOXCAR_NOTIFY_ONDOWNLOAD, BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD, BOXCAR_NOTIFY_ONSNATCH, \
|
USE_BOXCAR, BOXCAR_USERNAME, BOXCAR_PASSWORD, BOXCAR_NOTIFY_ONDOWNLOAD, BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD, BOXCAR_NOTIFY_ONSNATCH, \
|
||||||
USE_BOXCAR2, BOXCAR2_ACCESSTOKEN, BOXCAR2_NOTIFY_ONDOWNLOAD, BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD, BOXCAR2_NOTIFY_ONSNATCH, \
|
USE_BOXCAR2, BOXCAR2_ACCESSTOKEN, BOXCAR2_NOTIFY_ONDOWNLOAD, BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD, BOXCAR2_NOTIFY_ONSNATCH, \
|
||||||
USE_PUSHOVER, PUSHOVER_USERKEY, PUSHOVER_NOTIFY_ONDOWNLOAD, PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHOVER_NOTIFY_ONSNATCH, \
|
USE_PUSHOVER, PUSHOVER_USERKEY, PUSHOVER_APIKEY, PUSHOVER_NOTIFY_ONDOWNLOAD, PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHOVER_NOTIFY_ONSNATCH, \
|
||||||
USE_LIBNOTIFY, LIBNOTIFY_NOTIFY_ONSNATCH, LIBNOTIFY_NOTIFY_ONDOWNLOAD, LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD, USE_NMJ, NMJ_HOST, NMJ_DATABASE, NMJ_MOUNT, USE_NMJv2, NMJv2_HOST, NMJv2_DATABASE, NMJv2_DBLOC, USE_SYNOINDEX, \
|
USE_LIBNOTIFY, LIBNOTIFY_NOTIFY_ONSNATCH, LIBNOTIFY_NOTIFY_ONDOWNLOAD, LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD, USE_NMJ, NMJ_HOST, NMJ_DATABASE, NMJ_MOUNT, USE_NMJv2, NMJv2_HOST, NMJv2_DATABASE, NMJv2_DBLOC, USE_SYNOINDEX, \
|
||||||
USE_SYNOLOGYNOTIFIER, SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH, SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD, SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD, \
|
USE_SYNOLOGYNOTIFIER, SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH, SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD, SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD, \
|
||||||
USE_EMAIL, EMAIL_HOST, EMAIL_PORT, EMAIL_TLS, EMAIL_USER, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_NOTIFY_ONSNATCH, EMAIL_NOTIFY_ONDOWNLOAD, EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD, EMAIL_LIST, \
|
USE_EMAIL, EMAIL_HOST, EMAIL_PORT, EMAIL_TLS, EMAIL_USER, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_NOTIFY_ONSNATCH, EMAIL_NOTIFY_ONDOWNLOAD, EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD, EMAIL_LIST, \
|
||||||
@ -754,7 +755,7 @@ def initialize(consoleLogging=True):
|
|||||||
PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = bool(
|
PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = bool(
|
||||||
check_setting_int(CFG, 'Pushover', 'pushover_notify_onsubtitledownload', 0))
|
check_setting_int(CFG, 'Pushover', 'pushover_notify_onsubtitledownload', 0))
|
||||||
PUSHOVER_USERKEY = check_setting_str(CFG, 'Pushover', 'pushover_userkey', '')
|
PUSHOVER_USERKEY = check_setting_str(CFG, 'Pushover', 'pushover_userkey', '')
|
||||||
|
PUSHOVER_APIKEY = check_setting_str(CFG, 'Pushover', 'pushover_apikey', '')
|
||||||
USE_LIBNOTIFY = bool(check_setting_int(CFG, 'Libnotify', 'use_libnotify', 0))
|
USE_LIBNOTIFY = bool(check_setting_int(CFG, 'Libnotify', 'use_libnotify', 0))
|
||||||
LIBNOTIFY_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Libnotify', 'libnotify_notify_onsnatch', 0))
|
LIBNOTIFY_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Libnotify', 'libnotify_notify_onsnatch', 0))
|
||||||
LIBNOTIFY_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Libnotify', 'libnotify_notify_ondownload', 0))
|
LIBNOTIFY_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Libnotify', 'libnotify_notify_ondownload', 0))
|
||||||
@ -1650,6 +1651,7 @@ def save_config():
|
|||||||
new_config['Pushover']['pushover_notify_ondownload'] = int(PUSHOVER_NOTIFY_ONDOWNLOAD)
|
new_config['Pushover']['pushover_notify_ondownload'] = int(PUSHOVER_NOTIFY_ONDOWNLOAD)
|
||||||
new_config['Pushover']['pushover_notify_onsubtitledownload'] = int(PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD)
|
new_config['Pushover']['pushover_notify_onsubtitledownload'] = int(PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD)
|
||||||
new_config['Pushover']['pushover_userkey'] = PUSHOVER_USERKEY
|
new_config['Pushover']['pushover_userkey'] = PUSHOVER_USERKEY
|
||||||
|
new_config['Pushover']['pushover_apikey'] = PUSHOVER_APIKEY
|
||||||
|
|
||||||
new_config['Libnotify'] = {}
|
new_config['Libnotify'] = {}
|
||||||
new_config['Libnotify']['use_libnotify'] = int(USE_LIBNOTIFY)
|
new_config['Libnotify']['use_libnotify'] = int(USE_LIBNOTIFY)
|
||||||
|
@ -32,10 +32,10 @@ API_KEY = "awKfdt263PLaEWV9RXuSn4c46qoAyA"
|
|||||||
|
|
||||||
|
|
||||||
class PushoverNotifier:
|
class PushoverNotifier:
|
||||||
def test_notify(self, userKey=None):
|
def test_notify(self, userKey=None, apiKey=None):
|
||||||
return self._notifyPushover("This is a test notification from SickRage", 'Test', userKey, force=True)
|
return self._notifyPushover("This is a test notification from SickRage", 'Test', userKey, force=True)
|
||||||
|
|
||||||
def _sendPushover(self, msg, title, userKey=None):
|
def _sendPushover(self, msg, title, userKey=None, apiKey=None):
|
||||||
"""
|
"""
|
||||||
Sends a pushover notification to the address provided
|
Sends a pushover notification to the address provided
|
||||||
|
|
||||||
@ -49,12 +49,17 @@ class PushoverNotifier:
|
|||||||
if not userKey:
|
if not userKey:
|
||||||
userKey = sickbeard.PUSHOVER_USERKEY
|
userKey = sickbeard.PUSHOVER_USERKEY
|
||||||
|
|
||||||
|
if not apiKey:
|
||||||
|
apiKey = sickbeard.PUSHOVER_APIKEY or API_KEY
|
||||||
|
|
||||||
|
logger.log("Pushover API KEY in use: " + apiKey, logger.DEBUG)
|
||||||
|
|
||||||
# build up the URL and parameters
|
# build up the URL and parameters
|
||||||
msg = msg.strip()
|
msg = msg.strip()
|
||||||
curUrl = API_URL
|
curUrl = API_URL
|
||||||
|
|
||||||
data = urllib.urlencode({
|
data = urllib.urlencode({
|
||||||
'token': API_KEY,
|
'token': apiKey,
|
||||||
'title': title,
|
'title': title,
|
||||||
'user': userKey,
|
'user': userKey,
|
||||||
'message': msg.encode('utf-8'),
|
'message': msg.encode('utf-8'),
|
||||||
@ -85,7 +90,7 @@ class PushoverNotifier:
|
|||||||
elif e.code == 401:
|
elif e.code == 401:
|
||||||
|
|
||||||
#HTTP status 401 if the user doesn't have the service added
|
#HTTP status 401 if the user doesn't have the service added
|
||||||
subscribeNote = self._sendPushover(msg, title, userKey)
|
subscribeNote = self._sendPushover(msg, title, userKey, apiKey)
|
||||||
if subscribeNote:
|
if subscribeNote:
|
||||||
logger.log("Subscription send", logger.DEBUG)
|
logger.log("Subscription send", logger.DEBUG)
|
||||||
return True
|
return True
|
||||||
@ -114,7 +119,7 @@ class PushoverNotifier:
|
|||||||
if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD:
|
if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||||
self._notifyPushover(title, ep_name + ": " + lang)
|
self._notifyPushover(title, ep_name + ": " + lang)
|
||||||
|
|
||||||
def _notifyPushover(self, title, message, userKey=None, force=False):
|
def _notifyPushover(self, title, message, userKey=None, apiKey=None, force=False):
|
||||||
"""
|
"""
|
||||||
Sends a pushover notification based on the provided info or SB config
|
Sends a pushover notification based on the provided info or SB config
|
||||||
|
|
||||||
@ -130,8 +135,8 @@ class PushoverNotifier:
|
|||||||
|
|
||||||
logger.log("Sending notification for " + message, logger.DEBUG)
|
logger.log("Sending notification for " + message, logger.DEBUG)
|
||||||
|
|
||||||
# self._sendPushover(message, title, userKey)
|
# self._sendPushover(message, title, userKey, apiKey)
|
||||||
return self._sendPushover(message, title)
|
return self._sendPushover(message, title, userKey, apiKey)
|
||||||
|
|
||||||
|
|
||||||
notifier = PushoverNotifier
|
notifier = PushoverNotifier
|
||||||
|
@ -2123,7 +2123,7 @@ class ConfigNotifications(IndexHandler):
|
|||||||
use_boxcar2=None, boxcar2_notify_onsnatch=None, boxcar2_notify_ondownload=None,
|
use_boxcar2=None, boxcar2_notify_onsnatch=None, boxcar2_notify_ondownload=None,
|
||||||
boxcar2_notify_onsubtitledownload=None, boxcar2_accesstoken=None,
|
boxcar2_notify_onsubtitledownload=None, boxcar2_accesstoken=None,
|
||||||
use_pushover=None, pushover_notify_onsnatch=None, pushover_notify_ondownload=None,
|
use_pushover=None, pushover_notify_onsnatch=None, pushover_notify_ondownload=None,
|
||||||
pushover_notify_onsubtitledownload=None, pushover_userkey=None,
|
pushover_notify_onsubtitledownload=None, pushover_userkey=None, pushover_apikey=None,
|
||||||
use_libnotify=None, libnotify_notify_onsnatch=None, libnotify_notify_ondownload=None,
|
use_libnotify=None, libnotify_notify_onsnatch=None, libnotify_notify_ondownload=None,
|
||||||
libnotify_notify_onsubtitledownload=None,
|
libnotify_notify_onsubtitledownload=None,
|
||||||
use_nmj=None, nmj_host=None, nmj_database=None, nmj_mount=None, use_synoindex=None,
|
use_nmj=None, nmj_host=None, nmj_database=None, nmj_mount=None, use_synoindex=None,
|
||||||
@ -2208,6 +2208,7 @@ class ConfigNotifications(IndexHandler):
|
|||||||
sickbeard.PUSHOVER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(pushover_notify_ondownload)
|
sickbeard.PUSHOVER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(pushover_notify_ondownload)
|
||||||
sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(pushover_notify_onsubtitledownload)
|
sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(pushover_notify_onsubtitledownload)
|
||||||
sickbeard.PUSHOVER_USERKEY = pushover_userkey
|
sickbeard.PUSHOVER_USERKEY = pushover_userkey
|
||||||
|
sickbeard.PUSHOVER_APIKEY = pushover_apikey
|
||||||
|
|
||||||
sickbeard.USE_LIBNOTIFY = config.checkbox_to_value(use_libnotify)
|
sickbeard.USE_LIBNOTIFY = config.checkbox_to_value(use_libnotify)
|
||||||
sickbeard.LIBNOTIFY_NOTIFY_ONSNATCH = config.checkbox_to_value(libnotify_notify_onsnatch)
|
sickbeard.LIBNOTIFY_NOTIFY_ONSNATCH = config.checkbox_to_value(libnotify_notify_onsnatch)
|
||||||
@ -3058,10 +3059,10 @@ class Home(IndexHandler):
|
|||||||
return "Error sending Boxcar2 notification"
|
return "Error sending Boxcar2 notification"
|
||||||
|
|
||||||
|
|
||||||
def testPushover(self, userKey=None):
|
def testPushover(self, userKey=None, apiKey=None):
|
||||||
self.set_header('Cache-Control', "max-age=0,no-cache,no-store")
|
self.set_header('Cache-Control', "max-age=0,no-cache,no-store")
|
||||||
|
|
||||||
result = notifiers.pushover_notifier.test_notify(userKey)
|
result = notifiers.pushover_notifier.test_notify(userKey, apiKey)
|
||||||
if result:
|
if result:
|
||||||
return "Pushover notification succeeded. Check your Pushover clients to make sure it worked"
|
return "Pushover notification succeeded. Check your Pushover clients to make sure it worked"
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user