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()) and/or populatecommon_rpc_error_map.All asynchronous methods may raise
ConnectionError.- 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:It also converts any common errors by passing
common_rpc_error_maptoaiobtclientrpc.RPCError.translate().
- 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 add(torrent, *, location=None, stopped=False, verify=True)[source]
Add torrent to client
- Parameters:
torrent – Path or URL to torrent file,
magnet:URI or infohashlocation (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:
Infohashof the added torrent- Raises:
errors.AddTorrentError – if adding fails
- async start(infohash)[source]
Start torrent
- Parameters:
infohashes – Infohash of the torrent to start
- Returns:
None when the torrent was started
- Raises:
errors.StartTorrentError – if starting the torrent failed
- async stop(infohash)[source]
Stop torrent
- Parameters:
infohash – Infohash of the torrent to stop
- Returns:
None when the torrent was stopped
- Raises:
errors.StopTorrentError – if stopping the torrent failed
- async verify(infohash)[source]
Initiate hash check of a torrent’s files
See also
verify_wait().- Parameters:
infohash – Infohash of the torrent to check
- Returns:
None when the verification was initiated
- Raises:
errors.VerifyTorrentError – if initiating the verification failed
- async verify_wait(*infohashes, interval=(0.3, 3))[source]
Asynchronous generator that yields
(infohash, progress)tuplesprogressis either a number from0.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.
seconds_minis used untilprogressgets close to100.0. Then,seconds_mingradually moves toseconds_max.This allows to spread out update requests until the end, where you want to check progress more frequently to know when the verification is finished.
- 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