Skip to main content

Python 3 module for creating and parsing torrent files and magnet URIs

Project description

torf provides a Torrent and a Magnet class.

torf-cli is a command line tool that makes use of torf.

This project started as a fork of dottorrent but turned into a rewrite.


  • Create a Torrent instance from a path to the torrent’s content or by reading an existing .torrent file
  • High-level access to standard metainfo fields via properties
  • Low-level access to arbitrary metainfo fields via metainfo property
  • Optional metainfo validation with helpful error messages
  • Generate a BTIH magnet URI from a .torrent file (the reverse is also possible but the resulting torrent is incomplete due to the lack of information in magnet URIs)
  • Check if a file system path contains everything an existing .torrent file needs
  • Use multiple CPU cores to compute piece hashes
  • Randomize the info hash to help with cross-seeding


from torf import Torrent
t = Torrent(path='path/to/content',
            comment='This is a comment')
t.private = True


Everything should be explained in the docstrings. Read it with pydoc3 torf.Torrent or pydoc3 torf.Magnet.

Documentation is also available at or for the development version.


torf is available on PyPI.

The latest development version is in the master branch on GitHub.


I consider this project feature complete, but feel free to request new features or improvements. Bug reports are always welcome, of course.



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for torf, version 3.1.3
Filename, size File type Python version Upload date Hashes
Filename, size torf-3.1.3-py3-none-any.whl (50.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size torf-3.1.3.tar.gz (78.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page