Added Windows Phone SuperToasty Notifier

This commit is contained in:
Travis La Marr
2013-01-01 17:34:53 -05:00
committed by Ruud
parent a3a2c8da8e
commit c2453bb070
2 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
from .main import Toasty
def start():
return Toasty()
config = [{
'name': 'toasty',
'groups': [
{
'tab': 'notifications',
'name': 'toasty',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'api_key',
'label': 'Device ID',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

View File

@@ -0,0 +1,30 @@
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from httplib import HTTPConnection
from urllib import urlencode
import traceback
log = CPLog(__name__)
class Toasty(Notification):
def notify(self, message = '', data = {}, listener = None):
if self.isDisabled(): return
data = {
'title': self.default_title,
'text': toUnicode(message),
'sender': toUnicode("CouchPotato"),
'image': 'https://raw.github.com/RuudBurger/CouchPotatoServer/master/couchpotato/static/images/homescreen.png',
}
try:
http_handler = HTTPConnection("api.supertoasty.com")
http_handler.request("GET", "/notify/"+self.conf('api_key')+"?"+urlencode(data))
log.info('Toasty notifications sent.')
return True
except:
log.error('Toasty failed: %s', traceback.format_exc())
return False