Notify my Windows Phone support

Thanks to https://github.com/yngvebn
This commit is contained in:
Ruud
2012-03-06 16:15:47 +01:00
parent aa0f7bfb36
commit d2fd098030
3 changed files with 201 additions and 0 deletions
@@ -0,0 +1,43 @@
from .main import NotifyMyWP
def start():
return NotifyMyWP()
config = [{
'name': 'notifymywp',
'groups': [
{
'tab': 'notifications',
'name': 'notifymywp',
'label': 'Notify My Windows Phone',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'api_key',
'description': 'Multiple keys seperated by a comma. Maximum of 5.'
},
{
'name': 'dev_key',
'advanced': True,
},
{
'name': 'priority',
'default': 0,
'type': 'dropdown',
'values': [('Very Low', -2), ('Moderate', -1), ('Normal', 0), ('High', 1), ('Emergency', 2)],
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]
@@ -0,0 +1,24 @@
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from pynmwp import PyNMWP
log = CPLog(__name__)
class NotifyMyWP(Notification):
def notify(self, message = '', data = {}):
if self.isDisabled():
return
keys = self.conf('api_key').split(',')
p = PyNMWP(keys, self.conf('dev_key'))
response = p.push(application = self.default_title, event = message, description = message, priority = self.conf('priority'), batch_mode = len(keys) > 1)
for key in keys:
if not response[key]['Code'] == u'200':
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s' % (key, response[key]['message']))
return response