Browse Source

Move notifications to single file

pull/3111/head
Ruud 11 years ago
parent
commit
8492c9b214
  1. 30
      couchpotato/core/notifications/boxcar.py
  2. 34
      couchpotato/core/notifications/boxcar/__init__.py
  3. 32
      couchpotato/core/notifications/boxcar2.py
  4. 34
      couchpotato/core/notifications/boxcar2/__init__.py
  5. 4
      couchpotato/core/notifications/core/__init__.py
  6. 64
      couchpotato/core/notifications/email.py
  7. 68
      couchpotato/core/notifications/email/__init__.py
  8. 41
      couchpotato/core/notifications/growl.py
  9. 46
      couchpotato/core/notifications/growl/__init__.py
  10. 28
      couchpotato/core/notifications/nmj.py
  11. 34
      couchpotato/core/notifications/nmj/__init__.py
  12. 37
      couchpotato/core/notifications/notifymyandroid.py
  13. 35
      couchpotato/core/notifications/notifymyandroid/main.py
  14. 27
      couchpotato/core/notifications/notifymywp.py
  15. 25
      couchpotato/core/notifications/notifymywp/main.py
  16. 2
      couchpotato/core/notifications/plex/__init__.py
  17. 37
      couchpotato/core/notifications/prowl.py
  18. 35
      couchpotato/core/notifications/prowl/main.py
  19. 40
      couchpotato/core/notifications/pushalot.py
  20. 38
      couchpotato/core/notifications/pushalot/main.py
  21. 36
      couchpotato/core/notifications/pushbullet.py
  22. 40
      couchpotato/core/notifications/pushbullet/__init__.py
  23. 38
      couchpotato/core/notifications/pushover.py
  24. 40
      couchpotato/core/notifications/pushover/__init__.py
  25. 22
      couchpotato/core/notifications/synoindex.py
  26. 24
      couchpotato/core/notifications/synoindex/__init__.py
  27. 32
      couchpotato/core/notifications/toasty.py
  28. 34
      couchpotato/core/notifications/toasty/__init__.py
  29. 29
      couchpotato/core/notifications/trakt.py
  30. 31
      couchpotato/core/notifications/trakt/__init__.py
  31. 2
      couchpotato/core/notifications/twitter/__init__.py
  32. 65
      couchpotato/core/notifications/xbmc.py
  33. 68
      couchpotato/core/notifications/xbmc/__init__.py
  34. 47
      couchpotato/core/notifications/xmpp.py
  35. 43
      couchpotato/core/notifications/xmpp/main.py

30
couchpotato/core/notifications/boxcar/main.py → couchpotato/core/notifications/boxcar.py

@ -33,3 +33,33 @@ class Boxcar(Notification):
def isEnabled(self):
return super(Boxcar, self).isEnabled() and self.conf('email')
config = [{
'name': 'boxcar',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'boxcar',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'email',
'description': 'Your Boxcar registration emailaddress.'
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

34
couchpotato/core/notifications/boxcar/__init__.py

@ -1,34 +0,0 @@
from .main import Boxcar
def start():
return Boxcar()
config = [{
'name': 'boxcar',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'boxcar',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'email',
'description': 'Your Boxcar registration emailaddress.'
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

32
couchpotato/core/notifications/boxcar2/main.py → couchpotato/core/notifications/boxcar2.py

@ -4,6 +4,8 @@ from couchpotato.core.notifications.base import Notification
log = CPLog(__name__)
autoload = 'Boxcar2'
class Boxcar2(Notification):
@ -37,3 +39,33 @@ class Boxcar2(Notification):
def isEnabled(self):
return super(Boxcar2, self).isEnabled() and self.conf('token')
config = [{
'name': 'boxcar2',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'boxcar2',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'token',
'description': ('Your Boxcar access token.', 'Can be found in the app under settings')
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

34
couchpotato/core/notifications/boxcar2/__init__.py

@ -1,34 +0,0 @@
from .main import Boxcar2
def start():
return Boxcar2()
config = [{
'name': 'boxcar2',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'boxcar2',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'token',
'description': ('Your Boxcar access token.', 'Can be found in the app under settings')
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

4
couchpotato/core/notifications/core/__init__.py

@ -1,7 +1,5 @@
from .main import CoreNotifier
def start():
def autoload():
return CoreNotifier()
config = []

64
couchpotato/core/notifications/email/main.py → couchpotato/core/notifications/email.py

@ -66,3 +66,67 @@ class Email(Notification):
log.error('E-mail failed: %s', traceback.format_exc())
return False
config = [{
'name': 'email',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'email',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'from',
'label': 'Send e-mail from',
},
{
'name': 'to',
'label': 'Send e-mail to',
},
{
'name': 'smtp_server',
'label': 'SMTP server',
},
{ 'name': 'smtp_port',
'label': 'SMTP server port',
'default': '25',
'type': 'int',
},
{
'name': 'ssl',
'label': 'Enable SSL',
'default': 0,
'type': 'bool',
},
{
'name': 'starttls',
'label': 'Enable StartTLS',
'default': 0,
'type': 'bool',
},
{
'name': 'smtp_user',
'label': 'SMTP user',
},
{
'name': 'smtp_pass',
'label': 'SMTP password',
'type': 'password',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

68
couchpotato/core/notifications/email/__init__.py

@ -1,68 +0,0 @@
from .main import Email
def start():
return Email()
config = [{
'name': 'email',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'email',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'from',
'label': 'Send e-mail from',
},
{
'name': 'to',
'label': 'Send e-mail to',
},
{
'name': 'smtp_server',
'label': 'SMTP server',
},
{ 'name': 'smtp_port',
'label': 'SMTP server port',
'default': '25',
'type': 'int',
},
{
'name': 'ssl',
'label': 'Enable SSL',
'default': 0,
'type': 'bool',
},
{
'name': 'starttls',
'label': 'Enable StartTLS',
'default': 0,
'type': 'bool',
},
{
'name': 'smtp_user',
'label': 'SMTP user',
},
{
'name': 'smtp_pass',
'label': 'SMTP password',
'type': 'password',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

41
couchpotato/core/notifications/growl/main.py → couchpotato/core/notifications/growl.py

@ -64,3 +64,44 @@ class Growl(Notification):
return False
config = [{
'name': 'growl',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'growl',
'description': 'Version 1.4+',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'on_snatch',
'default': False,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
{
'name': 'hostname',
'description': 'Notify growl over network. Needs restart.',
'advanced': True,
},
{
'name': 'port',
'type': 'int',
'advanced': True,
},
{
'name': 'password',
'type': 'password',
'advanced': True,
},
],
}
],
}]

46
couchpotato/core/notifications/growl/__init__.py

@ -1,46 +0,0 @@
from .main import Growl
def start():
return Growl()
config = [{
'name': 'growl',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'growl',
'description': 'Version 1.4+',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'on_snatch',
'default': False,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
{
'name': 'hostname',
'description': 'Notify growl over network. Needs restart.',
'advanced': True,
},
{
'name': 'port',
'type': 'int',
'advanced': True,
},
{
'name': 'password',
'type': 'password',
'advanced': True,
},
],
}
],
}]

28
couchpotato/core/notifications/nmj/main.py → couchpotato/core/notifications/nmj.py

@ -118,3 +118,31 @@ class NMJ(Notification):
}
config = [{
'name': 'nmj',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'nmj',
'label': 'NMJ',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'host',
'default': 'localhost',
},
{
'name': 'database',
},
{
'name': 'mount',
},
],
}
],
}]

34
couchpotato/core/notifications/nmj/__init__.py

@ -1,34 +0,0 @@
from .main import NMJ
def start():
return NMJ()
config = [{
'name': 'nmj',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'nmj',
'label': 'NMJ',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'host',
'default': 'localhost',
},
{
'name': 'database',
},
{
'name': 'mount',
},
],
}
],
}]

37
couchpotato/core/notifications/notifymyandroid/__init__.py → couchpotato/core/notifications/notifymyandroid.py

@ -1,8 +1,39 @@
from .main import NotifyMyAndroid
from couchpotato.core.helpers.variable import splitString
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import pynma
import six
log = CPLog(__name__)
class NotifyMyAndroid(Notification):
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
nma = pynma.PyNMA()
keys = splitString(self.conf('api_key'))
nma.addkey(keys)
nma.developerkey(self.conf('dev_key'))
response = nma.push(
application = self.default_title,
event = message.split(' ')[0],
description = message,
priority = self.conf('priority'),
batch_mode = len(keys) > 1
)
successful = 0
for key in keys:
if not response[str(key)]['code'] == six.u('200'):
log.error('Could not send notification to NotifyMyAndroid (%s). %s', (key, response[key]['message']))
else:
successful += 1
return successful == len(keys)
def start():
return NotifyMyAndroid()
config = [{
'name': 'notifymyandroid',

35
couchpotato/core/notifications/notifymyandroid/main.py

@ -1,35 +0,0 @@
from couchpotato.core.helpers.variable import splitString
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import pynma
import six
log = CPLog(__name__)
class NotifyMyAndroid(Notification):
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
nma = pynma.PyNMA()
keys = splitString(self.conf('api_key'))
nma.addkey(keys)
nma.developerkey(self.conf('dev_key'))
response = nma.push(
application = self.default_title,
event = message.split(' ')[0],
description = message,
priority = self.conf('priority'),
batch_mode = len(keys) > 1
)
successful = 0
for key in keys:
if not response[str(key)]['code'] == six.u('200'):
log.error('Could not send notification to NotifyMyAndroid (%s). %s', (key, response[key]['message']))
else:
successful += 1
return successful == len(keys)

27
couchpotato/core/notifications/notifymywp/__init__.py → couchpotato/core/notifications/notifymywp.py

@ -1,8 +1,29 @@
from .main import NotifyMyWP
from couchpotato.core.helpers.variable import splitString
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from pynmwp import PyNMWP
import six
log = CPLog(__name__)
class NotifyMyWP(Notification):
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
keys = splitString(self.conf('api_key'))
p = PyNMWP(keys, self.conf('dev_key'))
response = p.push(application = self.default_title, event = message, description = message, priority = self.conf('priority'), batch_mode = len(keys) > 1)
for key in keys:
if not response[key]['Code'] == six.u('200'):
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s', (key, response[key]['message']))
return False
return response
def start():
return NotifyMyWP()
config = [{
'name': 'notifymywp',

25
couchpotato/core/notifications/notifymywp/main.py

@ -1,25 +0,0 @@
from couchpotato.core.helpers.variable import splitString
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from pynmwp import PyNMWP
import six
log = CPLog(__name__)
class NotifyMyWP(Notification):
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
keys = splitString(self.conf('api_key'))
p = PyNMWP(keys, self.conf('dev_key'))
response = p.push(application = self.default_title, event = message, description = message, priority = self.conf('priority'), batch_mode = len(keys) > 1)
for key in keys:
if not response[key]['Code'] == six.u('200'):
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s', (key, response[key]['message']))
return False
return response

2
couchpotato/core/notifications/plex/__init__.py

@ -1,7 +1,7 @@
from .main import Plex
def start():
def autoload():
return Plex()
config = [{

37
couchpotato/core/notifications/prowl/__init__.py → couchpotato/core/notifications/prowl.py

@ -1,8 +1,39 @@
from .main import Prowl
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import traceback
log = CPLog(__name__)
class Prowl(Notification):
urls = {
'api': 'https://api.prowlapp.com/publicapi/add'
}
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
data = {
'apikey': self.conf('api_key'),
'application': self.default_title,
'description': toUnicode(message),
'priority': self.conf('priority'),
}
headers = {
'Content-type': 'application/x-www-form-urlencoded'
}
try:
self.urlopen(self.urls['api'], headers = headers, data = data, show_error = False)
log.info('Prowl notifications sent.')
return True
except:
log.error('Prowl failed: %s', traceback.format_exc())
return False
def start():
return Prowl()
config = [{
'name': 'prowl',

35
couchpotato/core/notifications/prowl/main.py

@ -1,35 +0,0 @@
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import traceback
log = CPLog(__name__)
class Prowl(Notification):
urls = {
'api': 'https://api.prowlapp.com/publicapi/add'
}
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
data = {
'apikey': self.conf('api_key'),
'application': self.default_title,
'description': toUnicode(message),
'priority': self.conf('priority'),
}
headers = {
'Content-type': 'application/x-www-form-urlencoded'
}
try:
self.urlopen(self.urls['api'], headers = headers, data = data, show_error = False)
log.info('Prowl notifications sent.')
return True
except:
log.error('Prowl failed: %s', traceback.format_exc())
return False

40
couchpotato/core/notifications/pushalot/__init__.py → couchpotato/core/notifications/pushalot.py

@ -1,8 +1,42 @@
from .main import Pushalot
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import traceback
log = CPLog(__name__)
class Pushalot(Notification):
urls = {
'api': 'https://pushalot.com/api/sendmessage'
}
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
data = {
'AuthorizationToken': self.conf('auth_token'),
'Title': self.default_title,
'Body': toUnicode(message),
'IsImportant': self.conf('important'),
'IsSilent': self.conf('silent'),
'Image': toUnicode(self.getNotificationImage('medium') + '?1'),
'Source': toUnicode(self.default_title)
}
headers = {
'Content-type': 'application/x-www-form-urlencoded'
}
try:
self.urlopen(self.urls['api'], headers = headers, data = data, show_error = False)
return True
except:
log.error('PushAlot failed: %s', traceback.format_exc())
return False
def start():
return Pushalot()
config = [{
'name': 'pushalot',

38
couchpotato/core/notifications/pushalot/main.py

@ -1,38 +0,0 @@
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import traceback
log = CPLog(__name__)
class Pushalot(Notification):
urls = {
'api': 'https://pushalot.com/api/sendmessage'
}
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
data = {
'AuthorizationToken': self.conf('auth_token'),
'Title': self.default_title,
'Body': toUnicode(message),
'IsImportant': self.conf('important'),
'IsSilent': self.conf('silent'),
'Image': toUnicode(self.getNotificationImage('medium') + '?1'),
'Source': toUnicode(self.default_title)
}
headers = {
'Content-type': 'application/x-www-form-urlencoded'
}
try:
self.urlopen(self.urls['api'], headers = headers, data = data, show_error = False)
return True
except:
log.error('PushAlot failed: %s', traceback.format_exc())
return False

36
couchpotato/core/notifications/pushbullet/main.py → couchpotato/core/notifications/pushbullet.py

@ -67,3 +67,39 @@ class Pushbullet(Notification):
log.debug(ex)
return None
config = [{
'name': 'pushbullet',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'pushbullet',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'api_key',
'label': 'User API Key'
},
{
'name': 'devices',
'default': '',
'advanced': True,
'description': 'IDs of devices to send notifications to, empty = all devices'
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

40
couchpotato/core/notifications/pushbullet/__init__.py

@ -1,40 +0,0 @@
from .main import Pushbullet
def start():
return Pushbullet()
config = [{
'name': 'pushbullet',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'pushbullet',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'api_key',
'label': 'User API Key'
},
{
'name': 'devices',
'default': '',
'advanced': True,
'description': 'IDs of devices to send notifications to, empty = all devices'
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

38
couchpotato/core/notifications/pushover/main.py → couchpotato/core/notifications/pushover.py

@ -6,6 +6,8 @@ from httplib import HTTPSConnection
log = CPLog(__name__)
autoload = 'Pushover'
class Pushover(Notification):
@ -47,3 +49,39 @@ class Pushover(Notification):
else:
log.error('Pushover notification failed.')
return False
config = [{
'name': 'pushover',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'pushover',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'user_key',
'description': 'Register on pushover.net to get one.'
},
{
'name': 'priority',
'default': 0,
'type': 'dropdown',
'values': [('Normal', 0), ('High', 1)],
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

40
couchpotato/core/notifications/pushover/__init__.py

@ -1,40 +0,0 @@
from .main import Pushover
def start():
return Pushover()
config = [{
'name': 'pushover',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'pushover',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'user_key',
'description': 'Register on pushover.net to get one.'
},
{
'name': 'priority',
'default': 0,
'type': 'dropdown',
'values': [('Normal', 0), ('High', 1)],
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

22
couchpotato/core/notifications/synoindex/main.py → couchpotato/core/notifications/synoindex.py

@ -6,6 +6,8 @@ import subprocess
log = CPLog(__name__)
autoload = 'Synoindex'
class Synoindex(Notification):
@ -35,3 +37,23 @@ class Synoindex(Notification):
return {
'success': os.path.isfile(self.index_path)
}
config = [{
'name': 'synoindex',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'synoindex',
'description': 'Automaticly adds index to Synology Media Server.',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
}
],
}
],
}]

24
couchpotato/core/notifications/synoindex/__init__.py

@ -1,24 +0,0 @@
from .main import Synoindex
def start():
return Synoindex()
config = [{
'name': 'synoindex',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'synoindex',
'description': 'Automaticly adds index to Synology Media Server.',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
}
],
}
],
}]

32
couchpotato/core/notifications/toasty/main.py → couchpotato/core/notifications/toasty.py

@ -5,6 +5,8 @@ import traceback
log = CPLog(__name__)
autoload = 'Toasty'
class Toasty(Notification):
@ -29,3 +31,33 @@ class Toasty(Notification):
log.error('Toasty failed: %s', traceback.format_exc())
return False
config = [{
'name': 'toasty',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'toasty',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'api_key',
'label': 'Device ID',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

34
couchpotato/core/notifications/toasty/__init__.py

@ -1,34 +0,0 @@
from .main import Toasty
def start():
return Toasty()
config = [{
'name': 'toasty',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'toasty',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'api_key',
'label': 'Device ID',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

29
couchpotato/core/notifications/trakt/main.py → couchpotato/core/notifications/trakt.py

@ -4,6 +4,8 @@ from couchpotato.core.notifications.base import Notification
log = CPLog(__name__)
autoload = 'Trakt'
class Trakt(Notification):
@ -62,3 +64,30 @@ class Trakt(Notification):
log.error('Failed to call trakt, check your login.')
return False
config = [{
'name': 'trakt',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'trakt',
'label': 'Trakt',
'description': 'add movies to your collection once downloaded. Fill in your username and password in the <a href="../automation/">Automation Trakt settings</a>',
'options': [
{
'name': 'notification_enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'remove_watchlist_enabled',
'label': 'Remove from watchlist',
'default': False,
'type': 'bool',
},
],
}
],
}]

31
couchpotato/core/notifications/trakt/__init__.py

@ -1,31 +0,0 @@
from .main import Trakt
def start():
return Trakt()
config = [{
'name': 'trakt',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'trakt',
'label': 'Trakt',
'description': 'add movies to your collection once downloaded. Fill in your username and password in the <a href="../automation/">Automation Trakt settings</a>',
'options': [
{
'name': 'notification_enabled',
'default': False,
'type': 'enabler',
},
{
'name': 'remove_watchlist_enabled',
'label': 'Remove from watchlist',
'default': False,
'type': 'bool',
},
],
}
],
}]

2
couchpotato/core/notifications/twitter/__init__.py

@ -1,7 +1,7 @@
from .main import Twitter
def start():
def autoload():
return Twitter()
config = [{

65
couchpotato/core/notifications/xbmc/main.py → couchpotato/core/notifications/xbmc.py

@ -11,6 +11,8 @@ from requests.packages.urllib3.exceptions import MaxRetryError
log = CPLog(__name__)
autoload = 'XBMC'
class XBMC(Notification):
@ -210,3 +212,66 @@ class XBMC(Notification):
log.error('Failed sending request to XBMC: %s', traceback.format_exc())
return []
config = [{
'name': 'xbmc',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'xbmc',
'label': 'XBMC',
'description': 'v11 (Eden) and v12 (Frodo)',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'host',
'default': 'localhost:8080',
},
{
'name': 'username',
'default': 'xbmc',
},
{
'name': 'password',
'default': '',
'type': 'password',
},
{
'name': 'only_first',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Only update the first host when movie snatched, useful for synced XBMC',
},
{
'name': 'remote_dir_scan',
'label': 'Remote Folder Scan',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Only scan new movie folder at remote XBMC servers. Works if movie location is the same.',
},
{
'name': 'force_full_scan',
'label': 'Always do a full scan',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Do a full scan instead of only the new movie. Useful if the XBMC path is different from the path CPS uses.',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

68
couchpotato/core/notifications/xbmc/__init__.py

@ -1,68 +0,0 @@
from .main import XBMC
def start():
return XBMC()
config = [{
'name': 'xbmc',
'groups': [
{
'tab': 'notifications',
'list': 'notification_providers',
'name': 'xbmc',
'label': 'XBMC',
'description': 'v11 (Eden) and v12 (Frodo)',
'options': [
{
'name': 'enabled',
'default': 0,
'type': 'enabler',
},
{
'name': 'host',
'default': 'localhost:8080',
},
{
'name': 'username',
'default': 'xbmc',
},
{
'name': 'password',
'default': '',
'type': 'password',
},
{
'name': 'only_first',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Only update the first host when movie snatched, useful for synced XBMC',
},
{
'name': 'remote_dir_scan',
'label': 'Remote Folder Scan',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Only scan new movie folder at remote XBMC servers. Works if movie location is the same.',
},
{
'name': 'force_full_scan',
'label': 'Always do a full scan',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Do a full scan instead of only the new movie. Useful if the XBMC path is different from the path CPS uses.',
},
{
'name': 'on_snatch',
'default': 0,
'type': 'bool',
'advanced': True,
'description': 'Also send message when movie is snatched.',
},
],
}
],
}]

47
couchpotato/core/notifications/xmpp/__init__.py → couchpotato/core/notifications/xmpp.py

@ -1,8 +1,49 @@
from .main import Xmpp
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from time import sleep
import traceback
import xmpp
log = CPLog(__name__)
autoload = 'Xmpp'
class Xmpp(Notification):
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
try:
jid = xmpp.protocol.JID(self.conf('username'))
client = xmpp.Client(jid.getDomain(), debug = [])
# Connect
if not client.connect(server = (self.conf('hostname'), self.conf('port'))):
log.error('XMPP failed: Connection to server failed.')
return False
# Authenticate
if not client.auth(jid.getNode(), self.conf('password'), resource = jid.getResource()):
log.error('XMPP failed: Failed to authenticate.')
return False
# Send message
client.send(xmpp.protocol.Message(to = self.conf('to'), body = message, typ = 'chat'))
# Disconnect
# some older servers will not send the message if you disconnect immediately after sending
sleep(1)
client.disconnect()
log.info('XMPP notifications sent.')
return True
except:
log.error('XMPP failed: %s', traceback.format_exc())
return False
def start():
return Xmpp()
config = [{
'name': 'xmpp',

43
couchpotato/core/notifications/xmpp/main.py

@ -1,43 +0,0 @@
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from time import sleep
import traceback
import xmpp
log = CPLog(__name__)
class Xmpp(Notification):
def notify(self, message = '', data = None, listener = None):
if not data: data = {}
try:
jid = xmpp.protocol.JID(self.conf('username'))
client = xmpp.Client(jid.getDomain(), debug = [])
# Connect
if not client.connect(server = (self.conf('hostname'), self.conf('port'))):
log.error('XMPP failed: Connection to server failed.')
return False
# Authenticate
if not client.auth(jid.getNode(), self.conf('password'), resource = jid.getResource()):
log.error('XMPP failed: Failed to authenticate.')
return False
# Send message
client.send(xmpp.protocol.Message(to = self.conf('to'), body = message, typ = 'chat'))
# Disconnect
# some older servers will not send the message if you disconnect immediately after sending
sleep(1)
client.disconnect()
log.info('XMPP notifications sent.')
return True
except:
log.error('XMPP failed: %s', traceback.format_exc())
return False
Loading…
Cancel
Save