I modified the sabToPushover script (sorry - I dont know the author to give credit) to work with PushBullet
Forgot to mention that this is running for me on Linux (Ubuntu) and uses CURL to talk to pushbullet.
Two files are required:
sabToPushBullet.py
Code: Select all
#!/usr/bin/env python
import sys
import httplib
import urllib
import os.path
import logging
import ConfigParser
import subprocess
ch = logging.StreamHandler()
ch.setFormatter(logging.Formatter('%(asctime)s [%(name)s] %(levelname)s: %(message)s'))
logger = logging.getLogger("PushBullet.sab")
logger.setLevel(logging.DEBUG)
logger.addHandler(ch)
def readConfig(configName) :
config = ConfigParser.ConfigParser()
file = os.path.join(os.path.dirname(sys.argv[0]), configName)
if not os.path.isfile(file):
print "ERROR: You need a {0} config file!".format(configName)
sys.exit(-1)
try:
fp = open(file, "r")
config.readfp(fp)
fp.close()
except IOError, e:
print "Could not read configuration file: ", str(e)
sys.exit(1)
return config
def PushBullet(dirname, nzbName=None, cleanJobName=None, statusCode=0) :
logger.info("Sending notification for job '%s', status %s", cleanJobName, statusCode)
config = readConfig("sabToPushBullet.cfg")
api = config.get("PushBullet", "api")
iden = config.get("PushBullet", "device_iden")
logger.info("api %s", api)
status = int(statusCode)
# message title
title = "Download complete"
if status > 0: "Download failed"
# message detail
message = "Downloaded {0} successfully".format(cleanJobName)
if status == 1: message = "Failed to verify nzb {0}".format(nzbName)
if status == 2: message = "Failed to unpack {0}".format(cleanJobName)
if status > 2: message = "Failed to verify and unpack {0}".format(cleanJobName)
# the message priority for errors
priority = 0
if status > 0 and error_priority > 0: priority = 1
# call pushbullet
vcl='curl https://api.pushbullet.com/api/pushes -u "%s": -d device_iden="%s" -d type=note -d title="%s" -d body="%s" -X POST -s -S > /dev/null' % (api,iden,title,message)
x = subprocess.Popen(vcl,shell=True)
logger.info("Message { title: '%s', message: '%s' }", title, message)
if len(sys.argv) < 2:
print "No folder supplied - is this being called from SABnzbd?"
sys.exit()
elif len(sys.argv) >= 3:
PushBullet(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[7])
else:
PushBullet(sys.argv[1])
sabToPushBullet.cfg
Code: Select all
[PushBullet]
api=(apikey without the :)
device_iden=(can be left blank and will send to all your devices)
Spants