diff --git a/couchpotato/core/notifications/base.py b/couchpotato/core/notifications/base.py index 8feea71..b1a5139 100644 --- a/couchpotato/core/notifications/base.py +++ b/couchpotato/core/notifications/base.py @@ -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 diff --git a/couchpotato/core/notifications/growl/__init__.py b/couchpotato/core/notifications/growl/__init__.py index 87e8af2..586e2d4 100644 --- a/couchpotato/core/notifications/growl/__init__.py +++ b/couchpotato/core/notifications/growl/__init__.py @@ -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.', + }, ], } ], diff --git a/couchpotato/core/notifications/growl/main.py b/couchpotato/core/notifications/growl/main.py index 7adce31..2ed632c 100644 --- a/couchpotato/core/notifications/growl/main.py +++ b/couchpotato/core/notifications/growl/main.py @@ -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(",")] diff --git a/couchpotato/core/notifications/nmj/main.py b/couchpotato/core/notifications/nmj/main.py index 27dc06f..934dc39 100644 --- a/couchpotato/core/notifications/nmj/main.py +++ b/couchpotato/core/notifications/nmj/main.py @@ -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') diff --git a/couchpotato/core/notifications/notifo/__init__.py b/couchpotato/core/notifications/notifo/__init__.py index ef9a46e..5bf035c 100644 --- a/couchpotato/core/notifications/notifo/__init__.py +++ b/couchpotato/core/notifications/notifo/__init__.py @@ -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.', + }, ], } ], diff --git a/couchpotato/core/notifications/notifo/main.py b/couchpotato/core/notifications/notifo/main.py index c66044e..f5c49c5 100644 --- a/couchpotato/core/notifications/notifo/main.py +++ b/couchpotato/core/notifications/notifo/main.py @@ -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 diff --git a/couchpotato/core/notifications/notifymyandroid/__init__.py b/couchpotato/core/notifications/notifymyandroid/__init__.py index 12d6631..58f8e62 100644 --- a/couchpotato/core/notifications/notifymyandroid/__init__.py +++ b/couchpotato/core/notifications/notifymyandroid/__init__.py @@ -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.', + }, ], } ], diff --git a/couchpotato/core/notifications/plex/main.py b/couchpotato/core/notifications/plex/main.py index ad84231..72fdef1 100644 --- a/couchpotato/core/notifications/plex/main.py +++ b/couchpotato/core/notifications/plex/main.py @@ -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') diff --git a/couchpotato/core/notifications/prowl/__init__.py b/couchpotato/core/notifications/prowl/__init__.py index 62de55a..5884f74 100644 --- a/couchpotato/core/notifications/prowl/__init__.py +++ b/couchpotato/core/notifications/prowl/__init__.py @@ -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.', + }, ], } ], diff --git a/couchpotato/core/notifications/twitter/__init__.py b/couchpotato/core/notifications/twitter/__init__.py index 00569e6..266a287 100644 --- a/couchpotato/core/notifications/twitter/__init__.py +++ b/couchpotato/core/notifications/twitter/__init__.py @@ -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.', + }, ], } ],