iPhone notification via Prowl

Come up with a useful post-processing script? Share it here!
Post Reply
UloPe
Newbie
Newbie
Posts: 4
Joined: July 21st, 2009, 11:49 am

iPhone notification via Prowl

Post by UloPe »

Hi,

i made a quick script to notify me about finished downloads on my iPhone via Prowl:
You need the prowlpy library (there is a link on the Prowl site).

Code: Select all

#!/usr/bin/env python

import sys

from prowlpy import Prowl

p = Prowl('YOUR_API_KEY_GOES_HERE')
try:
    p.add("SABnzbd", "Download finished", '"%s" completed' % sys.argv[3])
except Exception, e:
    print e
jubei
Release Testers
Release Testers
Posts: 53
Joined: January 28th, 2009, 11:49 am

Re: iPhone notification via Prowl

Post by jubei »

I can't get this to work, can you tell me exactly what pre-req's are required and where they need to be put?
UloPe
Newbie
Newbie
Posts: 4
Joined: July 21st, 2009, 11:49 am

Re: iPhone notification via Prowl

Post by UloPe »

Hi,

you need prowlpy.py which in turn needs httplib2.

Install httplib2 as described on the page. Then put prowlpy.py in the same directory as my script and you should be up and running.

Of course you also need a prowl account.
gazzzmoly
Release Testers
Release Testers
Posts: 27
Joined: May 15th, 2009, 9:46 am

Re: iPhone notification via Prowl

Post by gazzzmoly »

jubei wrote: I can't get this to work, can you tell me exactly what pre-req's are required and where they need to be put?

are you using an alpha  ?      if so post in the testers forum    not sure i can help in here !
dasme

Re: iPhone notification via Prowl

Post by dasme »

Hey there, I'm having an issue with this script. SABnzbd reports this output in the post-processing script when run:

Code: Select all

    Traceback (most recent call last):
  File "/Users/dasme/downloads/scripts/Prowl.py", line 5, in <module>
    from prowlpy import Prowl
  File "/Users/dasme/Downloads/scripts/prowlpy.py", line 12, in <module>
    import httplib2
ImportError: No module named httplib2
yet if I run the script manually (eg ./Prowl.py 1 2 3)I get a Prowl notification ("3" completed), so I know that httplib2 is installed and working. I'm new to Python, not having used it before so I'm wondering if this is a simple fix? I'm on OSX btw

thanks in advance for any tips!
Fevida
Newbie
Newbie
Posts: 2
Joined: September 16th, 2009, 3:46 pm

Re: iPhone notification via Prowl

Post by Fevida »

Works brilliantly on my FreeBSD-box!! Thnx!  ;D
tastynzb
Release Testers
Release Testers
Posts: 5
Joined: September 26th, 2009, 3:01 pm

Re: iPhone notification via Prowl

Post by tastynzb »

dasme,

I had the same error. To fix, install from the repo instead of installing manually

sudo apt-get install python-httplib2
Se7en
Newbie
Newbie
Posts: 47
Joined: December 28th, 2010, 1:11 pm

Re: iPhone notification via Prowl

Post by Se7en »

Hi all.

I'd like to have Prowl notifications from sabnzbd only if the download is incomplete/error message - if that's possible. If anyone has a script, I'd be more than happy :)
idmanager
Newbie
Newbie
Posts: 11
Joined: December 12th, 2010, 2:47 pm

Re: iPhone notification via Prowl

Post by idmanager »

add your prowl api key and save script as .py file and set as default script to run on sab
will notify you on complete downloads

Code: Select all

#!/usr/bin/env python
import sys,urllib

# Get clean NZB name
job_name = sys.argv[3]

# Prowl API settings - http://prowl.weks.net/api.php
# Set Prowl API
API = "enter the prowl api key here "
# Set Prowl priority. 0 - Normal, 2 - Emergency, -2 - Very Low
priority = "0"

# Set job title/event name
job_title = "Download%20Complete"

# Get current date/time and strip spaces
from time import gmtime, strftime
event_time = strftime("%d/%m/%y %H:%M")
event_time=event_time.replace(' ', '%20')

# URL encode chars from NZB name that cause issues
job_name=job_name.replace(' ', '%20')
job_name=job_name.replace('_', '%20')
job_name=job_name.replace('.', '%20')

# Send download complete notification to iPhone - swap 'job_title' for 'event_time' if completion time is required instead of 'Download Complete'
urllib.urlopen("https://prowl.weks.net/publicapi/add?apikey=" + API + "&priority=" + priority + "&application=SABnzbd&event=" + job_title + "&description=" + job_name)
Se7en
Newbie
Newbie
Posts: 47
Joined: December 28th, 2010, 1:11 pm

Re: iPhone notification via Prowl

Post by Se7en »

idmanager wrote:add your prowl api key and save script as .py file and set as default script to run on sab
will notify you on complete downloads

Code: Select all

#!/usr/bin/env python
import sys,urllib

# Get clean NZB name
job_name = sys.argv[3]

# Prowl API settings - http://prowl.weks.net/api.php
# Set Prowl API
API = "enter the prowl api key here "
# Set Prowl priority. 0 - Normal, 2 - Emergency, -2 - Very Low
priority = "0"

# Set job title/event name
job_title = "Download%20Complete"

# Get current date/time and strip spaces
from time import gmtime, strftime
event_time = strftime("%d/%m/%y %H:%M")
event_time=event_time.replace(' ', '%20')

# URL encode chars from NZB name that cause issues
job_name=job_name.replace(' ', '%20')
job_name=job_name.replace('_', '%20')
job_name=job_name.replace('.', '%20')

# Send download complete notification to iPhone - swap 'job_title' for 'event_time' if completion time is required instead of 'Download Complete'
urllib.urlopen("https://prowl.weks.net/publicapi/add?apikey=" + API + "&priority=" + priority + "&application=SABnzbd&event=" + job_title + "&description=" + job_name)
Nice, thanks, changed to Download%20Incomplete, it works like a charm. Thanks again O0
Nurfballs
Newbie
Newbie
Posts: 5
Joined: November 29th, 2011, 4:01 pm

Re: iPhone notification via Prowl

Post by Nurfballs »

I cant seem to get this to work :(
I'm using the same script as Se7en, however the script executes but fails with the following error:

Code: Select all

env: python
: No such file or directory
Any help would be greatly appreciated.
Nurfballs
Newbie
Newbie
Posts: 5
Joined: November 29th, 2011, 4:01 pm

Re: iPhone notification via Prowl

Post by Nurfballs »

Looks like i've fixed it by accident.

Originally, I created the script on my Windows machine, and used WinSCP to copy it to my linux box.
After making any changes to the script while troubleshooting, I would use the same method of editing it on my Windows machine and copying it back. Each time the script would fail with the same issue.

However, I found that if I edited the script using WinSCP directly on the linux box (instead of Notepad, and copying it back) - it seems to work. Code is exactly the same. Bizarre!
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: iPhone notification via Prowl

Post by shypike »

The bash shell gets confused when it reads a Windows text file,
because lines are terminated by a CR and an LF code (where Unix only uses LF).
The CR character is taken as part of the first line, so the "env" command looks for "python$",
where $ is the CR character.
The Python interpreter just ignores the extra characters.
Nurfballs
Newbie
Newbie
Posts: 5
Joined: November 29th, 2011, 4:01 pm

Re: iPhone notification via Prowl

Post by Nurfballs »

Very interesting to know - thanks shypike!
xreyuk
Newbie
Newbie
Posts: 17
Joined: December 28th, 2012, 12:46 pm

Re: iPhone notification via Prowl

Post by xreyuk »

Sorry to bump the old thread, but to make idmanagers script work, do I still need the prowl.py file and httplib2?
Post Reply