You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.0 KiB
72 lines
2.0 KiB
11 years ago
|
from couchpotato.core.helpers.encoding import toUnicode
|
||
|
from couchpotato.core.logger import CPLog
|
||
|
from couchpotato.core.notifications.base import Notification
|
||
|
import traceback
|
||
14 years ago
|
|
||
11 years ago
|
log = CPLog(__name__)
|
||
|
|
||
|
|
||
|
class Prowl(Notification):
|
||
|
|
||
|
urls = {
|
||
|
'api': 'https://api.prowlapp.com/publicapi/add'
|
||
|
}
|
||
|
|
||
|
def notify(self, message = '', data = None, listener = None):
|
||
|
if not data: data = {}
|
||
|
|
||
|
data = {
|
||
|
'apikey': self.conf('api_key'),
|
||
|
'application': self.default_title,
|
||
|
'description': toUnicode(message),
|
||
|
'priority': self.conf('priority'),
|
||
|
}
|
||
|
headers = {
|
||
|
'Content-type': 'application/x-www-form-urlencoded'
|
||
|
}
|
||
|
|
||
|
try:
|
||
|
self.urlopen(self.urls['api'], headers = headers, data = data, show_error = False)
|
||
|
log.info('Prowl notifications sent.')
|
||
|
return True
|
||
|
except:
|
||
|
log.error('Prowl failed: %s', traceback.format_exc())
|
||
|
|
||
|
return False
|
||
11 years ago
|
|
||
14 years ago
|
|
||
|
config = [{
|
||
|
'name': 'prowl',
|
||
|
'groups': [
|
||
|
{
|
||
|
'tab': 'notifications',
|
||
12 years ago
|
'list': 'notification_providers',
|
||
14 years ago
|
'name': 'prowl',
|
||
|
'options': [
|
||
|
{
|
||
|
'name': 'enabled',
|
||
14 years ago
|
'default': 0,
|
||
14 years ago
|
'type': 'enabler',
|
||
|
},
|
||
|
{
|
||
|
'name': 'api_key',
|
||
|
'label': 'Api key',
|
||
|
},
|
||
|
{
|
||
|
'name': 'priority',
|
||
|
'default': '0',
|
||
|
'type': 'dropdown',
|
||
|
'values': [('Very Low', -2), ('Moderate', -1), ('Normal', 0), ('High', 1), ('Emergency', 2)]
|
||
|
},
|
||
14 years ago
|
{
|
||
|
'name': 'on_snatch',
|
||
|
'default': 0,
|
||
|
'type': 'bool',
|
||
|
'advanced': True,
|
||
|
'description': 'Also send message when movie is snatched.',
|
||
|
},
|
||
14 years ago
|
],
|
||
|
}
|
||
|
],
|
||
|
}]
|