Simplify notification providers
This commit is contained in:
1 parent
b82319cb54
commit
7c234ab7e9
15 files changed
+7
-18
No files matched your search
@@ -22,7 +22,7 @@ class Notification(Provider):
|
|||||||
dont_listen_to = []
|
dont_listen_to = []
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('notify.%s' % self.getName().lower(), self.notify)
|
addEvent('notify.%s' % self.getName().lower(), self._notify)
|
||||||
|
|
||||||
addApiView(self.testNotifyName(), self.test)
|
addApiView(self.testNotifyName(), self.test)
|
||||||
|
|
||||||
@@ -35,13 +35,17 @@ class Notification(Provider):
|
|||||||
def notify(message = None, group = {}, data = None):
|
def notify(message = None, group = {}, data = None):
|
||||||
if not self.conf('on_snatch', default = True) and listener == 'movie.snatched':
|
if not self.conf('on_snatch', default = True) and listener == 'movie.snatched':
|
||||||
return
|
return
|
||||||
return self.notify(message = message, data = data if data else group, listener = listener)
|
return self._notify(message = message, data = data if data else group, listener = listener)
|
||||||
|
|
||||||
return notify
|
return notify
|
||||||
|
|
||||||
def getNotificationImage(self, size = 'small'):
|
def getNotificationImage(self, size = 'small'):
|
||||||
return 'https://raw.github.com/RuudBurger/CouchPotatoServer/master/couchpotato/static/images/notify.couch.%s.png' % size
|
return 'https://raw.github.com/RuudBurger/CouchPotatoServer/master/couchpotato/static/images/notify.couch.%s.png' % size
|
||||||
|
|
||||||
|
def _notify(self, *args, **kwargs):
|
||||||
|
if self.isEnabled():
|
||||||
|
self.notify(*args, **kwargs)
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -51,7 +55,7 @@ class Notification(Provider):
|
|||||||
|
|
||||||
log.info('Sending test to %s', test_type)
|
log.info('Sending test to %s', test_type)
|
||||||
|
|
||||||
success = self.notify(
|
success = self._notify(
|
||||||
message = self.test_message,
|
message = self.test_message,
|
||||||
data = {},
|
data = {},
|
||||||
listener = 'test'
|
listener = 'test'
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ class Boxcar(Notification):
|
|||||||
url = 'https://boxcar.io/devices/providers/7MNNXY3UIzVBwvzkKwkC/notifications'
|
url = 'https://boxcar.io/devices/providers/7MNNXY3UIzVBwvzkKwkC/notifications'
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = message.strip()
|
message = message.strip()
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ log = CPLog(__name__)
|
|||||||
class Email(Notification):
|
class Email(Notification):
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
# Extract all the settings from settings
|
# Extract all the settings from settings
|
||||||
from_address = self.conf('from')
|
from_address = self.conf('from')
|
||||||
@@ -50,6 +49,5 @@ class Email(Notification):
|
|||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error('E-mail failed: %s', traceback.format_exc())
|
log.error('E-mail failed: %s', traceback.format_exc())
|
||||||
return False
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@@ -44,7 +44,6 @@ class Growl(Notification):
|
|||||||
log.error('Failed register of growl: %s', traceback.format_exc())
|
log.error('Failed register of growl: %s', traceback.format_exc())
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
self.register()
|
self.register()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class Notifo(Notification):
|
|||||||
url = 'https://api.notifo.com/v1/send_notification'
|
url = 'https://api.notifo.com/v1/send_notification'
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ log = CPLog(__name__)
|
|||||||
class NotifyMyAndroid(Notification):
|
class NotifyMyAndroid(Notification):
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
nma = pynma.PyNMA()
|
nma = pynma.PyNMA()
|
||||||
keys = splitString(self.conf('api_key'))
|
keys = splitString(self.conf('api_key'))
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ log = CPLog(__name__)
|
|||||||
class NotifyMyWP(Notification):
|
class NotifyMyWP(Notification):
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
keys = splitString(self.conf('api_key'))
|
keys = splitString(self.conf('api_key'))
|
||||||
p = PyNMWP(keys, self.conf('dev_key'))
|
p = PyNMWP(keys, self.conf('dev_key'))
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ class Plex(Notification):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
hosts = [x.strip() + ':3000' for x in self.conf('host').split(",")]
|
hosts = [x.strip() + ':3000' for x in self.conf('host').split(",")]
|
||||||
successful = 0
|
successful = 0
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class Prowl(Notification):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'apikey': self.conf('api_key'),
|
'apikey': self.conf('api_key'),
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class Pushalot(Notification):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'AuthorizationToken': self.conf('auth_token'),
|
'AuthorizationToken': self.conf('auth_token'),
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ class Pushover(Notification):
|
|||||||
app_token = 'YkxHMYDZp285L265L3IwH3LmzkTaCy'
|
app_token = 'YkxHMYDZp285L265L3IwH3LmzkTaCy'
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
http_handler = HTTPSConnection("api.pushover.net:443")
|
http_handler = HTTPSConnection("api.pushover.net:443")
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class Toasty(Notification):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'title': self.default_title,
|
'title': self.default_title,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class Trakt(Notification):
|
|||||||
listen_to = ['movie.downloaded']
|
listen_to = ['movie.downloaded']
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
post_data = {
|
post_data = {
|
||||||
'username': self.conf('automation_username'),
|
'username': self.conf('automation_username'),
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class Twitter(Notification):
|
|||||||
addApiView('notify.%s.credentials' % self.getName().lower(), self.getCredentials)
|
addApiView('notify.%s.credentials' % self.getName().lower(), self.getCredentials)
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
api = Api(self.consumer_key, self.consumer_secret, self.conf('access_token_key'), self.conf('access_token_secret'))
|
api = Api(self.consumer_key, self.consumer_secret, self.conf('access_token_key'), self.conf('access_token_secret'))
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class XBMC(Notification):
|
|||||||
use_json_notifications = {}
|
use_json_notifications = {}
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
|
||||||
|
|
||||||
hosts = splitString(self.conf('host'))
|
hosts = splitString(self.conf('host'))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user