Tested on Python 3.11
but it should work on Python ^3.9
versions just fine.
-
Dependencies: The only 2 dependencies which are needed for aiotorrent to work are
fast-bencode
andbitstring
. -
Streaming dependencies: built-in support for streaming files over HTTP. To use this feature, you need to install some extra streaming dependencies.
Install aiotorrent from PyPI using:
$ pip install aiotorrent
In order to use the streaming feature, you can install the dependencies using:
$ pip install aiotorrent[stream-support]
You need to import the Torrent class and pass a torrent file to it:
from aiotorrent import Torrent
torrent = Torrent('path/to/torrent')
# To initialise the torrent, you need to call the init() coroutine.
await torrent.init()
Files can be accessed from the files
attribute of the torrent class which stores all the File
objects in a list.
To download a file, you can call the download()
coroutine and pass in a File
object:
# To download file2
await torrent.download(torrent.files[2])
Similarly, to stream a torrent file, you can call the stream()
coroutine, as follows:
await torrent.stream(torrent.files[2])
This starts up a uvicorn
server on localhost:8080
which uses starlette
behind the scenes as the ASGI framework to stream files over http.
The above methods can take additional parameters to customize the behaviour of this library. Read the documentation to know more.
- Test compatiability on older versions of Python.
- Add documentation for all the classes in the library.
- Add support for HTTP trackers (And later, WSS trackers).
Return downloaded pieces as soon as they are downloaded (replace batch downloading approach)Replace print statements with logging.- Update the Torrent class to make the API more modular.
- Implement functionality to get download status in the Torrent class.