Skip to main content

Convert magnet links to .torrent files

Project description

Project Status: Active — The project has reached a stable, usable state and is being actively developed. CI Status https://codecov.io/gh/jwodder/demagnetize/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/demagnetize.svg MIT License

GitHub | PyPI | Issues | Changelog

demagnetize is a Python program for converting one or more BitTorrent magnet links into .torrent files by downloading the torrent info from active peers.

At the moment, demagnetize only supports basic features of the BitTorrent protocol. The following notable features are supported:

  • BitTorrent protocol v1

  • HTTP (including compact and IPv6 extensions) and UDP trackers

  • magnet URIs with info hashes encoded in either hexadecimal or base32

  • Fast extension (BEP 6)

  • UDP tracker protocol extensions (BEP 41)

The following features are not currently supported but are planned, in no particular order:

  • Encryption

  • Distributed hash tables

  • BitTorrent protocol v2

  • x.pe parameters in magnet links

  • uTP

demagnetize has also been translated by the author into Rust; you can find the Rust version at <https://github.com/jwodder/demagnetize-rs>.

Installation

demagnetize requires Python 3.10 or higher. Just use pip for Python 3 (You have pip, right?) to install it:

python3 -m pip install demagnetize

Usage

demagnetize [<global options>] <subcommand> ...

The demagnetize command has two subcommands, get (for converting a single magnet link) and batch (for converting a file of magnet links), both detailed below.

Global Options

-l LEVEL, --log-level LEVEL

Set the log level to the given value. Possible values are “CRITICAL”, “ERROR”, “WARNING”, “INFO”, “DEBUG”, and “TRACE” (all case-insensitive). [default value: INFO]

demagnetize get

demagnetize [<global options>] get [<options>] <magnet-link>

Convert a single magnet link specified on the command line to a .torrent file. (Note that you will likely have to quote the link in order to prevent it from being interpreted by the shell.) By default, the file is saved at {name}.torrent, where {name} is replaced by the value of the name field from the torrent info, but a different path can be set via the --outfile option.

Options

-o PATH, --outfile PATH

Save the .torrent file to the given path. The path may contain a {name} placeholder, which will be replaced by the (sanitized) name of the torrent, and/or a {hash} placeholder, which will be replaced by the torrent’s info hash in hexadecimal. Specifying - will cause the torrent to be written to standard output. [default: {name}.torrent]

demagnetize batch

demagnetize [<global options>] batch [<options>] <file>

Read magnet links from <file>, one per line (ignoring empty lines and lines that start with #), and convert each one to a .torrent file. By default, each file is saved at {name}.torrent, where {name} is replaced by the value of the name field from the torrent info, but a different path can be set via the --outfile option.

Options

-o PATH, --outfile PATH

Save the .torrent files to the given path. The path may contain a {name} placeholder, which will be replaced by the (sanitized) name of each torrent, and/or a {hash} placeholder, which will be replaced by each torrent’s info hash in hexadecimal. [default: {name}.torrent]

Project details


Download files

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

Source Distribution

demagnetize-0.2.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

demagnetize-0.2.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file demagnetize-0.2.0.tar.gz.

File metadata

  • Download URL: demagnetize-0.2.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for demagnetize-0.2.0.tar.gz
Algorithm Hash digest
SHA256 417f53baac2bf37be4e0d91ecaf662784cea1789bafbada6fa62f295af6217a3
MD5 5c57accfe6a9a170b7e2bbf55c210581
BLAKE2b-256 15cb7db6bebf597c1316d694e5252987fdd9b58ed4007eb62bd5ba5198120737

See more details on using hashes here.

File details

Details for the file demagnetize-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: demagnetize-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for demagnetize-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7def25fd4498ab6a9614c89ccb251a179843ba5bcb8cf8c350373ecf63df01b9
MD5 7fe3501f7e7a996ba9108db343b61a96
BLAKE2b-256 44e9d5c09a4a3cc42682ec6989d003d1559b5aa9ed1de421b6983b374509e272

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page