User Scripts

SABnzbd can run a user-provided script to be executed when a job has completed without errors.

You can do whatever you like with such a script.

The script will receive the parameters described below. Use %1 in Windows scripts and $1 in Unix scripts.

Please note that in Windows the parameters will be enclosed in double quotes ("my name").
On Posix systems (OSX, Linux, Unix) the parameters will not have quotes at all.

1 The final directory of the job (full path)
2 The original name of the NZB file
3 Clean version of the job name (no path info and ".nzb" removed)
4 Indexer's report number (if supported)
5 User-defined category
6 Group that the NZB was posted in e.g. alt.binaries.x
7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21, -1=failed download
8 URL to be called when job failed (if provided by the server, it is always sent, so check parameter 7!) The URL is provided by some indexers as the X-DNZB-Failure header.2

All parameters are properly quoted so that they may contain embedded spaces.

The "return" code that your script itself returns should be 0 if all went well or non-zero if errors occurred. If the return code is something else than 0, SABnzbd's History will show that return code (also known as exit code) in green surrounded by "Exit(…)".

The console output of the script is captured by SABnzbd and is saved in the so called "Script Log": to see that log, in the History overview, click on the "More" after the green text on the right hand side .
The file will be added to the (optional) notification email and can be examined in the History page.

A post-processing script will only run when the job has completed without errors.
If you want to run the script always, you need to disable the option "Post-Process Only Verified Jobs".

A script can return an exit code. SABnzbd will show a non-zero code in the download report, but the job will not be flagged as failed.
Note: Release 0.8.0 has an option in Config->Switches to let a non-zero code mark the job as failed.

All scripts must be located in the script-directory, that can be specified in Config->Directories. Furthermore, the script must be executable. On Linux this means the x-bit must be on. On Windows, the requirement is that the script's extension is listed in your system's PATHEXT environment variable.

The scripts can be used in these contexts:

  • Associated with a job entry on the Main page
  • Changed for a job on the Queue page
  • Associated with a user-defined category
  • Associated with the empty-queue event on the Queue page

Example Python script

The get the parameters in python, you can do this:

import sys
    (scriptname,directory,orgnzbname,jobname,reportnumber,category,group,postprocstatus,url) = sys.argv
        # are we testing only?
        directory = sys.argv[1]
        print "No commandline parameters found"

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