Added "on snatch" option to some notification. fix #55
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.helpers.request import jsonified
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
@@ -23,7 +23,14 @@ class Notification(Plugin):
|
||||
# Attach listeners
|
||||
for listener in self.listen_to:
|
||||
if not listener in self.dont_listen_to:
|
||||
addEvent(listener, self.notify)
|
||||
|
||||
# Add on snatch default
|
||||
def notify(message, data):
|
||||
if not self.conf('on_snatch', default = 1) and listener == 'movie.snatched':
|
||||
return
|
||||
return self.notify(message, data)
|
||||
|
||||
addEvent(listener, notify)
|
||||
|
||||
def notify(self, message = '', data = {}):
|
||||
pass
|
||||
|
||||
@@ -23,6 +23,13 @@ config = [{
|
||||
'name': 'password',
|
||||
'type': 'password',
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
@@ -2,7 +2,6 @@ from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
from couchpotato.core.notifications.growl.growl import GROWL_UDP_PORT, \
|
||||
GrowlRegistrationPacket, GrowlNotificationPacket
|
||||
from couchpotato.environment import Env
|
||||
from socket import AF_INET, SOCK_DGRAM, socket
|
||||
|
||||
log = CPLog(__name__)
|
||||
@@ -10,10 +9,7 @@ log = CPLog(__name__)
|
||||
|
||||
class Growl(Notification):
|
||||
|
||||
def conf(self, attr):
|
||||
return Env.setting(attr, 'growl')
|
||||
|
||||
def notify(self, message = '', data = {}):
|
||||
def notify(self, type = '', message = '', data = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
hosts = [x.strip() for x in self.conf('host').split(",")]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.helpers.request import getParams, jsonified
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
@@ -18,13 +19,10 @@ log = CPLog(__name__)
|
||||
class NMJ(Notification):
|
||||
|
||||
def __init__(self):
|
||||
super(NMJ, self).__init__()
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
addApiView('notify.nmj.auto_config', self.autoConfig)
|
||||
|
||||
def conf(self, attr):
|
||||
return Env.setting(attr, 'nmj')
|
||||
|
||||
def autoConfig(self):
|
||||
|
||||
params = getParams()
|
||||
@@ -72,7 +70,7 @@ class NMJ(Notification):
|
||||
'mount': mount,
|
||||
})
|
||||
|
||||
def notify(self, message = '', data = {}):
|
||||
def addToLibrary(self, group = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
host = self.conf('host')
|
||||
|
||||
@@ -22,6 +22,13 @@ config = [{
|
||||
{
|
||||
'name': 'api_key',
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
from couchpotato.environment import Env
|
||||
from flask.helpers import json
|
||||
import base64
|
||||
|
||||
|
||||
@@ -30,6 +30,13 @@ config = [{
|
||||
'type': 'dropdown',
|
||||
'values': [('Very Low', -2), ('Moderate', -1), ('Normal', 0), ('High', 1), ('Emergency', 2)],
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.helpers.variable import cleanHost
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
@@ -9,7 +10,10 @@ log = CPLog(__name__)
|
||||
|
||||
class Plex(Notification):
|
||||
|
||||
def notify(self, message = '', data = {}):
|
||||
def __init__(self):
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
def addToLibrary(self, group = {}):
|
||||
if self.isDisabled(): return
|
||||
|
||||
log.info('Sending notification to Plex')
|
||||
|
||||
@@ -25,6 +25,13 @@ config = [{
|
||||
'type': 'dropdown',
|
||||
'values': [('Very Low', -2), ('Moderate', -1), ('Normal', 0), ('High', 1), ('Emergency', 2)]
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
@@ -31,6 +31,13 @@ config = [{
|
||||
'name': 'mention',
|
||||
'description': 'Add a mention to this user to the tweet.',
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user