aiobtclientapi.clients
Clients
Classes
- class aiobtclientapi.clients.APIBase(*args, **kwargs)[source]
Bases:
ABCBase class for all BitTorrent client APIs
Subclasses are expected to also inherit from a
aiobtclientrpc.RPCBasesubclass.call(),connect()anddisconnect()catch most low-level exceptions and translate them intoConnectionError.Subclasses must catch
aiobtclientrpc.RPCErrorwhen making RPC calls (seeaiobtclientrpc.RPCError.translate()) or populatecommon_rpc_error_map.- create_background_task(coro, name=None, done_callback=None, detach=False)[source]
Run coroutine in background
- Parameters:
coro – Coroutine or any other argument for
asyncio.create_task()name – Identifier to help with debugging
done_callback – Synchronous callable that is called with the return value of coro
detach –
Whether to always wait for coro to return
If this is set to a truthy value, coro is cancelled by
wait_for_background_tasks()andCancelledErroris ignored.If this is set to a falsy value,
wait_for_background_tasks()blocks until coro returns.
- Returns:
asyncio.Taskinstance
- async wait_for_background_tasks()[source]
Wait for all tasks created by
create_background_task()Detached tasks are cancelled first.
Exceptions from tasks are raised here, except for
asyncio.CancelledErrorfrom a detached task.
- monitor_interval = 0.1
Seconds between requests when waiting for an RPC call to take effect
- common_rpc_error_map = {}
Mapping of regular expressions to exceptions for all
call()callsSee
aiobtclientrpc.RPCError.translate().
- async call(*args, **kwargs)[source]
Wrapper around
aiobtclientrpc.RPCBase.call()that handles exceptionsThis is a thin wrapper that translates the following exceptions into
ConnectionError:
- async connect(*args, **kwargs)[source]
Wrapper around
aiobtclientrpc.RPCBase.connect()that handles exceptionsSee
call().
- async disconnect(*args, **kwargs)[source]
Wrapper around
aiobtclientrpc.RPCBase.disconnect()that handles exceptionsSee
call().
- async get_infohashes()[source]
Return sequence of all known infohashes
- Raises:
ConnectionError – if the connection can’t be established
- async add(*torrents, location=None, stopped=False, verify=True)[source]
Add torrents to client
- Parameters:
torrents – Paths or URLs to torrent files,
magnet:URIs or infohasheslocation (str) –
Download directory or None to use the default
This should be an absolute path. If it isn’t, it is made absolute based on the current working directory, which may be surprising or even non-sensical if the client is running in a different environment.
stopped (bool) – Whether the torrent is active right away
verify (bool) – Whether any existing files from the torrent are hashed by the client to make sure they are not corrupt
- Returns:
Responseinstance with these custom attributes:- added
Infohashes of successfully added torrents
- already_added
Infohashes of torrents that were already added
- async start(*infohashes)[source]
Start torrent
- Parameters:
infohashes – Infohashes of the torrents to start
- Returns:
Responseinstance with these custom attributes:- started
Infohashes of successfully started torrents
- already_started
Infohashes of torrents that were already started
- async stop(*infohashes)[source]
Stop torrent
- Parameters:
infohashes – Infohash of the torrents to stop
- Returns:
Responseinstance with these custom attributes:- stopped
Infohashes of successfully stopped torrents
- already_stopped
Infohashes of torrents that were already stopped
- async verify(*infohashes)[source]
Initiate hash check of torrent files
- Parameters:
infohashes – Infohashes of the torrents to verify
- Returns:
Responseinstance with these custom attributes:- verifying
Infohashes of torrents that are now being verified
- already_verifying
Infohashes of torrents that are already being verified
- async verify_wait(*infohashes, interval=(0.3, 3))[source]
Asynchronous generator that yields
(infohash, progress)tuplesprogress is either a number from
0.0to100.0orErrororWarning.Every infohash is yielded at least once.
- Parameters:
infohashes – Infohashes of the torrents
interval –
Delay between progress updates
secondsAlways use the same delay.
(seconds_min, seconds_max)Dynamically change the delay based on how much time is left.
- class aiobtclientapi.clients.DelugeAPI(*args, **kwargs)[source]
-
Deluge API
- common_rpc_error_map = {"^'?(([0-9a-fA-F]{40}))'?$": (<class 'aiobtclientapi.errors.NoSuchTorrentError'>, '\\1')}
Mapping of regular expressions to exceptions for all
call()callsSee
aiobtclientrpc.RPCError.translate().
- class aiobtclientapi.clients.QbittorrentAPI(*args, **kwargs)[source]
Bases:
APIBase,QbittorrentRPCqBittorrent API
- class aiobtclientapi.clients.RtorrentAPI(*args, **kwargs)[source]
Bases:
APIBase,RtorrentRPCrTorrent API
- class aiobtclientapi.clients.TransmissionAPI(*args, **kwargs)[source]
Bases:
APIBase,TransmissionRPCTransmission daemon API