[PP-Script] Notify OSX

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
DrDaveDeath
Posts: 5
Joined: 27 Aug 2014, 16:18

[PP-Script] Notify OSX

Post by DrDaveDeath » 27 Aug 2014, 16:30

This PP and Queue script will notify OSX via Notification Centre when a download has completed, failed or added to NZBGet. I utilise the 'terminal-notifier' work done here https://github.com/alloy/terminal-notifier, the actual script to send the notifications is simple, but works well. Feel free to download the terminal-notifier app from the link posted and replace the one included in the download.

Source: GitHub|Direct Download
Requirements: NZBGet v13+ and Python 2.7

Installation
  1. Download and copy the notify-osx folder into your NZBGet scripts directory
  2. Add to both PostScript and QueueScript
  3. Configure which notifications you'd like to see
Hope this is useful to someone.
Last edited by DrDaveDeath on 27 Aug 2014, 18:52, edited 1 time in total.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Notify OSX

Post by hugbug » 27 Aug 2014, 17:02

Great work, thank you!

(As a security measure I've downloaded the terminal-notifier.app from the link above).

I noticed it doesn't notify if the download wasn't unpacked (nothing to unpack). I changed the check to test "NZBPP_TOTALSTATUS": instead of "NZBPP_STATUS":

Code: Select all

# If download is a success
if os.environ.get('NZBPP_TOTALSTATUS') == 'SUCCESS' and on_success == 'yes':

DrDaveDeath
Posts: 5
Joined: 27 Aug 2014, 16:18

Re: [PP-Script] Notify OSX

Post by DrDaveDeath » 27 Aug 2014, 18:51

hugbug wrote: I noticed it doesn't notify if the download wasn't unpacked (nothing to unpack). I changed the check to test "NZBPP_TOTALSTATUS": instead of "NZBPP_STATUS":

Code: Select all

# If download is a success
if os.environ.get('NZBPP_TOTALSTATUS') == 'SUCCESS' and on_success == 'yes':
Ah yeah, that makes much more sense! I've pushed that change.

pducharme
Posts: 5
Joined: 24 Jul 2014, 00:56

Re: [PP-Script] Notify OSX

Post by pducharme » 26 Oct 2014, 23:50

This is exactly what I was looking for, but I'm running NZBGet on my Unraid Server (on a different computer).

How can I use this to notify my OS X Notification Center ??

I want the script to get the notification thru API...

rr0ss0rr
Posts: 10
Joined: 21 Feb 2015, 14:59

Re: [PP-Script] Notify OSX

Post by rr0ss0rr » 21 Feb 2015, 15:14

**Update** .. Never mind. I read too much into adding the script to PostScript and QueueScript when nzbget mentioned Only filenames without path must be used. Changed to notify-osx/notify-osx.py and all works fine.. Thanks again for writing this



Not working for me .. Mac Yosemite Release. I did replace terminal-notifier.app with the 1.6.2 version. Added notify-osx.py to PostScript and QueueScript in the EXTENSION SCRIPTS page and enabled all 3 notify messages. How does one try to debug this? Nothing mentioned in nzbget messages about notify-osx . I'm not a python guy, the only thing that thing I saw was the path to the terminal-notifier.app:

directory = str(os.path.dirname(os.path.realpath(__file__))).replace('\\', '\\\\')
os.system(directory + '/terminal-notifier.app/Contents/MacOS/terminal-notifier {}'.format(' '.join([m, t, s])))

Wasn't sure if the path translates to ~/NZBGet/scripts/notify-osx/

:~/NZBGet/scripts/notify-osx$ ll
total 24
drwxr-xr-x@ 6 richard staff 204 Feb 20 20:56 .
drwxr-xr-x 7 richard staff 238 Feb 20 19:53 ..
-rw-r--r--@ 1 richard staff 6148 Feb 20 21:05 .DS_Store
-rwxr-xr-x@ 1 richard staff 2818 Aug 27 12:49 notify-osx.py
drwxr-xr-x 3 richard staff 102 Feb 20 20:10 terminal-notifier.app
drwxr-xr-x@ 3 richard staff 102 Aug 27 12:49 terminal-notifier.old

~/NZBGet/scripts/notify-osx$ ./terminal-notifier.app/Contents/MacOS/terminal-notifier -v
terminal-notifier (1.6.2) is a command-line tool to send OS X User Notifications.

Thanks

a_penguin
Posts: 4
Joined: 04 Apr 2015, 07:53

Re: [PP-Script] Notify OSX

Post by a_penguin » 04 Apr 2015, 07:57

Can't seem to get this to work on Yosemite. I have the settings configured exactly as in the OP, but notification centre doesn't receive or display anything messages from NZBGet events

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Notify OSX

Post by hugbug » 04 Apr 2015, 08:06

Is a message printd about the script beingcutd? Show your log.

EDIT: Is a message printed about the script being executed? Show your log.

a_penguin
Posts: 4
Joined: 04 Apr 2015, 07:53

Re: [PP-Script] Notify OSX

Post by a_penguin » 04 Apr 2015, 08:28

hugbug wrote:Is a message printd about the script beingcutd? Show your log.
What does this mean?

The only messages I get in the log related to the script is (after adding a sample .nzb):

Sat Apr 4 16:23:26 2015 INFO Executing queue-script notify-osx/notify-osx.py for The.Green.Prince.2014.PROPER.LIMITED.DVDRip.x264-RedBlade
Sat Apr 4 16:23:27 2015 INFO notify-osx: sh: /Users/[REDACTED]/Library/Application: No such file or directory

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Notify OSX

Post by hugbug » 04 Apr 2015, 08:52

There is a bug. Open the script in TextEdit and replace the string

Code: Select all

    os.system(directory + '/terminal-notifier.app/Contents/MacOS/terminal-notifier {}'.format(' '.join([m, t, s])))
with

Code: Select all

    os.system('"' + directory + '/terminal-notifier.app/Contents/MacOS/terminal-notifier" {}'.format(' '.join([m, t, s])))
Or use the patched attached version.
Attachments
notify-osx.py
Bug fix for directories with spaces
(2.76 KiB) Downloaded 237 times

a_penguin
Posts: 4
Joined: 04 Apr 2015, 07:53

Re: [PP-Script] Notify OSX

Post by a_penguin » 04 Apr 2015, 08:58

hugbug wrote:There is a bug. Open the script in TextEdit and replace the string

Code: Select all

    os.system(directory + '/terminal-notifier.app/Contents/MacOS/terminal-notifier {}'.format(' '.join([m, t, s])))
with

Code: Select all

    os.system('"' + directory + '/terminal-notifier.app/Contents/MacOS/terminal-notifier" {}'.format(' '.join([m, t, s])))
Or use the patched attached version.
Thank you thank you thank you! It works perfectly now :D

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests