Browse Source

Added "on snatch" option to some notification. fix #55

pull/62/head
Ruud 14 years ago
parent
commit
221c413aac
  1. 11
      couchpotato/core/notifications/base.py
  2. 7
      couchpotato/core/notifications/growl/__init__.py
  3. 6
      couchpotato/core/notifications/growl/main.py
  4. 8
      couchpotato/core/notifications/nmj/main.py
  5. 7
      couchpotato/core/notifications/notifo/__init__.py
  6. 1
      couchpotato/core/notifications/notifo/main.py
  7. 7
      couchpotato/core/notifications/notifymyandroid/__init__.py
  8. 6
      couchpotato/core/notifications/plex/main.py
  9. 7
      couchpotato/core/notifications/prowl/__init__.py
  10. 7
      couchpotato/core/notifications/twitter/__init__.py

11
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

7
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.',
},
],
}
],

6
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(",")]

8
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')

7
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.',
},
],
}
],

1
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

7
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.',
},
],
}
],

6
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')

7
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.',
},
],
}
],

7
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.',
},
],
}
],

Loading…
Cancel
Save