Prowl Notification
Posted: 24 Oct 2012, 00:52
This is code that was written by Peter Niels. I had no part in writing it and take no credit. I have been using it successfully to alert me when a new torrent is downloaded an added to the library. You must use Prowl on your Timer. I have found this much more reliable than email through gmail's occasional need to perform a "capcha" verification. I could always get email to work for a few days and then it would stop for no apparent reason. Anyway, prowl is really nice.
Put this part at the top:
Insert this part where you would otherwise be notified via email or after your renaming process:
Hope this helps some people and thanks for all your great work Rednoah!
Put this part at the top:
Code: Select all
class Prowl {
static add(apikey, application, event, description, priority = 0) {
use(StringCategory) {
send "https://prowl.weks.net/publicapi/add?apikey=${apikey}&application=${application.encode()}&event=${event.encode()}&description=${description.encode()}&priority=${priority}"
}
}
static verify(apikey) {
send "https://prowl.weks.net/publicapi/verify?apikey=${apikey}"
}
static send(url) {
def result = new Expando()
try {
def prowl = new XmlParser().parseText(url.toURL().text)
result.remaining = prowl.success[0].@remaining
result.resetdate = new Date(Long.valueOf(prowl.success[0].@resetdate) * 1000)
result.success = true
} catch (Exception ex) {
result.success = false
result.errorMessage = ex.message
}
return result
}
}
class StringCategory {
static encode(string) {
URLEncoder.encode(string, "UTF-8")
}
}
Code: Select all
--- verify api key ---
println Prowl.verify("your_api_key")
--- send event ---
println Prowl.add("your_api_key", "my-app", "my-event", "my-description")