![]() If your script consists or multiple files, put the script and all related files into a subdirectory within ppscripts-directory. exit ( POSTPROCESS_SUCCESS ) Script consisting of multiple files fromtimestamp ( int ( entry )), entry )) f. write ( '%s \t %s \t %s \n ' % ( entry, datetime. If len ( log ) > 0 : f = open ( '%s/_postprocesslog.txt' % os. Log = postqueue # Now iterate through entries and save them to the output file postqueue ( 10000 ) # Get field 'Log' from the first post-processing job The only parameter tells how many log-entries to return as maximum. Server = ServerProxy ( rpcUrl ) # Call remote method 'postqueue'. RpcUrl = % ( username, password, host, port ) # Create remote server object # NZBGet passes all configuration options to post-processing script as # First we need to know connection info: host, port, username and password of NZBGet server. # The first item in the list is current job. # and call method "postqueue", which returns the list of post-processing job. POSTPROCESS_SUCCESS = 93 POSTPROCESS_ERROR = 94 # To get the post-processing log we connect to NZBGet via XML-RPC Import os import sys import datetime from xmlrpclib import ServerProxy # Exit codes used by NZBGet for testing version: nzbget-11.0-testing-r620.NZBGet version is passed in env-var NZBOP_VERSION. See post-processing script EMail.py for the reference implementation. All messages printed by the script are saved to NZBGet log and are seen in web-interface on Messages tab. User may close the progress dialog but the script continues running in the background. The script must exit with one of predefined exit codes indicating success (exit code 93) or failure (exit code 94). exit ( COMMAND_SUCCESS ) ĭuring execution of the script NZBGet presents a special dialog showing script output. exit ( COMMAND_ERROR ) if test_mode : print ( ' Test connection.' ) sys. get ( 'NZBCP_COMMAND' ) test_mode = command = 'ConnectionTest' if command != None and not test_mode : print ( ' Invalid command ' command ) sys. In the next example we define a new section with two options:ĬOMMAND_SUCCESS = 93 COMMAND_ERROR = 94 # Check if the script is executed from settings page with a custom commandĬommand = os. The options are then made available on the settings page for user to configure.Įvery option belongs to a configuration section. To avoid hard-coding of these data in the script NZBGet allows the script to define the required options in the configuration section. The user needs to configure the script with options such as SMTP-Server host, port, login and password. Let’s say we are writing a script to send E-Mail notification. The script definition can be longer than 10KB but it must start within first 10KB of the script. Put the script definition at the beginning of the script. NOTE: for performance reasons NZBGet scans only first 10KB of the script. If a signature is found, the file is considered to be a script. NZBGet scans all files in script-directory (option ScriptDir) and all files in first-level sub-directories looking for script definition signature # NZBGET SCRIPT. The long description is separated with an empty line. This should be a short one sentence description. The short description stays near the script name in the edit download dialog. This line is a short description of what our pp-script does. The definition starts with one of the possible signatures depending on the purpose of the script: Configuration definitionĮach script must have a configuration definition. For specific information about certain kinds of scripts please also read the dedicated articles. This article describes how to write extension scripts in general. Select a script to review or change its options (if it has any). Menu at the left of page should list all extension scripts found in ScriptDir. Then go to settings tab in web-interface (if you were already on settings tab switch to downloads tab and then back to settings tab to reread the list of available scripts from the disk). To make a script available in NZBGet put the script into this directory. Option ScriptDir defines the location of extension scripts. On certain events the scripts are executed, they receive information about event, do certain work and can communicate with NZBGet to give it instructions for further processing. NZBGet provides documented entry points for scripts. The core functionality of NZBGet can be extended using extension scripts. ![]()
0 Comments
Leave a Reply. |