Prowl Notification

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Maxxodd
Posts: 23
Joined: 27 May 2012, 21:01

Prowl Notification

Post by Maxxodd »

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:

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")
  }
}
Insert this part where you would otherwise be notified via email or after your renaming process:

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")
Hope this helps some people and thanks for all your great work Rednoah!
User avatar
rednoah
The Source
Posts: 22995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Prowl Notification

Post by rednoah »

Thanks for the tip! Gmail worked fine for testing, but maybe if it sends to many mails, or from an IP where nobody ever logs into gmail. Maybe there is a solution somewhere on the net.

I'll have a look at Prowl, if it works well I'll add a new shared script so you can just do include('lib/prowl') to add those functions.

UPDATE:
Not gonna add default support for that since that Prowl app charges $$$! Since I don't get paid for my work, I don't really see why others should.
:idea: Please read the FAQ and How to Request Help.
Post Reply