Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/images/notifiers/pushalot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions data/interfaces/default/config_notifications.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,56 @@
</fieldset>
</div><!-- /nma component-group //-->


<div class="component-group clearfix">
<div class="component-group-desc">
<img class="notifier-icon" src="$sbRoot/images/notifiers/pushalot.png" alt="" title="Pushalot" />
<h3><a href="https://pushalot.com" onclick="window.open(this.href, '_blank'); return false;">Pushalot</a></h3>
<p>Pushalot is a platform for receiving custom push notifications to connected devices running Windows Phone or Windows 8.</p>
</div>
<fieldset class="component-group-list">
<div class="field-pair">
<input type="checkbox" class="enabler" name="use_pushalot" id="use_pushalot" #if $sickbeard.USE_PUSHALOT then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_pushalot">
<span class="component-title">Enable</span>
<span class="component-desc">Should Sick Beard send notifications through Pushalot?</span>
</label>
</div>

<div id="content_use_pushalot">
<div class="field-pair">
<input type="checkbox" name="pushalot_notify_onsnatch" id="pushalot_notify_onsnatch" #if $sickbeard.PUSHALOT_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
<label class="clearfix" for="pushalot_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="pushalot_notify_ondownload" id="pushalot_notify_ondownload" #if $sickbeard.PUSHALOT_NOTIFY_ONDOWNLOAD then "checked=\"checked\"" else ""# />
<label class="clearfix" for="pushalot_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">Pushalot Authorization Token</span>
<input type="text" name="pushalot_authorizationtoken" id="pushalot_authorizationtoken" value="$sickbeard.PUSHALOT_AUTHORIZATIONTOKEN" size="35" />
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Authorization Token of your Pushalot account</span>
</label>
</div>
<div class="testNotification" id="testPushalot-result">Click below to test.</div>
<input type="button" class="btn" value="Test Pushalot" id="testPushalot" />
<input type="submit" class="btn config_submitter" value="Save Changes" />
</div><!-- /content_use_pushalot //-->

</fieldset>
</div><!-- /pushalot component-group //-->


<div class="component-group-save">
<input type="submit" class="btn config_submitter" value="Save Changes" />
</div><br />
Expand Down
7 changes: 7 additions & 0 deletions data/js/configNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,11 @@ $(document).ready(function () {
$.get(sbRoot + "/home/testNMA", {'nma_api': nma_api, 'nma_priority': nma_priority},
function (data) { $('#testNMA-result').html(data); });
});

$('#testPushalot').click(function () {
$('#testPushalot-result').html(loading);
var pushalot_authorizationtoken = $("pushalot_authorizationtoken").val();
$.get(sbRoot + "/home/testPushalot", {'authorizationToken': pushalot_authorizationtoken},
function (data) { $('#testPushalot-result').html(data); });
});
});
17 changes: 17 additions & 0 deletions sickbeard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@
NMA_NOTIFY_ONDOWNLOAD = False
NMA_API = None
NMA_PRIORITY = 0

USE_PUSHALOT = False
PUSHALOT_NOTIFY_ONSNATCH = False
PUSHALOT_NOTIFY_ONDOWNLOAD = False
PUSHALOT_AUTHORIZATIONTOKEN = None

COMING_EPS_LAYOUT = None
COMING_EPS_DISPLAY_PAUSED = None
Expand Down Expand Up @@ -733,6 +738,12 @@ def initialize(consoleLogging=True):
NMA_API = check_setting_str(CFG, 'NMA', 'nma_api', '')
NMA_PRIORITY = check_setting_str(CFG, 'NMA', 'nma_priority', "0")

CheckSection(CFG, 'Pushalot')
USE_PUSHALOT = bool(check_setting_int(CFG, 'Pushalot', 'use_pushalot', 0))
PUSHALOT_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Pushalot', 'pushalot_notify_onsnatch', 0))
PUSHALOT_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Pushalot', 'pushalot_notify_ondownload', 0))
PUSHALOT_AUTHORIZATIONTOKEN = check_setting_str(CFG, 'Pushalot', 'pushalot_authorizationtoken', '')

# start up all the threads
logger.sb_log_instance.initLogging(consoleLogging=consoleLogging)

Expand Down Expand Up @@ -1234,6 +1245,12 @@ def save_config():
new_config['NMA']['nma_api'] = NMA_API
new_config['NMA']['nma_priority'] = NMA_PRIORITY

new_config['Pushalot'] = {}
new_config['Pushalot']['use_pushalot'] = int(USE_PUSHALOT)
new_config['Pushalot']['pushalot_notify_onsnatch'] = int(PUSHALOT_NOTIFY_ONSNATCH)
new_config['Pushalot']['pushalot_notify_ondownload'] = int(PUSHALOT_NOTIFY_ONDOWNLOAD)
new_config['Pushalot']['pushalot_authorizationtoken'] = PUSHALOT_AUTHORIZATIONTOKEN

new_config['Newznab'] = {}
new_config['Newznab']['newznab_data'] = '!!!'.join([x.configStr() for x in newznabProviderList])

Expand Down
4 changes: 2 additions & 2 deletions sickbeard/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def nameQuality(name):
return Quality.RAWHDTV
elif checkName(["1080p", "hdtv", "(h|x)264"], all) or checkName(["videomann", "1080p"], all):
return Quality.FULLHDTV
elif checkName(["720p", "web.?dl|webrip|webhd(rip)?"], all) or checkName(["720p", "(webhd|itunes)", "(h|x).?264"], all) or checkName(["720p", "(webhd|itunes)", "avc"], all):
elif checkName(["720p", "web.?dl|webrip|webhd(rip)?|netflixhd|amazonhd"], all) or checkName(["720p", "(webhd|itunes)", "(h|x).?264"], all) or checkName(["720p", "(webhd|itunes)", "avc"], all):
return Quality.HDWEBDL
elif checkName(["1080p", "web.?dl|webrip|webhd(rip)?"], all) or checkName(["1080p", "(webhd|itunes)", "(h|x).?264"], all):
elif checkName(["1080p", "web.?dl|webrip|webhd(rip)?|netflixhd|amazonhd"], all) or checkName(["1080p", "(webhd|itunes)", "(h|x).?264"], all):
return Quality.FULLHDWEBDL
elif checkName(["720p", "bluray|hddvd|bd", "(h|x)264"], all):
return Quality.HDBLURAY
Expand Down
3 changes: 3 additions & 0 deletions sickbeard/notifiers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import pushover
import boxcar
import nma
import pushalot

import tweet
import trakt
Expand All @@ -53,6 +54,7 @@
pushover_notifier = pushover.PushoverNotifier()
boxcar_notifier = boxcar.BoxcarNotifier()
nma_notifier = nma.NMA_Notifier()
pushalot_notifier = pushalot.PushalotNotifier()
# online
twitter_notifier = tweet.TwitterNotifier()
trakt_notifier = trakt.TraktNotifier()
Expand All @@ -71,6 +73,7 @@
pushover_notifier,
boxcar_notifier,
nma_notifier,
pushalot_notifier,
twitter_notifier,
trakt_notifier,
]
Expand Down
87 changes: 87 additions & 0 deletions sickbeard/notifiers/pushalot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Author: Maciej Olesinski (https://github.com/molesinski/)
# Based on prowl.py by Nic Wolfe <nic@wolfeden.ca>
# 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/>.

from httplib import HTTPSConnection, HTTPException
from urllib import urlencode

try:
# this only exists in 2.6
from ssl import SSLError
except ImportError:
# make a fake one since I don't know what it is supposed to be in 2.5
class SSLError(Exception):
pass

import sickbeard

from sickbeard import logger, common

class PushalotNotifier:

def test_notify(self, pushalot_authorizationtoken):
return self._sendPushalot(pushalot_authorizationtoken, event="Test", message="Testing Pushalot settings from Sick Beard", force=True)

def notify_snatch(self, ep_name):
if sickbeard.PUSHALOT_NOTIFY_ONSNATCH:
self._sendPushalot(pushalot_authorizationtoken=None, event=common.notifyStrings[common.NOTIFY_SNATCH], message=ep_name)

def notify_download(self, ep_name):
if sickbeard.PUSHALOT_NOTIFY_ONDOWNLOAD:
self._sendPushalot(pushalot_authorizationtoken=None, event=common.notifyStrings[common.NOTIFY_DOWNLOAD], message=ep_name)

def _sendPushalot(self, pushalot_authorizationtoken=None, event=None, message=None, force=False):

if not sickbeard.USE_PUSHALOT and not force:
return False

if pushalot_authorizationtoken == None:
pushalot_authorizationtoken = sickbeard.PUSHALOT_AUTHORIZATIONTOKEN

logger.log(u"Pushalot event: " + event, logger.DEBUG)
logger.log(u"Pushalot message: " + message, logger.DEBUG)
logger.log(u"Pushalot api: " + pushalot_authorizationtoken, logger.DEBUG)

http_handler = HTTPSConnection("pushalot.com")

data = {'AuthorizationToken': pushalot_authorizationtoken,
'Title': event.encode('utf-8'),
'Body': message.encode('utf-8') }

try:
http_handler.request("POST",
"/api/sendmessage",
headers = {'Content-type': "application/x-www-form-urlencoded"},
body = urlencode(data))
except (SSLError, HTTPException):
logger.log(u"Pushalot notification failed.", logger.ERROR)
return False
response = http_handler.getresponse()
request_status = response.status

if request_status == 200:
logger.log(u"Pushalot notifications sent.", logger.DEBUG)
return True
elif request_status == 410:
logger.log(u"Pushalot auth failed: %s" % response.reason, logger.ERROR)
return False
else:
logger.log(u"Pushalot notification failed.", logger.ERROR)
return False

notifier = PushalotNotifier
33 changes: 32 additions & 1 deletion sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,8 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
use_trakt=None, trakt_username=None, trakt_password=None, trakt_api=None,
use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None, pytivo_update_library=None,
pytivo_host=None, pytivo_share_name=None, pytivo_tivo_name=None,
use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_api=None, nma_priority=0 ):
use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_api=None, nma_priority=0,
use_pushalot=None, pushalot_notify_onsnatch=None, pushalot_notify_ondownload=None, pushalot_authorizationtoken=None ):

results = []

Expand Down Expand Up @@ -1414,6 +1415,21 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
else:
nma_notify_ondownload = 0

if use_pushalot == "on":
use_pushalot = 1
else:
use_pushalot = 0

if pushalot_notify_onsnatch == "on":
pushalot_notify_onsnatch = 1
else:
pushalot_notify_onsnatch = 0

if pushalot_notify_ondownload == "on":
pushalot_notify_ondownload = 1
else:
pushalot_notify_ondownload = 0

sickbeard.USE_XBMC = use_xbmc
sickbeard.XBMC_NOTIFY_ONSNATCH = xbmc_notify_onsnatch
sickbeard.XBMC_NOTIFY_ONDOWNLOAD = xbmc_notify_ondownload
Expand Down Expand Up @@ -1500,6 +1516,11 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
sickbeard.NMA_API = nma_api
sickbeard.NMA_PRIORITY = nma_priority

sickbeard.USE_PUSHALOT = use_pushalot
sickbeard.PUSHALOT_NOTIFY_ONSNATCH = pushalot_notify_onsnatch
sickbeard.PUSHALOT_NOTIFY_ONDOWNLOAD = pushalot_notify_ondownload
sickbeard.PUSHALOT_AUTHORIZATIONTOKEN = pushalot_authorizationtoken

sickbeard.save_config()

if len(results) > 0:
Expand Down Expand Up @@ -2243,6 +2264,16 @@ def testNMA(self, nma_api=None, nma_priority=0):
else:
return "Test NMA notice failed"

@cherrypy.expose
def testPushalot(self, authorizationToken=None):
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"

result = notifiers.pushalot_notifier.test_notify(authorizationToken)
if result:
return "Pushalot notification succeeded. Check your Pushalot clients to make sure it worked"
else:
return "Error sending Pushalot notification"

@cherrypy.expose
def shutdown(self, pid=None):

Expand Down