Private GIT

Skip to content
Snippets Groups Projects
Commit f1a43702 authored by Jonathon Saine's avatar Jonathon Saine
Browse files

Merge branch 'master' of https://github.com/midgetspy/Sick-Beard into api

parents cd4f5d54 3c8df499
No related branches found
No related tags found
No related merge requests found
data/images/notifiers/boxcar.gif

646 B

......@@ -419,6 +419,7 @@
</fieldset>
</div><!-- /component-group //-->
<div id="core-component-group6" class="component-group clearfix">
<div class="component-group-desc">
......@@ -617,10 +618,69 @@
</fieldset>
</div><!-- /component-group //-->
<div id="core-component-group10" class="component-group clearfix">
<div class="component-group-desc">
<h3><a href="http://boxcar.io/" onclick="window.open(this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/boxcar.gif" alt="Boxcar" title="Boxcar" width="16" height="16" /> Boxcar</a></h3>
<p>Read your messages where and when you want them! A subscription will be send if needed.</p>
</div>
<fieldset class="component-group-list">
<div class="field-pair">
<input type="checkbox" class="enabler" name="use_boxcar" id="use_boxcar" #if $sickbeard.USE_BOXCAR then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_boxcar">
<span class="component-title">Enable</span>
<span class="component-desc">Should Sick Beard send notifications through Boxcar?</span>
</label>
</div>
<div id="content_use_boxcar">
<div class="field-pair">
<input type="checkbox" name="boxcar_notify_onsnatch" id="boxcar_notify_onsnatch" #if $sickbeard.BOXCAR_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
<label class="clearfix" for="boxcar_notify_onsnatch">
<span class="component-title">Notify on Snatch</span>
<span class="component-desc">Send notification when we start a download?</span>
</label>
</div>
<div class="field-pair">
<input type="checkbox" name="boxcar_notify_ondownload" id="boxcar_notify_ondownload" #if $sickbeard.BOXCAR_NOTIFY_ONDOWNLOAD then "checked=\"checked\"" else ""# />
<label class="clearfix" for="boxcar_notify_ondownload">
<span class="component-title">Notify on Download</span>
<span class="component-desc">Send notification when we finish a download?</span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">Boxcar Username</span>
<input type="text" name="boxcar_username" id="boxcar_username" value="$sickbeard.BOXCAR_USERNAME" size="35" />
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Username of your Boxcar account</span>
</label>
</div>
<div class="testNotification" id="testBoxcar-result">Click below to test.</div>
<input type="button" value="Test Boxcar" id="testBoxcar" />
<input type="submit" class="config_submitter" value="Save Changes" />
</div><!-- /content_use_boxcar //-->
</fieldset>
</div>
<br/><input type="submit" class="config_submitter" value="Save Changes" /><br/>
</div><!-- /config-components //-->
</form>
......
......@@ -126,11 +126,11 @@ table.tablesorter thead tr .headerSortDown { background-image: url("$sbRoot/imag
\$("#NAV$topmenu").addClass("current");
\$("a.confirm").bind("click",function(e) {
\$('#MainMenu.sf-menu').hideSuperfishUl();
e.preventDefault();
var target = \$( this ).attr('href');
if ( confirm("Are you sure you want to " + \$(this).text() + "?") )
location.href = target;
\$('#MainMenu.sf-menu').hideSuperfishUl();
return false;
});
......
......@@ -45,6 +45,13 @@ $(document).ready(function(){
function (data){ $('#testNotifo-result').html(data); });
});
$('#testBoxcar').click(function(){
$('#testBoxcar-result').html(loading);
var boxcar_username = $("#boxcar_username").val();
$.get(sbRoot+"/home/testBoxcar", {'username': boxcar_username},
function (data){ $('#testBoxcar-result').html(data); });
});
$('#testLibnotify').click(function(){
$('#testLibnotify-result').html(loading);
$.get(sbRoot+"/home/testLibnotify",
......
......@@ -232,6 +232,13 @@ NOTIFO_USERNAME = None
NOTIFO_APISECRET = None
NOTIFO_PREFIX = None
USE_BOXCAR = False
BOXCAR_NOTIFY_ONSNATCH = False
BOXCAR_NOTIFY_ONDOWNLOAD = False
BOXCAR_USERNAME = None
BOXCAR_PASSWORD = None
BOXCAR_PREFIX = None
USE_LIBNOTIFY = False
LIBNOTIFY_NOTIFY_ONSNATCH = False
LIBNOTIFY_NOTIFY_ONDOWNLOAD = False
......@@ -365,6 +372,7 @@ def initialize(consoleLogging=True):
NZBSRUS, NZBSRUS_UID, NZBSRUS_HASH, NAMING_QUALITY, providerList, newznabProviderList, \
NAMING_DATES, EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, \
USE_NOTIFO, NOTIFO_USERNAME, NOTIFO_APISECRET, NOTIFO_NOTIFY_ONDOWNLOAD, NOTIFO_NOTIFY_ONSNATCH, \
USE_BOXCAR, BOXCAR_USERNAME, BOXCAR_PASSWORD, BOXCAR_NOTIFY_ONDOWNLOAD, BOXCAR_NOTIFY_ONSNATCH, \
USE_LIBNOTIFY, LIBNOTIFY_NOTIFY_ONSNATCH, LIBNOTIFY_NOTIFY_ONDOWNLOAD, USE_NMJ, NMJ_HOST, NMJ_DATABASE, NMJ_MOUNT, USE_SYNOINDEX, \
USE_BANNER, USE_LISTVIEW, METADATA_XBMC, METADATA_MEDIABROWSER, METADATA_PS3, metadata_provider_dict, \
NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, \
......@@ -569,6 +577,11 @@ def initialize(consoleLogging=True):
NOTIFO_USERNAME = check_setting_str(CFG, 'Notifo', 'notifo_username', '')
NOTIFO_APISECRET = check_setting_str(CFG, 'Notifo', 'notifo_apisecret', '')
USE_BOXCAR = bool(check_setting_int(CFG, 'Boxcar', 'use_boxcar', 0))
BOXCAR_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Boxcar', 'boxcar_notify_onsnatch', 0))
BOXCAR_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Boxcar', 'boxcar_notify_ondownload', 0))
BOXCAR_USERNAME = check_setting_str(CFG, 'Boxcar', 'boxcar_username', '')
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_ONDOWNLOAD = bool(check_setting_int(CFG, 'Libnotify', 'libnotify_notify_ondownload', 0))
......@@ -1066,6 +1079,12 @@ def save_config():
new_config['Notifo']['notifo_username'] = NOTIFO_USERNAME
new_config['Notifo']['notifo_apisecret'] = NOTIFO_APISECRET
new_config['Boxcar'] = {}
new_config['Boxcar']['use_boxcar'] = int(USE_BOXCAR)
new_config['Boxcar']['boxcar_notify_onsnatch'] = int(BOXCAR_NOTIFY_ONSNATCH)
new_config['Boxcar']['boxcar_notify_ondownload'] = int(BOXCAR_NOTIFY_ONDOWNLOAD)
new_config['Boxcar']['boxcar_username'] = BOXCAR_USERNAME
new_config['Libnotify'] = {}
new_config['Libnotify']['use_libnotify'] = int(USE_LIBNOTIFY)
new_config['Libnotify']['libnotify_notify_onsnatch'] = int(LIBNOTIFY_NOTIFY_ONSNATCH)
......
......@@ -25,6 +25,7 @@ import prowl
import tweet
from . import libnotify
import notifo
import boxcar
import nmj
import synoindex
......@@ -36,6 +37,7 @@ growl_notifier = growl.GrowlNotifier()
prowl_notifier = prowl.ProwlNotifier()
twitter_notifier = tweet.TwitterNotifier()
notifo_notifier = notifo.NotifoNotifier()
boxcar_notifier = boxcar.BoxcarNotifier()
libnotify_notifier = libnotify.LibnotifyNotifier()
nmj_notifier = nmj.NMJNotifier()
synoindex_notifier = synoindex.synoIndexNotifier()
......@@ -51,6 +53,7 @@ notifiers = [
twitter_notifier,
nmj_notifier,
synoindex_notifier,
boxcar_notifier
]
def notify_download(ep_name):
......@@ -62,3 +65,4 @@ def notify_snatch(ep_name):
for n in notifiers:
n.notify_snatch(ep_name)
notifo_notifier.notify_snatch(ep_name)
# Author: Marvin Pinto <me@marvinp.ca>
# Author: Dennis Lutter <lad1337@gmail.com>
# URL: http://code.google.com/p/sickbeard/
#
# This file is part of Sick Beard.
#
# Sick Beard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sick Beard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import urllib, urllib2
import time
import sickbeard
from sickbeard import logger
from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD
from sickbeard.exceptions import ex
API_URL = "https://boxcar.io/devices/providers/fWc4sgSmpcN6JujtBmR6/notifications"
class BoxcarNotifier:
def test_notify(self, email, title="Test"):
return self._sendBoxcar("This is a test notification from SickBeard", title, email)
def _sendBoxcar(self, msg, title, email, subscribe=False):
msg = msg.strip()
curUrl = API_URL
data = urllib.urlencode({
'email': email,
'notification[from_screen_name]': title,
'notification[message]': msg.encode('utf-8'),
'notification[from_remote_service_id]': int(time.time())
})
if subscribe: # subscription notification
data = urllib.urlencode({'email': email})
curUrl = curUrl + "/subscribe"
req = urllib2.Request(curUrl)
try:
handle = urllib2.urlopen(req, data)
handle.close()
except urllib2.URLError, e:
logger.log("Boxcar notification failed. error code: " + str(e.code), logger.WARNING)
if e.code == 404: #HTTP status 404 if the provided email address isn't a Boxcar user.
logger.log("Username is wrong/not a boxcar email. Boxcar will send an email to it", logger.WARNING)
return False
elif e.code == 401: #For HTTP status code 401's, it is because you are passing in either an invalid token, or the user has not added your service.
if subscribe: #If the user has already added your service, we'll return an HTTP status code of 401.
logger.log("Already subscribed to service", logger.ERROR)
# i dont know if this is true or false ... its neither but i also dont know how we got here in the first place
return False
else: #HTTP status 401 if the user doesn't have the service added
subscribeNote = self._sendBoxcar(msg, title, email, True)
if subscribeNote:
logger.log("Subscription send", logger.DEBUG)
return True
else:
logger.log("Subscription could not be send", logger.ERROR)
return False
elif e.code == 400: #If you receive an HTTP status code of 400, it is because you failed to send the proper parameters
logger.log("Wrong data send to boxcar", logger.ERROR)
return False
else:# 200
logger.log("Boxcar notification successful.", logger.DEBUG)
return True
def notify_snatch(self, ep_name, title=notifyStrings[NOTIFY_SNATCH]):
if sickbeard.BOXCAR_NOTIFY_ONSNATCH:
self._notifyBoxcar(title, ep_name)
def notify_download(self, ep_name, title=notifyStrings[NOTIFY_DOWNLOAD]):
if sickbeard.BOXCAR_NOTIFY_ONDOWNLOAD:
self._notifyBoxcar(title, ep_name)
def _notifyBoxcar(self, title, message=None, username=None, force=False):
if not sickbeard.USE_BOXCAR and not force:
logger.log("Notification for Boxcar not enabled, skipping this notification", logger.DEBUG)
return False
if not username:
username = sickbeard.BOXCAR_USERNAME
logger.log("Sending notification for " + message, logger.DEBUG)
self._sendBoxcar(message, title, username)
return True
notifier = BoxcarNotifier
......@@ -1167,6 +1167,7 @@ class ConfigNotifications:
use_prowl=None, prowl_notify_onsnatch=None, prowl_notify_ondownload=None, prowl_api=None, prowl_priority=0,
use_twitter=None, twitter_notify_onsnatch=None, twitter_notify_ondownload=None,
use_notifo=None, notifo_notify_onsnatch=None, notifo_notify_ondownload=None, notifo_username=None, notifo_apisecret=None,
use_boxcar=None, boxcar_notify_onsnatch=None, boxcar_notify_ondownload=None, boxcar_username=None,
use_libnotify=None, libnotify_notify_onsnatch=None, libnotify_notify_ondownload=None,
use_nmj=None, nmj_host=None, nmj_database=None, nmj_mount=None, use_synoindex=None):
......@@ -1274,6 +1275,20 @@ class ConfigNotifications:
else:
use_notifo = 0
if boxcar_notify_onsnatch == "on":
boxcar_notify_onsnatch = 1
else:
boxcar_notify_onsnatch = 0
if boxcar_notify_ondownload == "on":
boxcar_notify_ondownload = 1
else:
boxcar_notify_ondownload = 0
if use_boxcar == "on":
use_boxcar = 1
else:
use_boxcar = 0
if use_nmj == "on":
use_nmj = 1
else:
......@@ -1324,6 +1339,11 @@ class ConfigNotifications:
sickbeard.NOTIFO_USERNAME = notifo_username
sickbeard.NOTIFO_APISECRET = notifo_apisecret
sickbeard.USE_BOXCAR = use_boxcar
sickbeard.BOXCAR_NOTIFY_ONSNATCH = boxcar_notify_onsnatch
sickbeard.BOXCAR_NOTIFY_ONDOWNLOAD = boxcar_notify_ondownload
sickbeard.BOXCAR_USERNAME = boxcar_username
sickbeard.USE_LIBNOTIFY = use_libnotify == "on"
sickbeard.LIBNOTIFY_NOTIFY_ONSNATCH = libnotify_notify_onsnatch == "on"
sickbeard.LIBNOTIFY_NOTIFY_ONDOWNLOAD = libnotify_notify_ondownload == "on"
......@@ -1886,6 +1906,16 @@ class Home:
else:
return "Error sending Notifo notification"
@cherrypy.expose
def testBoxcar(self, username=None):
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
result = notifiers.boxcar_notifier.test_notify(username)
if result:
return "Boxcar notification succeeded. Check your Boxcar clients to make sure it worked"
else:
return "Error sending Boxcar notification"
@cherrypy.expose
def twitterStep1(self):
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment