rtorrent_rpc

class RTorrent[source]

RTorrent rpc client

rt = RTorrent('scgi://127.0.0.1:5000')
rt = RTorrent('scgi:///home/ubuntu/.local/rtorrent.sock')

If you are using ruTorrent or nginx scgi proxy, http(s) protocol are also supported

rt = RTorrent('http://127.0.0.1')

by default, /RPC2 path is used.

__init__(address: str, rutorrent_compatibility: bool = True)[source]
Parameters:
  • address – rtorrent rpc address

  • rutorrent_compatibility – compatibility for ruTorrent or flood.

rpc: ServerProxy

Underling xmlrpc.client.ServerProxy are exposed as instance property .rpc, you can use rt.rpc for direct rpc call.

jsonrpc: JSONRpc

a JSONRpc instance to send rpc request with json-rpc.

get_session_path() str[source]

get current rtorrent session path

add_torrent_by_file(content: bytes, directory_base: str, tags: Iterable[str] | None = None) None[source]

Add a torrent to the client by providing the torrent file content as bytes.

Note

rTorrent need some time to handle your torrent, there is a chance info_hash of the torrent you just added is not inoperable. In that case, you need wait some time after you just add a torrent.

Parameters:
  • content – The content of the torrent file as bytes.

  • directory_base – The base directory where the downloaded files will be saved.

  • tags – A sequence of tags associated with the torrent. Defaults to None. This argument is compatible with ruTorrent and flood.

stop_torrent(info_hash: str) None[source]

Stop and close a torrent.

Parameters:

info_hash (str) – The info hash of the torrent to be stopped.

Returns:

This function does not return anything.

Return type:

None

download_list() list[str][source]

get list of info hash for current downloads

property system: _SystemRpc

method call with system prefix

rt.system.listMethods(...)
system_list_methods() list[str][source]

get supported methods

property d: _DownloadRpc

method call with d prefix

rt.d.save_resume(...)
rt.d.open(...)
d_set_torrent_base_directory(info_hash: str, directory: str) None[source]

change base directory of a download.

you may need to stop/close torrent first.

d_save_resume(info_hash: str) None[source]

alias of d.save_resume

d_set_tags(info_hash: str, tags: Iterable[str]) None[source]

set download tags, work with flood and ruTorrent.

d_set_comment(info_hash: str, comment: str) None[source]

Set comment, work with flood and ruTorrent

d_set_custom(info_hash: str, key: str, value: str) int[source]

set custom key value pair on download

d_get_custom(info_hash: str, key: str) str[source]

get custom value by key, return empty str if key not set

d_tracker_send_scrape(info_hash: str, delay: Unknown) None[source]

force announce

d_add_tracker(info_hash: str, url: str, *, group: int = 0) None[source]

add a tracker to download

property t: _TrackerRpc

method call with t prefix

rt.t.is_enabled(...)
t_enable_tracker(info_hash: str, tracker_index: int) None[source]

enable a tracker of download

t_disable_tracker(info_hash: str, tracker_index: int) None[source]

disable a tracker of download

property f: _FileRpc

method call with d prefix

rt.f.multicall("<info_hash>", "", "f.path=")
class _DownloadRpc[source]

this is not a real class, it’s a typing protocol for rpc typing

save_resume(info_hash: str) None[source]

save resume data

multicall2(_: Literal[''], view: str, *commands: str) Iterable[Any][source]

run multiple rpc calls

property directory_base: _DirectoryRpc

base directory

property directory: _DirectoryRpc
__init__(*args, **kwargs)
class _SystemRpc[source]

this is not a real class, it’s a typing protocol for rpc typing

multicall(commands: list[MultiCall]) Any[source]

run multiple rpc calls

__init__(*args, **kwargs)
class _TrackerRpc[source]

this is not a real class, it’s a typing protocol for rpc typing

multicall(info_hash: str, _: Literal[''], *commands: str) Iterable[Any][source]

run multiple rpc calls

is_enabled(tracker_id: str) int[source]

tracker_id is in format {info_hash}:t{index}

__init__(*args, **kwargs)
class JSONRpc[source]

this class is exposed as RTorrent(...).jsonrpc, you do not need to construct it by yourself.

__init__(address: str)[source]
call(method: str, params: Any | None = None) Any[source]

send a json-rpc call

Unknown

alias of Any