Pushbullet: add device-id
Posted: October 13th, 2017, 1:43 am
When using Sonarr and Radarr I can setup a specific device-id for pushbullet-notifications. Is it possible to add this feature to SABnzbd?
Code: Select all
def send_pushbullet(title, msg, gtype, force=False, test=None):
""" Send message to Pushbullet """
if test:
apikey = test.get('pushbullet_apikey')
device = test.get('pushbullet_device')
else:
apikey = sabnzbd.cfg.pushbullet_apikey()
device = sabnzbd.cfg.pushbullet_device()
if not apikey:
return T('Cannot send, missing required data')
title = u'SABnzbd: ' + Tx(NOTIFICATION.get(gtype, 'other'))
try:
conn = httplib.HTTPSConnection('api.pushbullet.com:443')
conn.request('POST', '/v2/pushes',
json.dumps({
'type': 'note',
'device': device,
'title': title,
'body': msg}),
headers={'Authorization': 'Bearer ' + apikey,
'Content-type': 'application/json'})
res = conn.getresponse()
if res.status != 200:
logging.error(T('Bad response from Pushbullet (%s): %s'), res.status, res.read())
else:
logging.info('Successfully sent to Pushbullet')
except:
logging.warning(T('Failed to send pushbullet message'))
logging.info('Traceback: ', exc_info=True)
return T('Failed to send pushbullet message')
return ''