transmission-rpc
is a python3 library to help your control your transmission daemon remotely.
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
torrent_url = 'http://releases.ubuntu.com/' + \
'18.04/ubuntu-18.04.1-desktop-amd64.iso.torrent'
r = requests.get(torrent_url)
with open('a', 'wb') as f:
f.write(r.content)
c = Client(username='trim21', password='123456')
with open('a', 'rb') as f:
c.add_torrent(f)
client.add_torrent
support a url string(could start with file:
), file-like object(object with read()
method) or base64 encoded torrent file content.
if torrent
starts with file
, transmission-rpc
will read it from disk and base64 encode it.
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.
transmission-rpc
will put {"download-dir": "/path/to/download/dir"}
in arguments.
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 wiki
client.rst torrent.rst errors.rst utils.rst
genindex
modindex
search