Skip to content

NikhilJArora/pytorrent

Repository files navigation

pytorrent

Documentation Status

Simple Bittorrent client written using Python and Twisted.

Features

  • support for http Trackers
  • support for download via .torrent files (no Magnet links)
  • support for stopping/resuming downloads
  • support for both single and multi-file torrents

Get started

First lets get our python package installed. I prefer to user conda to create my virtual environments but any should work.

With conda installed lets create a virtual environment (venv or virtualenv would also work):

conda create -n pytorrent python=3.8 -y
conda activate pytorrent

Now with our venv activated lets clone down the repo and install it:

git clone https://github.com/NikhilJArora/pytorrent.git
cd pytorrent
pip install -e .

Once installed, we interact with the pytorrent CLI as follows:

$ pytorrent [-o, --output-dir DIRECTORY] "/path/to/file.torrent"

If prefered, we can interact directly with the main PyTorrent class to achieve the same result with the Python REPL:

from pytorrent.client import PyTorrent

torrent_file = "/path/to/file.torrent"
pt = PyTorrent(torrent_file)

pt.start()  # starts the download of torrent pieces

output_location = "/path/to/output/dir/"  # optional
pt.create_files(output_location)  # creates final file/files

There are also some other classes work noting that expose other useful functionality:

  • to interact directly with the Torrent metadata class: pytorrent.torrent_file.TorrentMD
  • to interact directly with the Torrent Tracker class: pytorrent.connections.Tracker

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

Bittorrent client written in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published