Simpler notifications
This commit is contained in:
@@ -12,15 +12,19 @@ class Notification(Plugin):
|
||||
default_title = 'CouchPotato'
|
||||
test_message = 'ZOMG Lazors Pewpewpew!'
|
||||
|
||||
listen_to = []
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
dont_listen_to = []
|
||||
|
||||
def __init__(self):
|
||||
addEvent('notify', self.notify)
|
||||
addEvent('notify.%s' % self.getName().lower(), self.notify)
|
||||
|
||||
addApiView(self.testNotifyName(), self.test)
|
||||
|
||||
# Attach listeners
|
||||
for listener in self.listen_to:
|
||||
if not listener in self.dont_listen_to:
|
||||
addEvent(listener, self.notify)
|
||||
|
||||
def notify(self, message = '', data = {}, type = ''):
|
||||
pass
|
||||
|
||||
@@ -36,12 +40,7 @@ class Notification(Plugin):
|
||||
type = test_type
|
||||
)
|
||||
|
||||
#return jsonified({'success': success})
|
||||
|
||||
def dontNotify(self, type = ''):
|
||||
return (not type in self.listen_to and len(self.listen_to) == 0 and type != self.testNotifyName()) \
|
||||
or type in self.dont_listen_to \
|
||||
or self.isDisabled()
|
||||
return jsonified({'success': success})
|
||||
|
||||
def testNotifyName(self):
|
||||
return 'notify.%s.test' % self.getName().lower()
|
||||
|
||||
@@ -27,7 +27,7 @@ class CoreNotifier(Notification):
|
||||
# Library update, frontend refresh
|
||||
addEvent('library.update_finish', lambda data: fireEvent('notify.frontend', type = 'library.update', data = data))
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
def notify(self, message = '', data = {}):
|
||||
self.add(data = {
|
||||
'message': message,
|
||||
'raw': data,
|
||||
|
||||
@@ -12,13 +12,10 @@ log = CPLog(__name__)
|
||||
|
||||
class Growl(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def conf(self, attr):
|
||||
return Env.setting(attr, 'growl')
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
hosts = [x.strip() for x in self.conf('host').split(",")]
|
||||
password = self.conf('password')
|
||||
|
||||
@@ -10,7 +10,7 @@ log = CPLog(__name__)
|
||||
|
||||
class History(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched', 'movie.renaming.']
|
||||
listen_to = ['movie.downloaded', 'movie.snatched', 'renamer.canceled']
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -19,8 +19,7 @@ class History(Notification):
|
||||
addEvent('app.load', self.test)
|
||||
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
db = get_session()
|
||||
history = Hist(
|
||||
|
||||
@@ -18,8 +18,6 @@ log = CPLog(__name__)
|
||||
|
||||
class NMJ(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def __init__(self):
|
||||
super(NMJ, self).__init__()
|
||||
|
||||
@@ -75,8 +73,7 @@ class NMJ(Notification):
|
||||
'mount': mount,
|
||||
})
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
host = self.conf('host')
|
||||
mount = self.conf('mount')
|
||||
|
||||
@@ -16,13 +16,10 @@ class Notifo(Notification):
|
||||
|
||||
url = 'https://api.notifo.com/v1/send_notification'
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def conf(self, attr):
|
||||
return Env.setting(attr, 'notifo')
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
try:
|
||||
data = urllib.urlencode({
|
||||
|
||||
@@ -7,10 +7,7 @@ log = CPLog(__name__)
|
||||
|
||||
class NotifyMyAndroid(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
nma = pynma.PyNMA()
|
||||
keys = self.conf('api_key').split(',')
|
||||
|
||||
@@ -10,10 +10,7 @@ log = CPLog(__name__)
|
||||
|
||||
class Plex(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
log.info('Sending notification to Plex')
|
||||
hosts = [x.strip() for x in self.conf('host').split(",")]
|
||||
|
||||
@@ -9,10 +9,7 @@ log = CPLog(__name__)
|
||||
|
||||
class Prowl(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
http_handler = HTTPSConnection('api.prowlapp.com')
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ log = CPLog(__name__)
|
||||
|
||||
class Twitter(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
consumer_key = "3POVsO3KW90LKZXyzPOjQ"
|
||||
consumer_secret = "Qprb94hx9ucXvD4Wvg2Ctsk4PDK7CcQAKgCELXoyIjE"
|
||||
|
||||
@@ -21,8 +19,7 @@ class Twitter(Notification):
|
||||
'authorize': 'https://api.twitter.com/oauth/authorize',
|
||||
}
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
api = Api(self.consumer_key, self.consumer_secret, self.conf('username'), self.conf('password'))
|
||||
|
||||
|
||||
@@ -9,10 +9,7 @@ log = CPLog(__name__)
|
||||
|
||||
class XBMC(Notification):
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched']
|
||||
|
||||
def notify(self, message = '', data = {}, type = None):
|
||||
if self.dontNotify(type): return
|
||||
def notify(self, message = '', data = {}):
|
||||
|
||||
for host in [x.strip() for x in self.conf('host').split(",")]:
|
||||
self.send({'command': 'ExecBuiltIn', 'parameter': 'Notification(CouchPotato, %s)' % message}, host)
|
||||
|
||||
Reference in New Issue
Block a user