Sab starts the scripts and feeds it parameters like this:
Running pre-queue script ['/home/username/.ppdir/pre-queue.sh', 'ubuntu 11.04', '3', '', '', '', '1579198044', 'alt.binaries.boneless alt.binaries.misc', '', '', '', '']
All parameters are translated into $x (where x is the number of paramater, like $1 here is ubuntu 11.04, the name of the nzb-file)
Here are all parameters and their numbers: http://wiki.sabnzbd.org/user-pre-queue-script
Now you can use this input to alter things before it enters the queue. Like setting a category. When downloading a movie from a 'normal' indexsite like binsearch, sab doesn't know by itself its a movie. But when the group is alt.binaries.movies, it will be a movie 99% of the times something is posted in that group. The same goes for ebooks, tvshows, playstation 3 etc. So if parameter 7 ($7) contains movie, you'll want to change categorie to movie. In 5.x this couldn't be automated. But now it can. An example script, this script will set category to specified if a word is found in the group (like alt.binaries.movies will set category to movies, because movie is found):
Code: Select all
#!/usr/bin/env bash
#
# NZB set category Script by Mar2zz v0.1
# input (this is what sabnzbd feeds to this script)
# All parameters (except 1) can be empty, meaning a default value.
# 1 : Name of the NZB (no path, no ".nzb")
# 2 : PP (0, 1, 2 or 3)
# 3 : Category
# 4 : Script (no path)
# 5 : Priority (-100, -1, 0 or 1 meaning Default, Low, Normal, High)
# 6 : Size of the download (in bytes)
# 7 : Group list (separated by spaces)
# 8 : Show name
# 9 : Season (1..99)
# 10 : Episode (1..99)
# 11: Episode name
# outputparams (what this script tells sabnzbd)
# The script writes the results to the console, each parameter on a separate line.
# Each parameter (except 1) can be an empty line, meaning the original value.
# 1 : 0=Refuse, 1=Accept
# 2 : Name of the NZB (no path, no ".nzb")
# 3 : PP (0, 1, 2 or 3)
# 4 : Category
# 5 : Script (basename)
# 6 : Priority (-100 -2, -1, 0 or 1, meaning Default, Paused, Low, Normal, High )
# 7 : Group to be used (in case your provider doesn't carry all groups and there are multiple groups in the NZB)
### if a word between *'s is found in the groups the category will be changed to the one that's set.
case $7 in
*movie*)
cat=movies
;;
*book*)
cat=ebooks
;;
*teevee*)
cat=tvshows
;;
*multimedia*)
cat=tvshows
;;
*)
cat=$3
;;
esac
### now tell sab what to do with nzb (note, this must be echoed in specific order, every command on a new line)
echo "1" # tell sab to use this .nzb
echo $1 # keep original name for nzb
echo $2 # keep original pp
echo "$cat" #set category to new if one of the parameters was found
The same stuff can be done to nzb names. Just echo $1 and do something to it. echo $1 | sed 's/.par//' will always remove .par from nzbnames (sometimes that happens).
It can be done to all 11 parameters, so it's possible to cover everything. Very nice feature! Thank you devs! sab > {insert random nzb-program} (always has been)
edit:
Also, here is code that notifies XBMC when an nzb enters the queue, similar to what sickbeard and couchpotato can do.
Code: Select all
### If you want to be notified on snatched downloads in XBMC, please specify your xbmc credentials:
### Note: curl needs to be installed for this (sudo apt-get install curl)
xbmc_notify () {
xbmc_host=xbmc # hostname or ipadres
xbmc_port=8080
xbmc_user=xbmc # if user is not set delete '$xbmc_user:$pass@' in url below
xbmc_pass=xbmc # if password is not set delete ':$pass@' in url below
if which curl > /dev/null
then
queued=$(echo $1 | sed -e 's/ /%20/g')
curl -s "http://$xbmc_user:$xbmc_pass@$xbmc_host:$xbmc_port/xbmcCmds/xbmcHttp/?command=ExecBuiltIn(Notification(Snatched,$queued))" | xargs echo > /dev/null
fi
}
xbmc_notify # comment this if you do not want to use xbmc-notify