Skip to content

Instantly share code, notes, and snippets.

@fvdm
Created September 8, 2012 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fvdm/3671303 to your computer and use it in GitHub Desktop.
Save fvdm/3671303 to your computer and use it in GitHub Desktop.
Push notification script for SABnzbd+
#!/usr/bin/node
/*
Post-process script for SABnzbd and AppNotifications
~ when a download is completed this script will send a push
~ notification to your mobile device using AppNotifications.com
Depends:
- NodeJS: http://nodejs.org
- NPM: http://npmjs.org (comes with Node)
- Module: http://npmjs.org/package/push-node
- Push account: http://appnotifications.com
Install:
- npm install push-node
- save the script in your SABnzbd scripts path
- config vars below
- chmod +x the script
- config SABnzbd categories to run this script
*/
// CONFIG
var pushApiKey = ''
// input
var dl = {
fullpath: process.argv[2], // /home/user/Downloads/complete/tv/Rookie Blue
nzbname: process.argv[3], // Rookie Blue S03E08 REPACK 720p HDTV x264 EVOLVE.nzb
cleanname: process.argv[4], // Rookie_Blue_S03E08_REPACK_720p_HDTV_x264_EVOLVE
reportnumber: process.argv[5],
category: process.argv[6], // tv
group: process.argv[7], // alt.binaries.multimedia
statuscode: process.argv[8] // 0
}
// fix category
if( dl.category.match( /^(|\-|\*)$/ ) ) {
dl.category = ''
}
// translate statuscode
switch( dl.statuscode ) {
case 1: status = 'incomplete'; break
case 2: status = 'fail'; break
case 3: status = 'bad'; break
case 0: default: status = 'ok'; break
}
// text
var msg = dl.cleanname.replace('_', ' ').trim()
///////////////////////
// PUSH NOTIFICATION //
///////////////////////
var apn = require('push-node')
apn.api.credential = pushApiKey
apn.account.notify(
{
message: dl.category +' '+ status +': '+ msg,
action_loc_key: 'details',
title: dl.category +' NZB download '+ status,
subtitle: msg,
long_message: '<b>'+ msg +'</b><br><small style="color:#555;">'+ dl.category +', nzb '+ status +', '+ dl.group +'</small>',
long_message_preview: dl.group,
icon_url: 'http://f.cl.ly/items/2M3s2V0M3B0i3h35282W/Cloud2go%208%20sep.%202012%2003:33.png'
message_level: 1 // background: 0 white, 1 green
},
function( result ) {
console.log( result )
console.log( 'notify ok' ) // visible in SABnzbd list
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment