Skip to content

Instantly share code, notes, and snippets.

@Critter
Created July 11, 2014 19:33
Show Gist options
  • Save Critter/e5bf161ca679bfa14837 to your computer and use it in GitHub Desktop.
Save Critter/e5bf161ca679bfa14837 to your computer and use it in GitHub Desktop.
SABNzbd script to push notifications to pushover
#!/usr/bin/python
import httplib, urllib, sys
message = "Download of " + sys.argv[3] + " "
serverurl = "$sabserver"
print("Converting 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": "$pushover-user-token",
"user": "$pushover-api-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 Sent.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment