I'm no python expert so don't expect the script to be super elegant ;]
Code: Select all
#!/usr/bin/python
import httplib, urllib, sys
message = "" #"Download of " + sys.argv[3] + " "
serverurl = "$SERVER_URL"
print("Convertig argument " + sys.argv[7] + " to status.")
if(int(sys.argv[7]) == 0):
message = "Download of " + sys.argv[3] + " has been completed."
elif(int(sys.argv[7]) == 1):
message = "Verification of " + sys.argv[3] + " failed."
elif(int(sys.argv[7]) == 2):
message = "Unpacking of " + sys.argv[3] + " failed."
elif(int(sys.argv[7]) == 3):
message = "Verification and unpacking of " + sys.argv[3] + " failed."
print("Establishing http connection.")
conn = httplib.HTTPSConnection("api.pushover.net:443")
print("Handling request.")
conn.request("POST", "/1/messages.json",
urllib.urlencode({
"token": "$API_KEY",
"user": "$USER_KEY",
"message": message,
"url": serverurl,
"url_title": "Visit web interface",
}), { "Content-type": "application/x-www-form-urlencoded" })
print("Waiting for response.")
conn.getresponse()
print("Notification send.")
The $USER_KEY is straight forward, you can find it when logging into your Pushover account.
Generating the $API_KEY is a little trickier but still easy ;]
Log into your account, go to "Apps & Plugins", select "Create a new application" and enter a name, select an icon (selection of pictures). Finally click on "Create application" and write down your api key.
Unfortunately this has to be done as Pushover limites the monthly API calls.
Replacing the server URL is optional but if you enter the URL of your Sabnzbd you can easily open the webpage if a download fails.
When you're done entering the values put the file into your sabnzbd scripts folder and make sure it's executable and accessible to the user hosting the sabnzbd process.
From the "Categories" page of your sabnzbd web interface you can now select the script.