FatRat

D-Bus Interface

A running FatRat offers a small interface on the D-Bus session bus. You can use it from scripts to add transfers. It is available if FatRat was built with D-Bus support.

ItemValue
Bussession bus
Service nameinfo.dolezel.fatrat
Object path/
Interfaceinfo.dolezel.fatrat

The examples use gdbus, which comes with GLib. qdbus, shipped with Qt, works too.

Methods

addTransfers

addTransfers(in s uris)

Desktop only. Opens the New transfer dialog with the links filled in. uris is a string of links separated by newlines. The method returns nothing. In fatrat-nogui it does nothing except write a note to the log; use addTransfersNonInteractive there.

gdbus call --session --dest info.dolezel.fatrat --object-path / \
  --method info.dolezel.fatrat.addTransfers "http://example.com/a.zip"

getQueues

getQueues() -> as

Returns the names of the queues, in order. The position of a queue in this list is the queueID for addTransfersNonInteractive, counting from 0.

gdbus call --session --dest info.dolezel.fatrat --object-path / \
  --method info.dolezel.fatrat.getQueues

A new installation answers (['Main queue'],).

addTransfersNonInteractive

addTransfersNonInteractive(in s uris, in s target, in s className, in i queueID)

Adds transfers without showing any dialog. Works with the desktop and with fatrat-nogui. The call returns nothing, so you cannot tell whether it worked. To get the result, use addTransfersChecked, which takes the same arguments.

uris
The links. They are separated by newlines, or by any whitespace if you set "Links in a list are separated by" to "whitespace characters" in the desktop settings.
target
The destination: a directory for downloads, or a URL for uploads.
className
The transfer type. Use auto to let FatRat choose from the first link: it tries the download types first, then the upload types using target. Other values include GeneralDownload (HTTP(S), FTP(S) and SFTP downloads), TorrentDownload (BitTorrent), MetalinkDownload (Metalink files) and FtpUpload (FTP(S) and SFTP uploads), and the transfer types that installed extensions add.
queueID
The position of the queue, counting from 0 (see getQueues). The first queue is 0.
gdbus call --session --dest info.dolezel.fatrat --object-path / \
  --method info.dolezel.fatrat.addTransfersNonInteractive \
  "http://example.com/a.zip" "/home/me/Downloads" auto 0

If the links are empty, the queue number is out of range or the type is unknown, FatRat writes the reason to its log and adds nothing.

addTransfersChecked

addTransfersChecked(in s uris, in s target, in s className, in i queueID) -> s

The same as addTransfersNonInteractive, but it returns a string: an empty string if all the transfers were added, or a message that says what went wrong. If a link in the middle of the list fails, the links before it have already been added.

gdbus call --session --dest info.dolezel.fatrat --object-path / \
  --method info.dolezel.fatrat.addTransfersChecked \
  "http://example.com/a.zip" "/home/me/Downloads" auto 0

It answers ('',) on success, and for example ('queueID is out of range',) when the queue number is wrong.

To manage transfers afterwards, and for a richer way to add them, see REST API.