Pushbullet: add device-id

Want something added? Ask for it here.
Post Reply
pven
Release Testers
Release Testers
Posts: 132
Joined: August 21st, 2009, 5:00 am

Pushbullet: add device-id

Post by pven » 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?

User avatar
sander
Release Testers
Release Testers
Posts: 6643
Joined: January 22nd, 2008, 2:22 pm

Re: Pushbullet: add device-id

Post by sander » October 13th, 2017, 2:14 am

Below is the SAB code. I see 'device', but AFAIK is not filled out. Could that be the device-id? Do you run from source?

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

pven
Release Testers
Release Testers
Posts: 132
Joined: August 21st, 2009, 5:00 am

Re: Pushbullet: add device-id

Post by pven » October 13th, 2017, 2:18 am

When device is empty it will send a notification to all devices (that is the default behavior for pushbullet).

I don't understand 'do you run from source'. I run SABnzbd on my Synology. :)

User avatar
safihre
Administrator
Administrator
Posts: 3239
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: Pushbullet: add device-id

Post by safihre » October 13th, 2017, 3:24 am

It was disabled, but not sure why: https://github.com/sabnzbd/sabnzbd/comm ... 7fed1b0606

I recommend that you instead use the Notification Script NZB-Notify https://github.com/caronc/nzb-notify
He supports the device ID and many more services, if you ever need them :)

pven
Release Testers
Release Testers
Posts: 132
Joined: August 21st, 2009, 5:00 am

Re: Pushbullet: add device-id

Post by pven » October 13th, 2017, 4:03 am

That one is new for me. Thanks, I will give it a try. :)

User avatar
shypike
Administrator
Administrator
Posts: 21039
Joined: January 18th, 2008, 12:49 pm

Re: Pushbullet: add device-id

Post by shypike » October 19th, 2017, 3:10 pm

It was disabled because it's not what people expect it to be.
It's not like "John's iPhone", but some internal ID.
You cannot lookup the IDs and the friendly names on the PushBullet website.
You need to do several API queries before you can show a selection list.
I didn't want to spend so much effort on it.

pven
Release Testers
Release Testers
Posts: 132
Joined: August 21st, 2009, 5:00 am

Re: Pushbullet: add device-id

Post by pven » October 26th, 2017, 2:25 am

nzb-notify works great. Thanks!

Post Reply