mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-23 01:43:43 +00:00
Boxcar2 notifier changes
This commit is contained in:
parent
73bdfc0777
commit
a5dfb0135d
6 changed files with 1916 additions and 1865 deletions
|
@ -37,6 +37,8 @@
|
||||||
* Remove duplicate thepiratebay icon
|
* Remove duplicate thepiratebay icon
|
||||||
* Change to ensure uTorrent API parameters are ordered for uT 2.2.1 compatibility
|
* Change to ensure uTorrent API parameters are ordered for uT 2.2.1 compatibility
|
||||||
* Remove defunct boxcar notifier
|
* Remove defunct boxcar notifier
|
||||||
|
* Add sound selection for boxcar2 notifier
|
||||||
|
* Change boxcar2 notifier to use updated api scheme
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
* Change uT params from unicode to str.format as magnet URLs worked but sending files in POST bodies failed
|
* Change uT params from unicode to str.format as magnet URLs worked but sending files in POST bodies failed
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#import sickbeard
|
#import sickbeard
|
||||||
#from sickbeard.helpers import anon_url
|
#from sickbeard.helpers import anon_url
|
||||||
|
|
||||||
#set global $title="Config - Notifications"
|
#set global $title = 'Config - Notifications'
|
||||||
#set global $header="Notifications"
|
#set global $header = 'Notifications'
|
||||||
|
|
||||||
#set global $sbPath="../.."
|
#set global $sbPath = '../..'
|
||||||
|
|
||||||
#set global $topmenu="config"#
|
#set global $topmenu = 'config'
|
||||||
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl")
|
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl')
|
||||||
|
|
||||||
<script type="text/javascript" src="$sbRoot/js/configNotifications.js?$sbPID"></script>
|
<script type="text/javascript" src="$sbRoot/js/configNotifications.js?$sbPID"></script>
|
||||||
<script type="text/javascript" src="$sbRoot/js/config.js?$sbPID"></script>
|
<script type="text/javascript" src="$sbRoot/js/config.js?$sbPID"></script>
|
||||||
|
@ -905,6 +905,47 @@
|
||||||
<span class="component-desc">access token for your Boxcar2 account.</span>
|
<span class="component-desc">access token for your Boxcar2 account.</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field-pair">
|
||||||
|
<label for="boxcar2_sound">
|
||||||
|
<span class="component-title">Custom sound</span>
|
||||||
|
<select id="boxcar2_sound" name="boxcar2_sound" class="form-control input-sm">
|
||||||
|
<option value="default" #if $sickbeard.BOXCAR2_SOUND == "default" then 'selected="selected"' else ""#>Default (General)</option>
|
||||||
|
<option value="no-sound" #if $sickbeard.BOXCAR2_SOUND == "no-sound" then 'selected="selected"' else ""#>Silent</option>
|
||||||
|
<option value="beep-crisp" #if $sickbeard.BOXCAR2_SOUND == "beep-crisp" then 'selected="selected"' else ""#>Beep Crisp</option>
|
||||||
|
<option value="beep-soft" #if $sickbeard.BOXCAR2_SOUND == "beep-soft" then 'selected="selected"' else ""#>Beep Soft</option>
|
||||||
|
<option value="bell-modern" #if $sickbeard.BOXCAR2_SOUND == "bell-modern" then 'selected="selected"' else ""#>Bell Modern</option>
|
||||||
|
<option value="bell-one-tone" #if $sickbeard.BOXCAR2_SOUND == "bell-one-tone" then 'selected="selected"' else ""#>Bell One Tone</option>
|
||||||
|
<option value="bell-simple" #if $sickbeard.BOXCAR2_SOUND == "bell-simple" then 'selected="selected"' else ""#>Bell Simple</option>
|
||||||
|
<option value="bell-triple" #if $sickbeard.BOXCAR2_SOUND == "bell-triple" then 'selected="selected"' else ""#>Bell Triple</option>
|
||||||
|
<option value="bird-1" #if $sickbeard.BOXCAR2_SOUND == "bird-1" then 'selected="selected"' else ""#>Bird 1</option>
|
||||||
|
<option value="bird-2" #if $sickbeard.BOXCAR2_SOUND == "bird-2" then 'selected="selected"' else ""#>Bird 2</option>
|
||||||
|
<option value="boing" #if $sickbeard.BOXCAR2_SOUND == "boing" then 'selected="selected"' else ""#>Boing</option>
|
||||||
|
<option value="cash" #if $sickbeard.BOXCAR2_SOUND == "cash" then 'selected="selected"' else ""#>Cash</option>
|
||||||
|
<option value="clanging" #if $sickbeard.BOXCAR2_SOUND == "clanging" then 'selected="selected"' else ""#>Clanging</option>
|
||||||
|
<option value="detonator-charge" #if $sickbeard.BOXCAR2_SOUND == "detonator-charge" then 'selected="selected"' else ""#>Detonator Charge</option>
|
||||||
|
<option value="digital-alarm" #if $sickbeard.BOXCAR2_SOUND == "digital-alarm" then 'selected="selected"' else ""#>Digital Alarm</option>
|
||||||
|
<option value="done" #if $sickbeard.BOXCAR2_SOUND == "done" then 'selected="selected"' else ""#>Done</option>
|
||||||
|
<option value="echo" #if $sickbeard.BOXCAR2_SOUND == "echo" then 'selected="selected"' else ""#>Echo</option>
|
||||||
|
<option value="flourish" #if $sickbeard.BOXCAR2_SOUND == "flourish" then 'selected="selected"' else ""#>Flourish</option>
|
||||||
|
<option value="harp" #if $sickbeard.BOXCAR2_SOUND == "harp" then 'selected="selected"' else ""#>Harp</option>
|
||||||
|
<option value="light" #if $sickbeard.BOXCAR2_SOUND == "light" then 'selected="selected"' else ""#>Light</option>
|
||||||
|
<option value="magic-chime" #if $sickbeard.BOXCAR2_SOUND == "magic-chime" then 'selected="selected"' else ""#>Magic Chime</option>
|
||||||
|
<option value="magic-coin" #if $sickbeard.BOXCAR2_SOUND == "magic-coin" then 'selected="selected"' else ""#>Magic Coin 1</option>
|
||||||
|
<option value="notifier-1" #if $sickbeard.BOXCAR2_SOUND == "notifier-1" then 'selected="selected"' else ""#>Notifier 1</option>
|
||||||
|
<option value="notifier-2" #if $sickbeard.BOXCAR2_SOUND == "notifier-2" then 'selected="selected"' else ""#>Notifier 2</option>
|
||||||
|
<option value="notifier-3" #if $sickbeard.BOXCAR2_SOUND == "notifier-3" then 'selected="selected"' else ""#>Notifier 3</option>
|
||||||
|
<option value="orchestral-long" #if $sickbeard.BOXCAR2_SOUND == "orchestral-long" then 'selected="selected"' else ""#>Orchestral Long</option>
|
||||||
|
<option value="orchestral-short" #if $sickbeard.BOXCAR2_SOUND == "orchestral-short" then 'selected="selected"' else ""#>Orchestral Short</option>
|
||||||
|
<option value="score" #if $sickbeard.BOXCAR2_SOUND == "score" then 'selected="selected"' else ""#>Score</option>
|
||||||
|
<option value="success" #if $sickbeard.BOXCAR2_SOUND == "success" then 'selected="selected"' else ""#>Success</option>
|
||||||
|
<option value="up" #if $sickbeard.BOXCAR2_SOUND == "up" then 'selected="selected"' else ""#>Up</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span class="component-title"> </span>
|
||||||
|
<span class="component-desc">override the default sound selected for the general notification.</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="testNotification" id="testBoxcar2-result">Click below to test.</div>
|
<div class="testNotification" id="testBoxcar2-result">Click below to test.</div>
|
||||||
<input class="btn" type="button" value="Test Boxcar2" id="testBoxcar2" />
|
<input class="btn" type="button" value="Test Boxcar2" id="testBoxcar2" />
|
||||||
<input type="submit" class="config_submitter btn" value="Save Changes" />
|
<input type="submit" class="config_submitter btn" value="Save Changes" />
|
||||||
|
@ -1497,4 +1538,4 @@
|
||||||
jQuery('#config-components').tabs();
|
jQuery('#config-components').tabs();
|
||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
#include $os.path.join($sickbeard.PROG_DIR,"gui/slick/interfaces/default/inc_bottom.tmpl")
|
#include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl')
|
||||||
|
|
|
@ -77,6 +77,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
$('#testBoxcar2').click(function () {
|
$('#testBoxcar2').click(function () {
|
||||||
var boxcar2_accesstoken = $.trim($('#boxcar2_accesstoken').val());
|
var boxcar2_accesstoken = $.trim($('#boxcar2_accesstoken').val());
|
||||||
|
var boxcar2_sound = $('#boxcar2_sound').val() || 'default';
|
||||||
if (!boxcar2_accesstoken) {
|
if (!boxcar2_accesstoken) {
|
||||||
$('#testBoxcar2-result').html('Please fill out the necessary fields above.');
|
$('#testBoxcar2-result').html('Please fill out the necessary fields above.');
|
||||||
$('#boxcar2_accesstoken').addClass('warning');
|
$('#boxcar2_accesstoken').addClass('warning');
|
||||||
|
@ -85,7 +86,7 @@ $(document).ready(function(){
|
||||||
$('#boxcar2_accesstoken').removeClass('warning');
|
$('#boxcar2_accesstoken').removeClass('warning');
|
||||||
$(this).prop('disabled', true);
|
$(this).prop('disabled', true);
|
||||||
$('#testBoxcar2-result').html(loading);
|
$('#testBoxcar2-result').html(loading);
|
||||||
$.get(sbRoot + '/home/testBoxcar2', {'accessToken': boxcar2_accesstoken})
|
$.get(sbRoot + '/home/testBoxcar2', {'accesstoken': boxcar2_accesstoken, 'sound': boxcar2_sound})
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
$('#testBoxcar2-result').html(data);
|
$('#testBoxcar2-result').html(data);
|
||||||
$('#testBoxcar2').prop('disabled', false);
|
$('#testBoxcar2').prop('disabled', false);
|
||||||
|
|
|
@ -314,6 +314,7 @@ BOXCAR2_NOTIFY_ONSNATCH = False
|
||||||
BOXCAR2_NOTIFY_ONDOWNLOAD = False
|
BOXCAR2_NOTIFY_ONDOWNLOAD = False
|
||||||
BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = False
|
BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = False
|
||||||
BOXCAR2_ACCESSTOKEN = None
|
BOXCAR2_ACCESSTOKEN = None
|
||||||
|
BOXCAR2_SOUND = None
|
||||||
|
|
||||||
USE_PUSHOVER = False
|
USE_PUSHOVER = False
|
||||||
PUSHOVER_NOTIFY_ONSNATCH = False
|
PUSHOVER_NOTIFY_ONSNATCH = False
|
||||||
|
@ -483,7 +484,7 @@ def initialize(consoleLogging=True):
|
||||||
RENAME_EPISODES, AIRDATE_EPISODES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \
|
RENAME_EPISODES, AIRDATE_EPISODES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \
|
||||||
WOMBLE, OMGWTFNZBS, OMGWTFNZBS_USERNAME, OMGWTFNZBS_APIKEY, providerList, newznabProviderList, torrentRssProviderList, \
|
WOMBLE, OMGWTFNZBS, OMGWTFNZBS_USERNAME, OMGWTFNZBS_APIKEY, providerList, newznabProviderList, torrentRssProviderList, \
|
||||||
EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, RECENTSEARCH_FREQUENCY, \
|
EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, RECENTSEARCH_FREQUENCY, \
|
||||||
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, BOXCAR2_SOUND, \
|
||||||
USE_PUSHOVER, PUSHOVER_USERKEY, PUSHOVER_APIKEY, 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, \
|
||||||
|
@ -789,6 +790,7 @@ def initialize(consoleLogging=True):
|
||||||
BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = bool(
|
BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = bool(
|
||||||
check_setting_int(CFG, 'Boxcar2', 'boxcar2_notify_onsubtitledownload', 0))
|
check_setting_int(CFG, 'Boxcar2', 'boxcar2_notify_onsubtitledownload', 0))
|
||||||
BOXCAR2_ACCESSTOKEN = check_setting_str(CFG, 'Boxcar2', 'boxcar2_accesstoken', '')
|
BOXCAR2_ACCESSTOKEN = check_setting_str(CFG, 'Boxcar2', 'boxcar2_accesstoken', '')
|
||||||
|
BOXCAR2_SOUND = check_setting_str(CFG, 'Boxcar2', 'boxcar2_sound', 'default')
|
||||||
|
|
||||||
USE_PUSHOVER = bool(check_setting_int(CFG, 'Pushover', 'use_pushover', 0))
|
USE_PUSHOVER = bool(check_setting_int(CFG, 'Pushover', 'use_pushover', 0))
|
||||||
PUSHOVER_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Pushover', 'pushover_notify_onsnatch', 0))
|
PUSHOVER_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Pushover', 'pushover_notify_onsnatch', 0))
|
||||||
|
@ -1631,6 +1633,7 @@ def save_config():
|
||||||
new_config['Boxcar2']['boxcar2_notify_ondownload'] = int(BOXCAR2_NOTIFY_ONDOWNLOAD)
|
new_config['Boxcar2']['boxcar2_notify_ondownload'] = int(BOXCAR2_NOTIFY_ONDOWNLOAD)
|
||||||
new_config['Boxcar2']['boxcar2_notify_onsubtitledownload'] = int(BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD)
|
new_config['Boxcar2']['boxcar2_notify_onsubtitledownload'] = int(BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD)
|
||||||
new_config['Boxcar2']['boxcar2_accesstoken'] = BOXCAR2_ACCESSTOKEN
|
new_config['Boxcar2']['boxcar2_accesstoken'] = BOXCAR2_ACCESSTOKEN
|
||||||
|
new_config['Boxcar2']['boxcar2_sound'] = BOXCAR2_SOUND
|
||||||
|
|
||||||
new_config['Pushover'] = {}
|
new_config['Pushover'] = {}
|
||||||
new_config['Pushover']['use_pushover'] = int(USE_PUSHOVER)
|
new_config['Pushover']['use_pushover'] = int(USE_PUSHOVER)
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import urllib, urllib2
|
import urllib
|
||||||
|
import urllib2
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
@ -27,14 +28,11 @@ from sickbeard import logger
|
||||||
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_GIT_UPDATE, NOTIFY_GIT_UPDATE_TEXT
|
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_GIT_UPDATE, NOTIFY_GIT_UPDATE_TEXT
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
|
|
||||||
API_URL = "https://new.boxcar.io/api/notifications"
|
API_URL = 'https://new.boxcar.io/api/notifications'
|
||||||
|
|
||||||
|
|
||||||
class Boxcar2Notifier:
|
class Boxcar2Notifier:
|
||||||
def test_notify(self, accesstoken, title="SickGear : Test"):
|
def _sendBoxcar2(self, title, msg, accesstoken, sound):
|
||||||
return self._sendBoxcar2("This is a test notification from SickGear", title, accesstoken)
|
|
||||||
|
|
||||||
def _sendBoxcar2(self, msg, title, accesstoken):
|
|
||||||
"""
|
"""
|
||||||
Sends a boxcar2 notification to the address provided
|
Sends a boxcar2 notification to the address provided
|
||||||
|
|
||||||
|
@ -47,83 +45,88 @@ class Boxcar2Notifier:
|
||||||
|
|
||||||
# build up the URL and parameters
|
# build up the URL and parameters
|
||||||
# more info goes here - https://boxcar.uservoice.com/knowledgebase/articles/306788-how-to-send-your-boxcar-account-a-notification
|
# more info goes here - https://boxcar.uservoice.com/knowledgebase/articles/306788-how-to-send-your-boxcar-account-a-notification
|
||||||
msg = msg.strip()
|
msg = msg.strip().encode('utf-8')
|
||||||
curUrl = API_URL
|
|
||||||
|
|
||||||
data = urllib.urlencode({
|
data = urllib.urlencode({
|
||||||
'user_credentials': accesstoken,
|
'user_credentials': accesstoken,
|
||||||
'notification[title]': "SickGear : " + title + ' : ' + msg,
|
'notification[title]': title + ' - ' + msg,
|
||||||
'notification[long_message]': msg,
|
'notification[long_message]': msg,
|
||||||
'notification[sound]': "notifier-2"
|
'notification[sound]': sound,
|
||||||
|
'notification[source_name]': 'SickGear',
|
||||||
|
'notification[icon_url]': 'https://cdn.rawgit.com/SickGear/SickGear/master/gui/slick/images/ico/apple-touch-icon-60x60.png'
|
||||||
})
|
})
|
||||||
|
|
||||||
# send the request to boxcar2
|
# send the request to boxcar2
|
||||||
try:
|
try:
|
||||||
req = urllib2.Request(curUrl)
|
req = urllib2.Request(API_URL)
|
||||||
handle = urllib2.urlopen(req, data)
|
handle = urllib2.urlopen(req, data)
|
||||||
handle.close()
|
handle.close()
|
||||||
|
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.URLError, e:
|
||||||
# if we get an error back that doesn't have an error code then who knows what's really happening
|
# if we get an error back that doesn't have an error code then who knows what's really happening
|
||||||
if not hasattr(e, 'code'):
|
if not hasattr(e, 'code'):
|
||||||
logger.log("Boxcar2 notification failed." + ex(e), logger.ERROR)
|
logger.log(u'BOXCAR2: Notification failed.' + ex(e), logger.ERROR)
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
logger.log("Boxcar2 notification failed. Error code: " + str(e.code), logger.WARNING)
|
logger.log(u'BOXCAR2: Notification failed. Error code: ' + str(e.code), logger.ERROR)
|
||||||
|
|
||||||
# HTTP status 404
|
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
logger.log("Access token is invalid. Check it.", logger.WARNING)
|
logger.log(u'BOXCAR2: Access token is wrong/not associated to a device.', logger.ERROR)
|
||||||
return False
|
elif e.code == 401:
|
||||||
|
logger.log(u'BOXCAR2: Access token not recognized.', logger.ERROR)
|
||||||
# If you receive an HTTP status code of 400, it is because you failed to send the proper parameters
|
|
||||||
elif e.code == 400:
|
elif e.code == 400:
|
||||||
logger.log("Wrong data sent to boxcar2", logger.ERROR)
|
logger.log(u'BOXCAR2: Wrong data sent to boxcar.', logger.ERROR)
|
||||||
|
elif e.code == 503:
|
||||||
|
logger.log(u'BOXCAR2: Boxcar server to busy to handle the request at this time.', logger.WARNING)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logger.log("Boxcar2 notification successful.", logger.DEBUG)
|
logger.log(u'BOXCAR2: Notification successful.', logger.MESSAGE)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def notify_snatch(self, ep_name, title=notifyStrings[NOTIFY_SNATCH]):
|
def _notifyBoxcar2(self, title, message, accesstoken=None, sound=None, force=False):
|
||||||
|
"""
|
||||||
|
Sends a boxcar2 notification based on the provided info or SG config
|
||||||
|
|
||||||
|
title: The title of the notification to send
|
||||||
|
message: The message string to send
|
||||||
|
accesstoken: to send to this device
|
||||||
|
force: If True then the notification will be sent even if Boxcar is disabled in the config
|
||||||
|
"""
|
||||||
|
|
||||||
|
# suppress notifications if the notifier is disabled but the notify options are checked
|
||||||
|
if not sickbeard.USE_BOXCAR2 and not force:
|
||||||
|
logger.log(u'BOXCAR2: Notifications are not enabled, skipping this notification', logger.DEBUG)
|
||||||
|
return False
|
||||||
|
|
||||||
|
# fill in omitted parameters
|
||||||
|
if not accesstoken:
|
||||||
|
accesstoken = sickbeard.BOXCAR2_ACCESSTOKEN
|
||||||
|
if not sound:
|
||||||
|
sound = sickbeard.BOXCAR2_SOUND
|
||||||
|
|
||||||
|
logger.log(u'BOXCAR2: Sending notification for ' + message, logger.DEBUG)
|
||||||
|
|
||||||
|
self._sendBoxcar2(title, message, accesstoken, sound)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def test_notify(self, accesstoken, sound, force=True):
|
||||||
|
return self._sendBoxcar2('Test', 'This is a test notification from SickGear', accesstoken, sound)
|
||||||
|
|
||||||
|
def notify_snatch(self, ep_name):
|
||||||
if sickbeard.BOXCAR2_NOTIFY_ONSNATCH:
|
if sickbeard.BOXCAR2_NOTIFY_ONSNATCH:
|
||||||
self._notifyBoxcar2(title, ep_name)
|
self._notifyBoxcar2(notifyStrings[NOTIFY_SNATCH], ep_name)
|
||||||
|
|
||||||
|
def notify_download(self, ep_name):
|
||||||
def notify_download(self, ep_name, title=notifyStrings[NOTIFY_DOWNLOAD]):
|
|
||||||
if sickbeard.BOXCAR2_NOTIFY_ONDOWNLOAD:
|
if sickbeard.BOXCAR2_NOTIFY_ONDOWNLOAD:
|
||||||
self._notifyBoxcar2(title, ep_name)
|
self._notifyBoxcar2(notifyStrings[NOTIFY_DOWNLOAD], ep_name)
|
||||||
|
|
||||||
def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]):
|
def notify_subtitle_download(self, ep_name, lang):
|
||||||
if sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD:
|
if sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||||
self._notifyBoxcar2(title, ep_name + ": " + lang)
|
self._notifyBoxcar2(notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ': ' + lang)
|
||||||
|
|
||||||
def notify_git_update(self, new_version = "??"):
|
def notify_git_update(self, new_version = '??'):
|
||||||
if sickbeard.USE_BOXCAR2:
|
if sickbeard.USE_BOXCAR2:
|
||||||
update_text=notifyStrings[NOTIFY_GIT_UPDATE_TEXT]
|
update_text=notifyStrings[NOTIFY_GIT_UPDATE_TEXT]
|
||||||
title=notifyStrings[NOTIFY_GIT_UPDATE]
|
title=notifyStrings[NOTIFY_GIT_UPDATE]
|
||||||
self._notifyBoxcar2(title, update_text + new_version)
|
self._notifyBoxcar2(title, update_text + new_version)
|
||||||
|
|
||||||
def _notifyBoxcar2(self, title, message, accesstoken=None):
|
|
||||||
"""
|
|
||||||
Sends a boxcar2 notification based on the provided info or SB config
|
|
||||||
|
|
||||||
title: The title of the notification to send
|
|
||||||
message: The message string to send
|
|
||||||
accesstoken: to send to this device
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not sickbeard.USE_BOXCAR2:
|
|
||||||
logger.log("Notification for Boxcar2 not enabled, skipping this notification", logger.DEBUG)
|
|
||||||
return False
|
|
||||||
|
|
||||||
# if no username was given then use the one from the config
|
|
||||||
if not accesstoken:
|
|
||||||
accesstoken = sickbeard.BOXCAR2_ACCESSTOKEN
|
|
||||||
|
|
||||||
logger.log("Sending notification for " + message, logger.DEBUG)
|
|
||||||
|
|
||||||
self._sendBoxcar2(message, title, accesstoken)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
notifier = Boxcar2Notifier
|
notifier = Boxcar2Notifier
|
||||||
|
|
|
@ -2345,7 +2345,7 @@ class ConfigNotifications(MainHandler):
|
||||||
use_twitter=None, twitter_notify_onsnatch=None, twitter_notify_ondownload=None,
|
use_twitter=None, twitter_notify_onsnatch=None, twitter_notify_ondownload=None,
|
||||||
twitter_notify_onsubtitledownload=None,
|
twitter_notify_onsubtitledownload=None,
|
||||||
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, boxcar2_sound=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_apikey=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,
|
||||||
|
@ -2421,6 +2421,7 @@ class ConfigNotifications(MainHandler):
|
||||||
sickbeard.BOXCAR2_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(boxcar2_notify_ondownload)
|
sickbeard.BOXCAR2_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(boxcar2_notify_ondownload)
|
||||||
sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(boxcar2_notify_onsubtitledownload)
|
sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(boxcar2_notify_onsubtitledownload)
|
||||||
sickbeard.BOXCAR2_ACCESSTOKEN = boxcar2_accesstoken
|
sickbeard.BOXCAR2_ACCESSTOKEN = boxcar2_accesstoken
|
||||||
|
sickbeard.BOXCAR2_SOUND = boxcar2_sound
|
||||||
|
|
||||||
sickbeard.USE_PUSHOVER = config.checkbox_to_value(use_pushover)
|
sickbeard.USE_PUSHOVER = config.checkbox_to_value(use_pushover)
|
||||||
sickbeard.PUSHOVER_NOTIFY_ONSNATCH = config.checkbox_to_value(pushover_notify_onsnatch)
|
sickbeard.PUSHOVER_NOTIFY_ONSNATCH = config.checkbox_to_value(pushover_notify_onsnatch)
|
||||||
|
@ -3349,10 +3350,10 @@ class Home(MainHandler):
|
||||||
return "Test prowl notice failed"
|
return "Test prowl notice failed"
|
||||||
|
|
||||||
|
|
||||||
def testBoxcar2(self, accesstoken=None):
|
def testBoxcar2(self, accesstoken=None, sound=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.boxcar2_notifier.test_notify(accesstoken)
|
result = notifiers.boxcar2_notifier.test_notify(accesstoken, sound)
|
||||||
if result:
|
if result:
|
||||||
return "Boxcar2 notification succeeded. Check your Boxcar2 clients to make sure it worked"
|
return "Boxcar2 notification succeeded. Check your Boxcar2 clients to make sure it worked"
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue