RPC API reference

From NZBGet
Jump to: navigation, search

Contents

About XML-RPC and JSON-RPC in NZBGet

Status of this document

The document describes methods available in NZBGet version 12.0 and later. The document is updated after a new stable version is out. Current testing version may have methods or fields not described here; these methods or fields may change before getting stable. If you need information for older NZBGet version please see a historical article RPC API reference 0.6.0-12.0.

Protocols

NZBGet supports XML-RPC, JSON-RPC and JSON-P-RPC. RPC-protocols allow to control the program from other applications. Many programming languages have libraries, which make the usage of XML-RPC, JSON-RPC and JSON-P-RPC very simple. The implementations of all three protocols in NZBGet are equal: all methods are identical. You may choose the protocol, which is better supported by your programming language.

The RPC server uses HTTP basic authentication with username and password from server's configuration file. The URL would be something like:

Versions prior 11.0 used hardcoded name "nzbget"; since version 11.0 the username can be changed.

Security warning: HTTP authentication is not secure. Although the password is encoded using Base64 it is not encrypted. For secure communication use HTTPS (needs to be explicitly enabled in NZBGet settings by user).

Features and limitations

  • Multicalls are supported for XML-RPC and not supported for JSON-RPC.
  • Introspection is not supported.
  • Only positional parameters are supported in JSON-RPC. Named parameters are not supported.
  • Each call to JSON-P-RPC has one additional parameter - the name of callback-function. This parameter must be named "callback" and must be passed first (before any other parameters).

Method "version"

Signature:

string version() 

Request the version-string of server. This method is equivalent for command "nzbget -V".

Return value: Version string.

Method "status"

Signature:

struct status() 

Request for current status (summary) information. Parts of informations returned by this method can be printed by command "nzbget -L".

Return value: This method returns a structure with following fields:

Field Type Description
RemainingSizeLo int Remaining size of all entries in download queue, in bytes. This field contains the low 32-bits of 64-bit value
RemainingSizeHi int Remaining size of all entries in download queue, in bytes. This field contains the high 32-bits of 64-bit value
RemainingSizeMB int Remaining size of all entries in download queue, in megabytes.
DownloadedSizeLo int Amount of data downloaded since server start, in bytes. This field contains the low 32-bits of 64-bit value
DownloadedSizeHi int Amount of data downloaded since server start, in bytes. This field contains the high 32-bits of 64-bit value
DownloadedSizeMB int Amount of data downloaded since server start, in megabytes.
DownloadRate int Current download speed, in Bytes per Second.
AverageDownloadRate int Average download speed since server start, in Bytes pro Second.
DownloadLimit int Current download limit, in Bytes pro Second. The limit can be changed via method "rate". Be aware of different scales used by the method rate (Kilobytes) and this field (Bytes).
ThreadCount int Number of threads running. It includes all threads, created by the program, not only download-threads.
PostJobCount int Number of Par-Jobs or Post-processing script jobs in the post-processing queue (including current file).
ParJobCount int Deprecated, use PostJobCount instead.
UrlCount int Number of URLs in the URL-queue (including current file).
UpTimeSec int Server uptime in seconds.
DownloadTimeSec int Server download time in seconds.
ServerStandBy bool "False" - there are currently downloads running, "True" - no downloads in progress (server paused or all jobs completed).
DownloadPaused bool "True" if download queue is paused via first pause register (soft-pause).
Download2Paused bool "True" if download queue is paused via second pause register (manual pause)
ServerPaused bool Deprecated, use DownloadPaused instead.
PostPaused bool "True" if post-processor queue is currently in paused-state.
ScanPaused bool "True" if the scanning of incoming nzb-directory is currently in paused-state.
ServerTime int Current time on computer running NZBGet. Time is in C/Unix format (number of seconds since 00:00:00 UTC, January 1, 1970).
ResumeTime int Time to resume if set with method "scheduleresume". Time is in C/Unix format.
FeedActive bool "True" if any RSS feed is being fetched right now.
NewsServers array Status of news-servers. See below.

Field NewsServers is an array of structures with following fields:

Field Type Description
ID int Server number in the configuration file. For example "1" for server defined by options "Server1.Host", "Server1.Port", etc.
Active bool True if server is in active state (enabled). Active doesn't mean that the data is being downloaded from the server right now. This only means the server can be used for download (if there are any download jobs).

Method "pausedownload"

Signature:

bool pausedownload() 

Pause download queue on server. This method is equivalent for command "nzbget -P".

Return value: Always "True".

Method "pausedownload2"

Signature:

bool pause2()

Pause download queue on server via second pause register. This method is equivalent for command "nzbget -P D2".

Options "ParPauseQueue", "PostPauseQueue", "TaskX.Command=PauseDownload" and "TaskX.Command=UnpauseDownload" use the so called first pause-register. To not interfere with the pause-state maintained by these commands the manual pause performed by user should use the second pause register.

Return value: Always "True".

Method "resumedownload"

Signature:

bool resume() 

Resume (previously paused) download queue on server. This method is equivalent for command "nzbget -U".

Return value: Always "True".

Method "resumedownload2"

Signature:

bool resume() 

Resume (previously paused) download queue on server via second pause register. This method is equivalent for command "nzbget -U D2".

Return value: Always "True".

Method "shutdown"

Signature:

bool shutdown() 

Shutdown server. This method is equivalent for command "nzbget -Q".

Return value: Always "True".

Method "rate"

Signature:

bool rate(int Limit) 

Set download speed limit. This method is equivalent for command "nzbget -R <Limit>".

Parameters:

  • Limit - new download speed limit in KBytes/second. Value "0" disables speed throttling.

Return value: "True" on success or "False" on failure.

Method "log"

Signature:

array log(int IDFrom, int NumberOfEntries) 

Request for screen-log. This method is similar to command "nzbget -G <NumberOfEntries>" but returns more information and can return lines from the specified log-ID. This method returns entries from server's screenlog-buffer. The size of this buffer is limited and can be set via option "LogBufferSize" in server's configuration file. Which messages should be saved to screenlog and which should be saved to log-file can be set via server's options InfoTarget, WarningTarget, ErrorTarget and DebugTarget in server's configuration file.

Parameters:

  • IDFrom - The first ID to be returned.
  • NumberOfEntries - Number of entries, which should be returned.

NOTE: only one parameter - either IDFrom or NumberOfEntries - can be specified. The other parameter must be "0".

TIP: If your application stores log-entries between subsequential calls to method log(), the usage of parameter IDFrom is recommended, since it reduces the amount of transferred data.

Return value: This method returns an array of structures with following fields:

Field Type Description
ID int ID of log-entry.
Kind string Class of log-entry, one of the following strings: INFO, WARNING, ERROR, DEBUG.
Time int Time in C/Unix format (number of seconds since 00:00:00 UTC, January 1, 1970).
Text string Log-message.

NOTE: if there are no entries for requested criteria, an empty array is returned.

Method "listfiles"

Signature:

struct[] listfiles(int IDFrom, int IDTo, int NZBID) 

Request for file's list. This method is similar to command "nzbget -L", but returns much more data for every file and does not return summary information (which can be requested via method status).

Parameters:

  • IDFrom - The first ID of file range to be returned.
  • IDTo - The last ID of file range to be returned.
  • NZBID - The NZBID of the group to be returned. This parameter is available since version 9.0.

If IDFrom and IDTo are submitted, the parameter NZBID must be 0. If NZBID is submitted, the parameters IDFrom and IDTo must be 0.

To get the list of all files from all groups set all parameters to 0;

Return value: This method returns an array of structures with following fields:

Field Type Description
ID int ID of file.
NZBID int ID of NZB-file.
NZBFilename string Name of nzb-file. The filename could include fullpath (if client sent it by adding the file to queue).
NZBName string The name of nzb-file without path and extension. Ready for user-friendly output.
NZBNicename string Deprecated, use NZBName instead.
Subject string Subject of article (read from nzb-file).
Filename string Filename parsed from subject. It could be incorrect since the subject not always correct formated. After the first article for file is read, the correct filename is read from article body.
FilenameConfirmed bool "True" if filename was already read from article's body. "False" if the name was parsed from subject. For confirmed filenames the destination file on disk will be exactly as specified in field "filename". For unconfirmed filenames the name could change later.
DestDir string Destination directory for output file.
FileSizeLo int Filesize in bytes, Low 32-bits of 64-bit value.
FileSizeHi int Filesize in bytes, High 32-bits of 64-bit value.
RemainingSizeLo int Remaining size in bytes, Low 32-bits of 64-bit value.
RemainingSizeHi int Remaining size in bytes, High 32-bits of 64-bit value.
Paused bool "True" if file is paused.
PostTime int Date/time when the file was posted to newsgroup (Time is in C/Unix format).
Priority int Priority of the file.
ActiveDownloads int Number of active downloads for the file. With this filed can be determined what file(s) is (are) being currently downloaded.

NOTE: it is very unlikely to see a file larger than 2 GB in newsgroups. Large files are always posten in parts (mostly as rar-archives with part-size not greather than 100 MB). Therefore it is almoust safe to ignore fields FileSizeHi and RemainingSizeHi if your programming language does not support 64-bit integers.

Method "listgroups"

Signature:

struct[] listgroups() 

Request for groups' list. This method returns summary information for each file group. A group is a collection of files from one nzb-file.

Return value: This method returns an array of structures with following fields:

Field Type Description
NZBID int ID of NZB-file.
FirstID int ID of the first file in download queue, belonging to the group.
LastID int ID of the last file in download queue, belonging to the group.
NZBFilename string Name of nzb-file, this file was added to queue from. The filename could include fullpath (if client sent it by adding the file to queue).
NZBName string The name of nzb-file without path and extension. Ready for user-friendly output.
NZBNicename string Deprecated, use NZBName instead.
DestDir string Destination directory for output file.
Category string Category for group or empty string if none category is assigned.
FileSizeLo int Initial size of all files in group in bytes, Low 32-bits of 64-bit value.
FileSizeHi int Initial size of all files in group in bytes, High 32-bits of 64-bit value.
FileSizeMB int Initial size of all files in group in megabytes.
RemainingSizeLo int Remaining size of all (remaining) files in group in bytes, Low 32-bits of 64-bit value.
RemainingSizeHi int Remaining size of all (remaining) files in group in bytes, High 32-bits of 64-bit value.
RemainingSizeMB int Remaining size of all (remaining) files in group in megabytes.
PausedSizeLo int Size of all paused files in group in bytes, Low 32-bits of 64-bit value.
PausedSizeHi int Size of all paused files in group in bytes, High 32-bits of 64-bit value.
PausedSizeMB int Size of all paused files in group in megabytes.
FileCount int Initial number of files in group.
RemainingFileCount int Remaining (current) number of files in group.
RemainingParCount int Remaining (current) number of par-files in group.
MinPostTime int Date/time when the oldest file in the group was posted to newsgroup (Time is in C/Unix format).
MaxPostTime int Date/time when the newest file in the group was posted to newsgroup (Time is in C/Unix format).
MinPriority int The lowest priority of files in the group. The files in the group can have different priorities.
MaxPriority int The highest priority of files in the group. The files in the group can have different priorities.
ActiveDownloads int Number of active downloads in the group. With this filed can be determined what group(s) is (are) being currently downloaded. In most cases only one group is downloaded at a time however more that one group can be downloaded simultaneously when the first group is almost completely downloaded.
TotalArticles int Total number of articles in all files of the group.
SuccessArticles int Number of successfully downloaded articles.
FailedArticles int Number of failed article downloads.
Health int Current health of the group, in permille. 1000 means 100.0%. The health can go down below this valued during download if more article fails. It can never increase (unless merging of groups). Higher values are better. See forum topic Download health monitoring.
CriticalHealth int Calculated critical health of the group, in permille. 1000 means 100.0%. The critical health is calculated based on the number and size of par-files. Lower values are better.
DupeKey string Duplicate key. See RSS#Duplicates.
DupeScore int Duplicate score. See RSS#Duplicates.
DupeMode string Duplicate mode. One of SCORE, ALL, FORCE. See RSS#Duplicates.
Parameters array Post-processing parameters for group. See below.
ParStatus, UnpackStatus, MoveStatus, ScriptStatus, DeleteStatus, MarkStatus, ScriptStatuses string These fields have meaning only for a group which is being currently post-processed. For description see method #history.
ServerStats array Per news-server download statistics. For description see method #history.

Field Parameters is an array of structures with following fields:

Field Type Description
Name string Name of post-processing parameter.
Value string Value of post-processing parameter.

NOTE: There is no field Status in the group, which would have a string like "Downloading" or "Paused". This information should be obtained from other fields. See forum topic Status of group with API.

Method "urlqueue"

Signature:

struct[] urlqueue() 

Request for list of items in URL-queue.

Return value: This method returns an array of structures with following fields:

Field Type Description
ID int ID of URL in the queue.
NZBFilename string Name of nzb-file, if it was passed when the URL was added to queue. May be empty string.
URL string URL to download file from.
Name string The name of nzb-file without path and extension (if it was passed) or a part of the URL. Ready for user-friendly output.
Category string Category assigned to nzb-file when it is added to download queue (after downloading from URL). If the category is empty the category is read from HTTP-response which is usually returned from server hosting the nzb-file.
Priority int Priority assigned to nzb-file when it is added to download queue (after downloading from URL).

Since the nzb-files are usually downloaded from URLs very fast, there are no commands provided to manage the URL-queue (delete, move items).

Method "postqueue"

Signature:

struct[] postqueue(int NumberOfLogEntries) 

Request for list of items in post-processor-queue.

Parameters:

  • NumberOfLogEntries - Number of log-entries, saved from post-process-script, which should be returned for the top (currently processing item in post-processor-queue).

Return value: This method returns an array of structures with following fields:

Field Type Description
NZBID int ID of NZB-file.
InfoName string Text with user-friendly formatted name of item. For par-jobs consists of NZBNicename and of ParFilename. For script-jobs is equal to NZBNicename.
NZBFilename string Name of nzb-file, this file was added to queue from. The filename could include fullpath (if client sent it by adding the file to queue).
NZBName string The name of nzb-file without path and extension. Ready for user-friendly output.
NZBNicename string Deprecated, use NZBName instead.
DestDir string Destination directory for output file.
ParFilename string Name of main par-file. For script-jobs this field is empty.
Stage string Indicate current stage of post-job. On of the predefined text constants: QUEUED, LOADING_PARS, VERIFYING_SOURCES, REPAIRING, VERIFYING_REPAIRED, EXECUTING_SCRIPT, FINISHED. The last constant (FINISHED) is very unlikely, because the post-jobs is deleted from queue right after it is completed. If nzb-file has no par-files or par-check is disabled the par-stages (LOADING_PARS..VERIFYING_REPAIRED) are skipped. If postprocess-script is not defined in program's options the stage EXECUTING_SCRIPT is skipped.
ProgressLabel string Text with short description of current action in post processor. For example: "Verifying file myfile.rar".
FileProgress int Compeleting of current file. A number in the range 0..1000. Divide it to 10 to get percent-value.
StageProgress int Compeleting of current stage. A number in the range 0..1000. Divide it to 10 to get percent-value.
TotalTimeSec int Number of seconds this post-job is beeing processed (after it first changed the state from QUEUED).
StageTimeSec int Number of seconds the current stage is beeing processed.
Log array Array of structs with log-messages. For description of struct see method log.

NOTE: postprocessor executes only one job at a time - the first (top) job in post-queue. Fields ProgressLabel, FileProgress, StageProgress, TotalTimeSec, StageTimeSec and Log have meaning only for that job.

Method "history"

Signature:

struct[] history() 

Request for list of items in history-list.

Return value: This method returns an array of structures with following fields:

Field Type Description
ID int ID of history item.
NZBID int ID of history item. NOTE: deprecated, use ID instead.
Kind string Kind of history item. One of the predefined text constants: NZB for nzb-files; URL for failed URL downloads. NOTE: successful URL-downloads results in adding files to download queue, a success-history-item is not created in this case.
NZBFilename string Name of nzb-file, this file was added to queue from. The filename could include fullpath (if client sent it by adding the file to queue).
Name string The name of nzb-file or info-name of URL, without path and extension. Ready for user-friendly output.
NZBNicename string Deprecated, use Name instead.
URL string URL (only for URL-downloads).
DestDir string Destination directory for output files.
Category string Category for group or empty string if none category is assigned.
FileSizeLo int Initial size of all files in group in bytes, Low 32-bits of 64-bit value.
FileSizeHi int Initial size of all files in group in bytes, High 32-bits of 64-bit value.
FileSizeMB int Initial size of all files in group in megabytes.
FileCount int Initial number of files in group.
RemainingFileCount int Number of parked files in group. If this number is greater than "0", the history item can be returned to download queue using command "HistoryReturn" of method "editqueue".
HistoryTime int Date/time when the file was added to history (Time is in C/Unix format).
ParStatus string Result of par-check/repair. One of the predefined text constants: NONE, FAILURE, REPAIR_POSSIBLE, SUCCESS.
ScriptStatus string Result of post-processing script. One of the predefined text constants: NONE, UNKNOWN, FAILURE, SUCCESS.
UrlStatus string Result of URL-download (only for URL-downloads). One of the predefined text constants: UNKNOWN, FAILURE, SUCCESS.
Parameters array Post-processing parameters for group. For description of struct see method listgroups.
Log array Log-messages added to history item by a post-processing script. For description of struct see method log.

Method "editqueue"

Signature:

bool editqueue(string Command, int Offset, string EditText, int[] IDs) 

Pause/unpause/move/delete files or groups. This method is equivalent for command "nzbget -E <args>".

Parameters:

  • Command - one of the following commands:
Command Description
FileMoveOffset Move files to Offset relative to the current position in queue.
FileMoveTop Move files to top of queue.
FileMoveBottom Move files to bottom of queue.
FilePause Pause files.
FileResume Resume (unpause) files.
FileDelete Delete files.
FilePauseAllPars Pause only pars (does not affect other files).
FilePauseExtraPars Pause only pars, except main par-file (does not affect other files).
FileSetPriority Set file priority.
FileReorder Reorder files in the group. The list of IDs may include files only from one group.
GroupMoveOffset Move groups to Offset relative to the current position in queue.
GroupMoveTop Move groups to top of queue.
GroupMoveBottom Move groups to bottom of queue.
GroupPause Pause groups.
GroupResume Resume (unpause) groups.
GroupDelete Delete groups.
GroupPauseAllPars Pause only pars (does not affect other files).
GroupPauseExtraPars Pause only pars, except main par-file (does not affect other files).
GroupSetPriority Set priority for all files in group.
GroupSetCategory Set category for group.
GroupMerge Merge groups.
GroupSetParameter Set post-processing parameter for group.
GroupSetName Rename group.
PostMoveOffset Move post-job to Offset relative to the current position in queue.
PostMoveTop Move post-job to top of queue.
PostMoveBottom Move post-job to bottom of queue.
PostDelete Delete post-jobs.
HistoryDelete Delete history items.
HistoryReturn Return history items back to download queue.
HistoryProcess Post-process history items again.
  • Offset - offset for commands FileMoveOffset and GroupMoveOffset. For all other commands must be "0".
  • EditText - additional parameter for commands FileSetPriority, GroupSetPriority, GroupSetCategory, GroupSetParameter and GroupSetName. Although the commands FileSetPriority and GroupSetPriority require integer value for priority, the parameter must be transferred as string value. For all other commands must be empty string ("").
  • IDs - array of IDs (as integers). File-commands and group-command need ID of file. For group-commands ID of any file in this group can be used, for example field FirstID or LastID of group-structure (the using of LastID is preferred, because the file with first ID has more chances to be completed and deleted from queue before edit-command is received by the server). Post-commands need ID of post-jobs. History-commands need ID of History-items.

Return value: "True" on success or "False" on failure.

Method "append"

Signature:

bool append(string NZBFilename, string Category, int Priority, bool AddToTop, string Content,
      bool AddPaused, string DupeKey, int DupeScore, string DupeMode)

Add nzb-file to download queue. This method is equivalent for command "nzbget -A [T] -K <category> <filename>".

Parameters:

  • NZBFilename - name of nzb-file. Server uses the name to build destination directory. This name can contain full path or only filename.
  • Category - category for nzb-file. Can be empty string.
  • Priority - priority for nzb-file. 0 for "normal priority", positive values for high priority and negative values for low priority. Default priorities are: -100 (very low), -50 (low), 0 (normal), 50 (high), 100 (very high). This parameter exists since version 9.0.
  • AddToTop - "True" if the file should be added to the top of the download queue or "False" if to the end.
  • Content - content of nzb-file encoded with Base64. See #Examples;
  • AddPaused - "True" if the file should be added in paused state. This parameter is supported since version 12.0.
  • DupeKey - duplicate key for nzb-file. See RSS#Duplicates. This parameter is supported since version 12.0.
  • DupeScore - duplicate score for nzb-file. See RSS#Duplicates. This parameter is supported since version 12.0.
  • DupeMode - duplicate mode for nzb-file. See RSS#Duplicates. This parameter is supported since version 12.0.

Return value: "True" on success or "False" on failure.

Method "appendurl"

Signature:

bool appendurl(string NZBFilename, string Category, int Priority, bool AddToTop, string URL,
      bool AddPaused, string DupeKey, int DupeScore, string DupeMode)
bool appendurl(string NZBFilename, string Category, int Priority, bool AddToTop, string URL) 

Add URL to download queue. This method is similar to command "nzbget -A U [T] -K <category> <URL>".

Parameters:

  • NZBFilename - name of nzb-file. Server uses the name to build destination directory.
  • Category - category for nzb-file. Can be empty string.
  • Priority - priority for nzb-file. 0 for "normal priority", positive values for high priority and negative values for low priority. Default priorities are: -100 (very low), -50 (low), 0 (normal), 50 (high), 100 (very high).
  • AddToTop - "True" if the file should be added to the top of the URL queue or "False" if to the end.
  • URL - URL of nzb-file. It must be a complete URL starting with "http://". If the program was compiled with TLS/SSL support the protocol "https://" is also supported.
  • AddPaused - "True" if the file should be added in paused state. This parameter is supported since version 12.0.
  • DupeKey - duplicate key for nzb-file. See RSS#Duplicates. This parameter is supported since version 12.0.
  • DupeScore - duplicate score for nzb-file. See RSS#Duplicates. This parameter is supported since version 12.0.
  • DupeMode - duplicate mode for nzb-file. See RSS#Duplicates. This parameter is supported since version 12.0.

NOTE: The command returns immediately after adding the URL to URL-queue before the actual file is downloaded.

Return value: "True" on success or "False" on failure.

Method "writelog"

Signature:

bool writelog(string Kind, string Text) 

Append log-entry into server's log. This method is equivalent for command "nzbget -W <D|I|W|E|G> <text>".

Parameters:

  • Kind - Kind of log-message. Must be one of the following strings: INFO, WARNING, ERROR, DETAIL, DEBUG. Debug-messages are processed by server, only if it was compiled in debug-mode.
  • Text - Text to be added into log.

Return value: Always "True".

Method "scan"

Signature:

bool scan() 

Request rescanning of incoming directory for nzb-files. This method is equivalent for command "nzbget -S".

Return value: Always "True".

Method "config"

Signature:

struct[] config() 

Returns current configuration loaded into program. Please note that the configuration file on disk may differ from the loaded configuration. This may occur if the configuration file on disk was changed after the program was launched or the program may become some options passed via command line.

Return value: This method returns an array of structures with following fields:

Field Type Description
Name string Option name.
Value string Option value.

Notes:

  • For options with predefined possible values (yes/no, etc.) the values are returned always in lower case.
  • If the option has variable references (e. g. "${MainDir}/dst") the returned value has all variables substituted ("/home/user/downloads/dst").

Method "loadconfig"

Signature:

struct[] loadconfig() 

Reads configuration file from the disk.

Return value: This method returns an array of structures with following fields:

Field Type Description
Name string Option name.
Value string Option value.

Notes:

  • The option value is returned exactly as it is stored in the configuration file. For example it may contain variable references (e. g. "${MainDir}/dst").

Method "saveconfig"

Signature:

bool saveconfig(struct[] options) 

Saves configuration file to the disk.

Parameters:

  • options - array of structs
Field Type Description
Name string Option name.
Value string Option value.

Return value: "True" on success or "False" on failure.

Method "configtemplates"

Signature:

struct[] configtemplates() 

Reads NZBGet configuration file template from disk and extracts configuration sections from all post-processing files. This information is for example used by web-interface to build settings page.

Return value: This method returns an array of structures with following fields:

Field Type Description
Name string Post-processing script name. For example "videosort/VideoSort.py". This field is empty in the first record, which holds the config template of the program itself.
DisplayName string Nice post-processing name ready for displaying. For example "VideoSort".
Template string Content of the configuration template.

Examples

The most comprehensive example on using JSON-RPC with NZBGet is NZBGets built-in web-interface. Look at the javascript sources in directory webui.

Another comprehensive example is NZBGetWeb - old web-interface written in PHP for NZBGet versions prior 9.0. Look in download section for source code. Take into account that this application is not developed anymore and may not be fully compatible with actual NZBGet versions. Still it's a good source for PHP example.

Two following examples show how to interact with NZBGet from Python using XML-RPC.

Adding file to download queue

C:\>C:\Programme\Python25\python.exe
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from xmlrpclib import ServerProxy
>>> server = ServerProxy('http://nzbget:tegbzn6789@localhost:6789/xmlrpc')
>>> filename="C:\\ubuntu-7.10.nzb"
>>> in_file = open(filename, "r")
>>> nzbcontent = in_file.read()
>>> in_file.close()
>>> from base64 import standard_b64encode
>>> nzbcontent64=standard_b64encode(nzbcontent)
>>> server.append(filename, 'software', False, nzbcontent64)
True
>>>

Obtaining log from server

C:\>C:\Programme\Python25\python.exe
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from xmlrpclib import ServerProxy
>>> server = ServerProxy('http://nzbget:tegbzn6789@localhost:6789/xmlrpc')
>>> server.log(1, 0)
[{'Text': 'nzbget server-mode', 'Kind': 'INFO', 'ID': 1, 'Time': 1202409509}, 
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [1/131]', 
'Kind': 'INFO', 'ID': 2, 'Time': 1202409509}, 
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [2/131]', 
'Kind': 'INFO', 'ID': 3, 'Time': 1202409509}, 
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [3/131]', 
'Kind': 'INFO', 'ID': 4, 'Time': 1202409509}, 
{'Text': 'Downloading ubuntu-7.10\ubuntu-7.10-desktop-i386.part04.rar [4/131]', 
'Kind': 'INFO', 'ID': 5, 'Time': 1202409509}, 
{'Text': 'Pausing download', 'Kind': 'INFO', 'ID': 6, 'Time': 1202409513}]
>>>
Donation



Get NZBGet at SourceForge.net. Fast, secure and Free Open Source software downloads

Personal tools