Welcome to transmission-rpc’s documentation!

transmission-rpc is a python3 library to help your control your transmission daemon remotely.

quick start

from transmission_rpc import Client

torrent_url = 'http://releases.ubuntu.com/' + \
              '18.04/ubuntu-18.04.1-desktop-amd64.iso.torrent'
c = Client(host='localhost', port=9091, username='transmission', password='password')
c.add_torrent(torrent_url)

########

from transmission_rpc import Client

c = Client(username='transmission', password='password')

torrent_url = 'magnet:?xt=urn:btih:e84213a794f3ccd890382a54' + \
              'a64ca68b7e925433&dn=ubuntu-18.04.1-desktop-amd64.iso'
c.add_torrent(torrent_url)

########

from transmission_rpc import Client
import requests

c = Client(username='trim21', password='123456')

torrent_url = 'http://releases.ubuntu.com/' + \
              '18.04/ubuntu-18.04.1-desktop-amd64.iso.torrent'
r = requests.get(torrent_url)

# client will base64 the torrent content for you.
c.add_torrent(r.content)

# or use a file-like object
with open('a', 'wb') as f:
    f.write(r.content)
with open('a', 'rb') as f:
    c.add_torrent(f)

client.add_torrent support a url string, file-like object(object with read() method) or base64 encoded torrent file content.

Arguments

Each method has it own arguments. You can pass arguments as kwargs when you call methods.

But in python, - can’t be used in a variable name, so you need to replace - with _.

For example, torrent-add method support arguments download-dir, you should call method like this.

from transmission_rpc import Client

Client().add_torrent(torrent_url, download_dir='/path/to/download/dir')

transmission-rpc will put {"download-dir": "/path/to/download/dir"} in arguments.

helper

If you want to know what kwargs you can use for a method, you can use transmission_rpc.utils.get_arguments() to get support arguments. For example, transmission 2.94 is rpc version 15, so just call print(get_arguments('torrent-add', 15))

rpc method and class method are not same, but reversed

you can find rpc version by transmission version from transmission rpc docs

Client

Client is the class handling the Transmission JSON-RPC client protocol.

Torrent ids

Many functions in Client takes torrent id. You can find torrent-ids spec in official docs

class transmission_rpc.client.Client[source]
__init__(*, protocol='http', username=None, password=None, host='127.0.0.1', port=9091, path='/transmission/', timeout=30.0, logger=<Logger transmission-rpc (ERROR)>)[source]
Parameters
  • protocol (Literal['http', 'https']) –

  • username (Optional[str]) –

  • password (Optional[str]) –

  • host (str) –

  • port (int) –

  • path (str) –

  • timeout (Union[int, float]) –

  • logger (Logger) –

property timeout: Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]

Get current timeout for HTTP queries.

property rpc_version: int

Get the Transmission RPC version. Trying to deduct if the server don’t have a version value.

add_torrent(torrent, timeout=None, *, download_dir=None, files_unwanted=None, files_wanted=None, paused=None, peer_limit=None, priority_high=None, priority_low=None, priority_normal=None, cookies=None, labels=None, bandwidthPriority=None)[source]

Add torrent to transfers list. torrent can be:

  • http://, https:// or magnet: URL

  • torrent file-like object in binary mode

  • bytes of torrent content

  • pathlib.Path for local torrent file, will be read and encoded as base64.

  • deprecated str of base64 encoded torrent file content

  • deprecated file:// URL

Note

url starts with file:// will be load by this package instead of transmission daemon

Returns a Torrent object with the fields.

Parameters
  • labels (Optional[Iterable[str]]) – Array of string labels. Add in rpc 17.

  • bandwidthPriority (Optional[int]) – Priority for this transfer.

  • cookies (Optional[str]) – One or more HTTP cookie(s).

  • download_dir (Optional[str]) – The directory where the downloaded contents will be saved in.

  • files_unwanted (Optional[List[int]]) – A list of file id’s that shouldn’t be downloaded.

  • files_wanted (Optional[List[int]]) – A list of file id’s that should be downloaded.

  • paused (Optional[bool]) – If True, does not start the transfer when added.

  • peer_limit (Optional[int]) – Maximum number of peers allowed.

  • priority_high (Optional[List[int]]) – A list of file id’s that should have high priority.

  • priority_low (Optional[List[int]]) – A list of file id’s that should have low priority.

  • priority_normal (Optional[List[int]]) – A list of file id’s that should have normal priority.

  • torrent (Union[BinaryIO, str, bytes, Path]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Torrent

remove_torrent(ids, delete_data=False, timeout=None)[source]

remove torrent(s) with provided id(s). Local data is removed if delete_data is True, otherwise not.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • delete_data (bool) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

start_torrent(ids, bypass_queue=False, timeout=None)[source]

Start torrent(s) with provided id(s)

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • bypass_queue (bool) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

start_all(bypass_queue=False, timeout=None)[source]

Start all torrents respecting the queue order

Parameters
  • bypass_queue (bool) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

stop_torrent(ids, timeout=None)[source]

stop torrent(s) with provided id(s)

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

verify_torrent(ids, timeout=None)[source]

verify torrent(s) with provided id(s)

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

reannounce_torrent(ids, timeout=None)[source]

Reannounce torrent(s) with provided id(s)

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

get_torrent(torrent_id, arguments=None, timeout=None)[source]

Get information for torrent with provided id. arguments contains a list of field names to be returned, when None all fields are requested. See the Torrent class for more information.

new argument format in rpc_version 16 is unnecessarily and this lib can’t handle table response, So it’s unsupported.

Returns a Torrent object with the requested fields.

Parameters
  • torrent_id (Union[int, str]) –

  • arguments (Optional[Iterable[str]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Torrent

get_torrents(ids=None, arguments=None, timeout=None)[source]

Get information for torrents with provided ids. For more information see get_torrent.

Returns a list of Torrent object.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • arguments (Optional[Iterable[str]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

List[Torrent]

get_files(ids=None, timeout=None)[source]

Get list of files for provided torrent id(s). If ids is empty, information for all torrents are fetched. This function returns a dictionary for each requested torrent id holding the information about the files.

See more detail in transmission_rpc.torrent.Torrent.files()

{
    <torrent id>: [
        <File 0>,
        <File 1>,
        ...
    ],
    ...
}
Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Dict[int, List[File]]

set_files(items, timeout=None)[source]

Set file properties. Takes a dictionary with similar contents as the result of transmission_rpc.client.Client.get_files().

{
    <torrent id>: {
        <file id>: {
            'priority': <priority ('high'|'normal'|'low')>,
            'selected': <selected for download (True|False)>
        },
        ...
    },
    ...
}
Parameters
  • items (Dict[str, Dict[int, Dict[str, Any]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

change_torrent(ids, timeout=None, *, bandwidth_priority=None, download_limit=None, download_limited=None, upload_limit=None, upload_limited=None, files_unwanted=None, files_wanted=None, honors_session_limits=None, location=None, peer_limit=None, priority_high=None, priority_low=None, priority_normal=None, queue_position=None, seed_idle_limit=None, seed_idle_mode=None, seed_ratio_limit=None, seed_ratio_mode=None, tracker_add=None, tracker_remove=None, tracker_replace=None, labels=None, group=None, tracker_list=None, **kwargs)[source]

Change torrent parameters for the torrent(s) with the supplied id’s.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) – torrent(s) to change.

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) – requesst timeout.

  • honors_session_limits (Optional[bool]) – true if session upload limits are honored.

  • location (Optional[str]) – new location of the torrent’s content

  • peer_limit (Optional[int]) – maximum number of peers

  • queue_position (Optional[int]) – position of this torrent in its queue [0…n)

  • files_wanted (Optional[Iterable[int]]) – Array of file id to download.

  • files_unwanted (Optional[Iterable[int]]) – Array of file id to not download.

  • download_limit (Optional[int]) – maximum download speed (KBps)

  • download_limited (Optional[bool]) – true if download_limit is honored

  • upload_limit (Optional[int]) – maximum upload speed (KBps)

  • upload_limited (Optional[bool]) – true if upload_limit is honored

  • bandwidth_priority (Optional[int]) – Priority for this transfer.

  • priority_high (Optional[Iterable[int]]) – list of file id to set high download priority

  • priority_low (Optional[Iterable[int]]) – list of file id to set low download priority

  • priority_normal (Optional[Iterable[int]]) – list of file id to set normal download priority

  • seed_ratio_limit (Optional[float]) – Seed inactivity limit in minutes.

  • seed_ratio_mode (Optional[int]) –

    Which ratio to use.

    0 = Use session limit

    1 = Use transfer limit

    2 = Disable limit.

  • seed_idle_limit (Optional[int]) – torrent-level seeding ratio

  • seed_idle_mode (Optional[int]) –

    Seed inactivity mode.

    0 = Use session limit

    1 = Use transfer limit

    2 = Disable limit.

  • tracker_add (Optional[Iterable[str]]) – Array of string with announce URLs to add.

  • tracker_remove (Optional[Iterable[int]]) – Array of ids of trackers to remove.

  • tracker_replace (Optional[Iterable[Tuple[int, str]]]) – Array of (id, url) tuples where the announce URL should be replaced.

  • labels (Optional[Iterable[str]]) – Array of string labels. Add in rpc 16.

  • group (Optional[str]) – The name of this torrent’s bandwidth group. Add in rpc 17.

  • tracker_list (Optional[Iterable[Iterable[str]]]) – A Iterable[Iterable[str]], each Iterable[str] for a tracker tier. Add in rpc 17.

  • kwargs (Any) –

Return type

None

Warning

kwargs is for the future features not supported yet, it’s not compatibility promising.

it will be bypassed to request arguments.

move_torrent_data(ids, location, timeout=None)[source]

Move torrent data to the new location.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • location (Union[str, Path]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

locate_torrent_data(ids, location, timeout=None)[source]

Locate torrent data at the provided location.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • location (Union[str, Path]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

rename_torrent_path(torrent_id, location, name, timeout=None)[source]

Rename directory and/or files for torrent. Remember to use get_torrent or get_torrents to update your file information.

Parameters
  • torrent_id (Union[int, str]) –

  • location (Union[str, Path]) –

  • name (str) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Tuple[str, str]

queue_top(ids, timeout=None)[source]

Move transfer to the top of the queue:_Timeout.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

queue_bottom(ids, timeout=None)[source]

Move transfer to the bottom of the queue.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

queue_up(ids, timeout=None)[source]

Move transfer up in the queue.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

queue_down(ids, timeout=None)[source]

Move transfer down in the queue.

Parameters
  • ids (Optional[Union[str, int, List[Union[int, str]]]]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

get_session(timeout=None)[source]

Get session parameters. See the Session class for more information.

Parameters

timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Session

set_session(timeout=None, *, alt_speed_down=None, alt_speed_enabled=None, alt_speed_time_begin=None, alt_speed_time_day=None, alt_speed_time_enabled=None, alt_speed_time_end=None, alt_speed_up=None, blocklist_enabled=None, blocklist_url=None, cache_size_mb=None, dht_enabled=None, download_dir=None, download_queue_enabled=None, download_queue_size=None, encryption=None, idle_seeding_limit=None, idle_seeding_limit_enabled=None, incomplete_dir=None, incomplete_dir_enabled=None, lpd_enabled=None, peer_limit_global=None, peer_limit_per_torrent=None, peer_port=None, peer_port_random_on_start=None, pex_enabled=None, port_forwarding_enabled=None, queue_stalled_enabled=None, queue_stalled_minutes=None, rename_partial_files=None, script_torrent_done_enabled=None, script_torrent_done_filename=None, seed_queue_enabled=None, seed_queue_size=None, seed_ratio_limit=None, seed_ratio_limited=None, speed_limit_down=None, speed_limit_down_enabled=None, speed_limit_up=None, speed_limit_up_enabled=None, start_added_torrents=None, trash_original_torrent_files=None, utp_enabled=None, script_torrent_done_seeding_filename=None, script_torrent_done_seeding_enabled=None, script_torrent_added_enabled=None, script_torrent_added_filename=None, **kwargs)[source]

Set session parameters.

Parameters
  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) – request timeout

  • alt_speed_down (Optional[int]) – max global download speed (KBps)

  • alt_speed_enabled (Optional[bool]) – true means use the alt speeds

  • alt_speed_time_begin (Optional[int]) – Time when alternate speeds should be enabled. Minutes after midnight.

  • alt_speed_time_day (Optional[int]) – Enables alternate speeds scheduling these days.

  • alt_speed_time_enabled (Optional[bool]) – Enables alternate speeds scheduling.

  • alt_speed_time_end (Optional[int]) – Time when alternate speeds should be disabled. Minutes after midnight.

  • alt_speed_up (Optional[int]) – Alternate session upload speed limit (in Kib/s).

  • blocklist_enabled (Optional[bool]) – Enables the block list

  • blocklist_url (Optional[str]) – Location of the block list. Updated with blocklist-update.

  • cache_size_mb (Optional[int]) – The maximum size of the disk cache in MB

  • dht_enabled (Optional[bool]) – Enables DHT.

  • download_dir (Optional[str]) – Set the session download directory.

  • download_queue_enabled (Optional[bool]) – Enables download queue.

  • download_queue_size (Optional[int]) – Number of slots in the download queue.

  • encryption (Optional[Literal['required', 'preferred', 'tolerated']]) – Set the session encryption mode, one of required, preferred or tolerated.

  • idle_seeding_limit (Optional[int]) – The default seed inactivity limit in minutes.

  • idle_seeding_limit_enabled (Optional[bool]) – Enables the default seed inactivity limit

  • incomplete_dir (Optional[str]) – The path to the directory of incomplete transfer data.

  • incomplete_dir_enabled (Optional[bool]) – Enables the incomplete transfer data directory, Otherwise data for incomplete transfers are stored in the download target.

  • lpd_enabled (Optional[bool]) – Enables local peer discovery for public torrents.

  • peer_limit_global (Optional[int]) – Maximum number of peers.

  • peer_limit_per_torrent (Optional[int]) – Maximum number of peers per transfer.

  • peer_port (Optional[int]) – Peer port.

  • peer_port_random_on_start (Optional[bool]) – Enables randomized peer port on start of Transmission.

  • pex_enabled (Optional[bool]) – Allowing PEX in public torrents.

  • port_forwarding_enabled (Optional[bool]) – Enables port forwarding.

  • queue_stalled_enabled (Optional[bool]) – Enable tracking of stalled transfers.

  • queue_stalled_minutes (Optional[int]) – Number of minutes of idle that marks a transfer as stalled.

  • rename_partial_files (Optional[bool]) – Appends “.part” to incomplete files

  • seed_queue_enabled (Optional[bool]) – Enables upload queue.

  • seed_queue_size (Optional[int]) – Number of slots in the upload queue.

  • seed_ratio_limit (Optional[int]) – Seed ratio limit. 1.0 means 1:1 download and upload ratio.

  • seed_ratio_limited (Optional[bool]) – Enables seed ration limit.

  • speed_limit_down (Optional[int]) – Download speed limit (in Kib/s).

  • speed_limit_down_enabled (Optional[bool]) – Enables download speed limiting.

  • speed_limit_up (Optional[int]) – Upload speed limit (in Kib/s).

  • speed_limit_up_enabled (Optional[bool]) – Enables upload speed limiting.

  • start_added_torrents (Optional[bool]) – Added torrents will be started right away.

  • trash_original_torrent_files (Optional[bool]) – The .torrent file of added torrents will be deleted.

  • utp_enabled (Optional[bool]) – Enables Micro Transport Protocol (UTP).

  • script_torrent_done_enabled (Optional[bool]) – Whether to call the “done” script.

  • script_torrent_done_filename (Optional[str]) – Filename of the script to run when the transfer is done.

  • script_torrent_added_filename (Optional[str]) – filename of the script to run

  • script_torrent_added_enabled (Optional[bool]) – whether or not to call the added script

  • script_torrent_done_seeding_enabled (Optional[bool]) – whether or not to call the seeding-done script

  • script_torrent_done_seeding_filename (Optional[str]) – filename of the script to run

  • kwargs (Any) –

Return type

None

Warning

kwargs is for the future features not supported yet, it’s not compatibility promising.

it will be bypassed to request arguments.

blocklist_update(timeout=None)[source]

Update block list. Returns the size of the block list.

Parameters

timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Optional[int]

port_test(timeout=None)[source]

Tests to see if your incoming peer port is accessible from the outside world.

Parameters

timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Optional[bool]

free_space(path, timeout=None)[source]

Get the amount of free space (in bytes) at the provided location.

Parameters
  • path (Union[str, Path]) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Optional[int]

session_stats(timeout=None)[source]

Get session statistics

Parameters

timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

Session

Timeouts

Since most methods results in HTTP requests against Transmission, it is possible to provide a argument called timeout. Default timeout is 30 seconds.

Torrent

class transmission_rpc.torrent.Torrent[source]

Torrent is a class holding the data received from Transmission regarding a bittorrent transfer.

All fetched torrent fields are accessible through this class using attributes. This class has a few convenience properties using the torrent data.

__init__(client, fields)[source]
Parameters
  • client (Client) –

  • fields (Dict[str, Any]) –

property id: int

Returns the id for this torrent

files()[source]

Get list of files for this torrent.

Note

The order of the files is guaranteed. The index of file object is the id of the file when calling transmission_rpc.client.Client.set_files().

from transmission_rpc import Client

torrent = Client().get_torrent(0)

for file_id, file in enumerate(torrent.files()):
    print(file_id, file)
Return type

List[File]

property name: str

Returns the name of this torrent.

Raise AttributeError if server don’t return this field

property status: Status

Status

Returns the torrent status. Is either one of ‘check pending’, ‘checking’, ‘downloading’, ‘download pending’, ‘seeding’, ‘seed pending’ or ‘stopped’. The first two is related to verification.

Examples:

torrent = Torrent()
torrent.status.downloading
torrent.status == 'downloading'
Type

rtype

property rateDownload: int

Returns download rate in B/s

Return type

int

property rateUpload: int

Returns upload rate in B/s

Return type

int

property hashString: str

Returns the info hash of this torrent.

Raise

AttributeError – if server don’t return this field

property progress: float

download progress in percent.

Return type

float

property ratio: float

upload/download ratio.

Return type

float

property eta: timedelta

the “eta” as datetime.timedelta.

If downloading, estimated the timedelta left until the torrent is done. If seeding, estimated the timedelta left until seed ratio is reached.

raw eta maybe negative: - -1 for ETA Not Available. - -2 for ETA Unknown.

https://github.com/transmission/transmission/blob/3.00/libtransmission/transmission.h#L1748-L1749

Return type

datetime.timedelta

Raises

ValueError – non positive ETA.

property date_active: datetime

the attribute activityDate as datetime.datetime in UTC timezone.

Note

raw activityDate value could be 0 for never activated torrent, therefore it can’t always be converted to local timezone.

Return type

datetime.datetime

property date_added: datetime

raw field addedDate as datetime.datetime in local timezone.

Return type

datetime.datetime

property date_started: datetime

raw field startDate as datetime.datetime in local timezone.

Return type

datetime.datetime

property date_done: Optional[datetime]

the attribute “doneDate” as datetime.datetime. returns None if “doneDate” is invalid.

format_eta()[source]

Returns the attribute eta formatted as a string.

  • If eta is -1 the result is ‘not available’

  • If eta is -2 the result is ‘unknown’

  • Otherwise eta is formatted as <days> <hours>:<minutes>:<seconds>.

Return type

str

property download_dir: Optional[str]

The download directory.

Available

transmission version 1.5.

Available

RPC version 4.

property download_limit: Optional[int]

The download limit.

Can be a number or None.

property peer_limit: int

the peer limit.

property priority: str

Bandwidth priority as string. Can be one of ‘low’, ‘normal’, ‘high’. This is a mutator.

property seed_idle_limit: int

seed idle limit in minutes.

property is_finished: bool

Returns true if the torrent is finished (available from rpc version 2.0)

property is_stalled: bool

Returns true if the torrent is stalled (available from rpc version 2.4)

property size_when_done: int

Size in bytes when the torrent is done

property total_size: int

Total size in bytes

property left_until_done: int

Bytes left until done

property desired_available: int

Bytes that are left to download and available

property error: int

0 for fine task, non-zero for error torrent

property error_string: str

empty string for fine task

property available: float

Availability in percent

property seed_idle_mode: str

Seed idle mode as string. Can be one of ‘global’, ‘single’ or ‘unlimited’.

  • global, use session seed idle limit.

  • single, use torrent seed idle limit. See seed_idle_limit.

  • unlimited, no seed idle limit.

property seed_ratio_limit: float

Torrent seed ratio limit as float. Also see seed_ratio_mode. This is a mutator.

Return type

float

property seed_ratio_mode: str

Seed ratio mode as string. Can be one of ‘global’, ‘single’ or ‘unlimited’.

  • global, use session seed ratio limit.

  • single, use torrent seed ratio limit. See seed_ratio_limit.

  • unlimited, no seed ratio limit.

This is a mutator.

property upload_limit: Optional[int]

upload limit. Can be a number or None.

property queue_position: int

queue position for this torrent.

property file_count: int

added in transmission 4.00

property group: str

added in transmission 4.00

transmission will return an empty str "" if torrent doesn’t have a bandwidth group.

update(timeout=None)[source]

Update the torrent information.

Parameters

timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

start(bypass_queue=False, timeout=None)[source]

Start the torrent.

Parameters
  • bypass_queue (bool) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

stop(timeout=None)[source]

Stop the torrent.

Parameters

timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

move_data(location, timeout=None)[source]

Move torrent data to location.

Parameters
  • location (str) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

locate_data(location, timeout=None)[source]

Locate torrent data at location.

Parameters
  • location (str) –

  • timeout (Optional[Union[int, float, Tuple[Union[int, float], Union[int, float]]]]) –

Return type

None

class transmission_rpc.torrent.Status[source]

A wrapped str for torrent status.

returned by Torrent.status

stopped: bool
check_pending: bool
checking: bool
download_pending: bool
downloading: bool
seed_pending: bool
seeding: bool
static __new__(cls, raw)[source]
Parameters

raw (str) –

Return type

Status

__init__()

Session

class transmission_rpc.session.Session[source]

Session is a dict-like class holding the session data for a Transmission daemon.

Access the session field can be done through attributes. The attributes available are the same as the session arguments in the Transmission RPC specification, but with underscore instead of hyphen.

get 'download-dir' with session.download_dir.

session = Client().get_session()

current = session.download_dir

there are also setter like Session().download_dir = '/path/to/download'

session = Client().get_session()

session.download_dir = '/path/to/new/download/dir'

if you want to batch update a session, call .update(data)

session = Client().get_session()

session.update({'k1': 'v1', "k2": "v2"})

if you have to access to the private Session()._fields, keys are stored with underscore.

__init__(client, fields=None)[source]
Parameters
  • client (Client) –

  • fields (Dict[str, Any]) –

update(other)[source]

Update the session data from a Transmission JSON-RPC arguments dictionary

Parameters

other (Union[Dict[str, Any], Session]) –

Return type

None

keys()[source]

session keys with underscore (eg: download_dir)

Return type

Generator[str, None, None]

items()[source]

iter key,value pair

hyphen in key is replace by underscore. (eg: 'download_dir')

Return type

Generator[Tuple[str, Any], None, None]

property download_dir: str

default download location

  • rpc version 12

  • transmission version 2.20

property version: str
  • rpc version 3

  • transmission version 1.41

property rpc_version: int
  • rpc version 4

  • transmission version 1.50

property peer_port: int

Get the peer port.

  • rpc version 5

  • transmission version 1.60

property pex_enabled: bool

Is peer exchange enabled

  • rpc version 5

  • transmission version 1.60

Errors

exception raise by this package

exception transmission_rpc.error.TransmissionError[source]

This exception is raised when there has occurred an error related to communication with Transmission.

__init__(message='', original=None)[source]
Parameters
  • message (str) –

  • original (Optional[Response]) –

exception transmission_rpc.error.TransmissionAuthError[source]

Raised when username or password is incorrect

exception transmission_rpc.error.TransmissionConnectError[source]

raised when client can’t connect to transmission daemon

exception transmission_rpc.error.TransmissionTimeoutError[source]

Timeout

exception transmission_rpc.error.TransmissionVersionError[source]

transmission version is too lower to support some feature

Utils

transmission_rpc.utils.format_size(size)[source]

Format byte size into IEC prefixes, B, KiB, MiB …

Parameters

size (int) –

Return type

Tuple[float, str]

transmission_rpc.utils.format_speed(size)[source]

Format bytes per second speed into IEC prefixes, B/s, KiB/s, MiB/s …

Parameters

size (int) –

Return type

Tuple[float, str]

transmission_rpc.utils.format_timedelta(delta)[source]

Format datetime.timedelta into <days> <hours>:<minutes>:<seconds>.

Parameters

delta (timedelta) –

Return type

str

transmission_rpc.utils.rpc_bool(arg)[source]

Convert between Python boolean and Transmission RPC boolean.

Parameters

arg (Any) –

Return type

int

transmission_rpc.utils.make_python_name(name)[source]

Convert Transmission RPC name to python compatible name.

Parameters

name (str) –

Return type

str

transmission_rpc.utils.make_rpc_name(name)[source]

Convert python compatible name to Transmission RPC name.

Parameters

name (str) –

Return type

str

transmission_rpc.utils.get_torrent_arguments(rpc_version)[source]

Get torrent arguments for method in specified Transmission RPC version.

Parameters

rpc_version (int) –

Return type

List[str]

Indices and tables