SABnzbd

Wiki

User Manual FAQ Contact Introduction Installation Configuration Scripts Advanced Topics Extensions for SABnzbd

Incorrect or missing information? Notification Scripts

SABnzbd can run a user-provided script to be executed when a notification needs to be sent. In Config->Notifications you can specify for which type of notifications the script should be executed.

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.


Parameters

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. "job name").

Position Description
1 Type of notification
  • startup = Startup/Shutdown
  • download = Added NZB
  • pp = Post-processing started
  • complete = Job finished
  • failed = Job failed
  • warning = Warning
  • error = Error
  • disk_full = Disk full
  • queue_done = Queue finished
  • new_login = User logged in
  • other = Other Messages
2 The title of the notification in the user's language
3 The notification message
Environment variable:
SAB_NOTIFICATION_PARAMETERS
Parameters (can be specified in Config->Notifications)

When all went well, SABnzbd expects exit code 0. If an error occurred or something else than 0 is returned, the output will be shown to the user as an error.


Example Python script

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

import os
import sys
try:
    (scriptname, notification_type, notification_title, notification_text) = sys.argv
except:
    print("No commandline parameters found")
    sys.exit(1)

parameters = os.environ.get("SAB_NOTIFICATION_PARAMETERS")

# continue script

# Your code goes here

# Success code
sys.exit(0)