Giganews special deals
Supernews special deals
Incorrect or missing information? Post-processing scripts
SABnzbd can run a user-provided post-processing scripts. The scripts can be associated with a job entry when adding the job manually, via category or during downloading. Scripts can also be run as an end-of-queue event. A post-processing script will only run when the job has completed without errors. If you want to always run the script, you need to disable the option Post-Process Only Verified Jobs.
Scripts can be Python scripts, bash scripts and BAT scripts. All scripts must be located in the scripts-directory, that can be specified in Config->Folders. 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 console output of the script is captured by SABnzbd and is saved in the so called "Script Log" which can be opened from the history details. The output will be added to the (optional) notification email and can be examined in the History page.
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) as
Exit(...) in the History. By default the job will not be flagged as failed in case the exit code is non-zero. In Config->Switches there is the option to let a non-zero code mark the job as failed.
Example scripts are included in the
scripts directory of your SABnzbd installation and are shown at the end of this page.
The script will receive the parameters described below. Use
%1 in Windows scripts and
$1 in Unix scripts. Note that on Windows the input parameters are surrounded by quotes (e.g.
Much more information is available to scripts via environment variables, see below!
|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)|
|6||Group that the NZB was posted in e.g. alt.binaries.x|
|7||Status of post processing.
|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
Your script can get extra information via environment variables:
|SAB_SCRIPT||The name of the current script|
|SAB_NZO_ID||The unique ID assigned to the job|
|SAB_FINAL_NAME||The name of the job in the queue and of the final folder|
|SAB_FILENAME||The NZB filename (after grabbing from the URL)|
|SAB_COMPLETE_DIR||The whole path to the output directory of the job|
|SAB_PP_STATUS||Was post-processing succesfully completed (repair and/or unpack, if enabled by user)|
|SAB_CAT||What category was assigned|
|SAB_BYTES||Total number of bytes|
|SAB_BYTES_TRIED||How many bytes of the total bytes were tried|
|SAB_BYTES_DOWNLOADED||How many bytes were recieved (can be more than tried, due to overhead)|
|SAB_DUPLICATE||Was it detected as duplicate|
|SAB_UNWANTED_EXT||Were there unwanted extensions|
|SAB_OVERSIZED||Was the job over the user's size limit|
|SAB_PASSWORD||What was the password supplied by the NZB or the user|
|SAB_ENCRYPTED||Was the job detected as encrypted|
|SAB_STATUS||Current status (completed/failed/running)|
|SAB_FAIL_MSG||If job failed, why did it fail|
|SAB_AGE||Average age of the articles in the post|
|SAB_URL||URL from which the NZB was retrieved|
|SAB_AVG_BPS||Average bytes/second speed during active downloading|
|SAB_DOWNLOAD_TIME||How many seconds did we download|
|SAB_PP||What post-processing was activated (download/repair/unpack/delete)|
|SAB_REPAIR||Was repair selected by user|
|SAB_UNPACK||Was unpack selected by user|
|SAB_FAILURE_URL||Provided by some indexers as alternative NZB if download fails|
|SAB_PRIORITY||Priority set by user|
|SAB_GROUP||Newsgroup where (most of) the job's articles came from|
|SAB_VERSION||The version of SABnzbd used|
v2.3.1+ Enviroment variables below were added in SABnzbd 2.3.1.
|SAB_ORIG_NZB_GZ||Path to the original NZB-file of the job. The NZB-file is compressed with gzip (
|SAB_PROGRAM_DIR||The directory where the current SABnzbd instance is located|
|SAB_PAR2_COMMAND||The path to the
|SAB_MULTIPAR_COMMAND||Windows-only (empty on other systems). The path to the MultiPar command on the system that SABnzbd uses|
|SAB_RAR_COMMAND||The path to the
|SAB_ZIP_COMMAND||The path to the
|SAB_7ZIP_COMMAND||The path to the
Example Python script using basic parameters
The get the parameters in python, you can do this: