NotifyMyAndroid support
This commit is contained in:
1 parent
c4105aba97
commit
1d61433fb1
4 files changed
+203
No files matched your search
@@ -0,0 +1,36 @@
|
||||
from .main import NotifyMyAndroid
|
||||
|
||||
def start():
|
||||
return NotifyMyAndroid()
|
||||
|
||||
config = [{
|
||||
'name': 'notifymyandroid',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'notifications',
|
||||
'name': 'notifymyandroid',
|
||||
'label': 'Notify My Android',
|
||||
'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)],
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
}]
|
||||
@@ -0,0 +1,26 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
from libs import pynma
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class NotifyMyAndroid(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
|
||||
nma = pynma.PyNMA()
|
||||
keys = self.conf('api_key').split(',')
|
||||
nma.addkey(keys)
|
||||
nma.developerkey(self.conf('dev_key'))
|
||||
|
||||
response = nma.push(self.app_name, 'CouchPotato', message, priority = self.priority, batch_mode = len(keys) > 1)
|
||||
|
||||
for key in keys:
|
||||
if not response[str(key)]['code'] == u'200':
|
||||
log.error('Could not send notification to NotifyMyAndroid (%s). %s' % (key, response[key]['message']))
|
||||
|
||||
return response
|
||||
Reference in new issue
Block a user