Browse Source

Merge branch 'develop' of https://github.com/kjagiello/CouchPotatoServer into kjagiello-develop

pull/5076/head
Ruud 10 years ago
parent
commit
d0780043bd
  1. 27
      couchpotato/core/notifications/pushbullet.py

27
couchpotato/core/notifications/pushbullet.py

@ -19,14 +19,8 @@ class Pushbullet(Notification):
def notify(self, message = '', data = None, listener = None): def notify(self, message = '', data = None, listener = None):
if not data: data = {} if not data: data = {}
devices = self.getDevices()
if devices is None:
return False
# Get all the device IDs linked to this user # Get all the device IDs linked to this user
if not len(devices): devices = self.getDevices() or [None]
devices = [None]
successful = 0 successful = 0
for device in devices: for device in devices:
response = self.request( response = self.request(
@ -43,11 +37,24 @@ class Pushbullet(Notification):
else: else:
log.error('Unable to push notification to Pushbullet device with ID %s' % device) log.error('Unable to push notification to Pushbullet device with ID %s' % device)
for channel in self.getChannels():
response = self.request(
'pushes',
cache = False,
channel_tag = channel,
type = 'note',
title = self.default_title,
body = toUnicode(message)
)
return successful == len(devices) return successful == len(devices)
def getDevices(self): def getDevices(self):
return splitString(self.conf('devices')) return splitString(self.conf('devices'))
def getChannels(self):
return splitString(self.conf('channels'))
def request(self, method, cache = True, **kwargs): def request(self, method, cache = True, **kwargs):
try: try:
base64string = base64.encodestring('%s:' % self.conf('api_key'))[:-1] base64string = base64.encodestring('%s:' % self.conf('api_key'))[:-1]
@ -94,6 +101,12 @@ config = [{
'description': 'IDs of devices to send notifications to, empty = all devices' 'description': 'IDs of devices to send notifications to, empty = all devices'
}, },
{ {
'name': 'channels',
'default': '',
'advanced': True,
'description': 'IDs of channels to send notifications to, empty = no channels'
},
{
'name': 'on_snatch', 'name': 'on_snatch',
'default': 0, 'default': 0,
'type': 'bool', 'type': 'bool',

Loading…
Cancel
Save