Skip to main content
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]

Metadata

Release files for demagnetize 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for demagnetize 0.3.0
File Size Uploaded
demagnetize-0.3.0.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for demagnetize 0.3.0
File Interpreter ABI Platform
demagnetize-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.9 kB

Release files / demagnetize-0.3.0.tar.gz

Download URL demagnetize-0.3.0.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ab023ff72d03cc2ed369e94aa1d6d513e5774735c3adee9bc66e274e8207af4e
BLAKE2b-256 checksum
How to use checksums
4c06761ea05bd9367379f70afcc93db40d57f0b7ce423250dbf9d15729676c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / demagnetize-0.3.0-py3-none-any.whl

Download URL demagnetize-0.3.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3ac825bb8d949d3d1ea17fb67b48d41c22a22bf0eae6c70817042aa7db9f01c
BLAKE2b-256 checksum
How to use checksums
a92a51fcd920aa34212fe65e5e6acf6bf2eb6d9c3c5ed8223c42703708ca94e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page