User's pre-queue script

Available in 0.6.0+

You can choose to let SABnzbd run a script just before an NZB enters the queue.
This script will tell whether the NZB should be accepted or not and can modify some parameters.

There will be a single script only, to be set in Config->Switches (picked from the general script folder).
The sorting info is passed independent on the actual Sorting settings.
Only the SeasonSort method will be used for analysis.

The script sends results to the console.
If the script has an exit code other than 0, it's assumed the script failed and the NZB will be accepted.
Exit code 0 will make SABnzbd inspect the returned output.

Input parameters

All parameters (except 1) can be empty, meaning a default value.
1 : Name of the NZB (no path, no ".nzb")
2 : Post Processing (PP) flags: 0 = Download, 1 = +Repair, 2 = +Unpack, 3 = +Delete
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

Take note that on Windows, each parameter that contains a space will be embedded in quotes: "this example".
Season and episode are numerical strings, without leading 0.

The script can refuse or accept the NZB and it can also return alternative parameters.
When you want to manipulate the season parameters, you should assemble a new name and return a recognized format.

Return parameters

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 : Post Processing (PP) flags: 0 = Download, 1 = +Repair, 2 = +Unpack, 3 = +Delete
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)

SABnzbd uses the first 7 lines of output, so they should only contain proper data (or be empty).
Anything after line 7 is ignored.

The script can be anything that is considered "executable" by the operating system.
So on Windows is most likely a CMD or BAT file.
On Linux is might be a shell script; make sure you set the X bit.

Example of a Windows batch file that forces high priority on anything smaller than 2G.

@echo off
echo 1
echo.
echo.
echo.
echo.
if %6 LSS 2000000000 echo 1

Save it as file "size-checker.cmd" and put in the scripts folder.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License