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.
35 lines
996 B
35 lines
996 B
from couchpotato.core.helpers.encoding import toUnicode
|
|
from couchpotato.core.logger import CPLog
|
|
from couchpotato.core.notifications.base import Notification
|
|
import traceback
|
|
|
|
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
|
|
|