diff --git a/couchpotato/core/notifications/boxcar/__init__.py b/couchpotato/core/notifications/boxcar/__init__.py new file mode 100644 index 0000000..f83722f --- /dev/null +++ b/couchpotato/core/notifications/boxcar/__init__.py @@ -0,0 +1,32 @@ +from .main import Boxcar + +def start(): + return Boxcar() + +config = [{ + 'name': 'boxcar', + 'groups': [ + { + 'tab': 'notifications', + '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.', + }, + ], + } + ], +}] diff --git a/couchpotato/core/notifications/boxcar/main.py b/couchpotato/core/notifications/boxcar/main.py new file mode 100644 index 0000000..b4a7ef7 --- /dev/null +++ b/couchpotato/core/notifications/boxcar/main.py @@ -0,0 +1,36 @@ +from couchpotato.core.helpers.encoding import toUnicode +from couchpotato.core.logger import CPLog +from couchpotato.core.notifications.base import Notification +import time + +log = CPLog(__name__) + + +class Boxcar(Notification): + + url = 'https://boxcar.io/devices/providers/7MNNXY3UIzVBwvzkKwkC/notifications' + + def notify(self, message = '', data = {}): + if self.isDisabled(): return + print 'test' + + try: + message = message.strip() + + params = { + 'email': self.conf('email'), + 'notification[from_screen_name]': self.default_title, + 'notification[message]': toUnicode(message), + 'notification[from_remote_service_id]': int(time.time()), + } + + self.urlopen(self.url, params = params) + except: + log.error('Check your email and added services on boxcar.io') + return False + + log.info('Boxcar notification successful.') + return True + + def isEnabled(self): + return super(Boxcar, self) and self.conf('email')