Skip to main content

GitHub release (latest SemVer) version on pypi python versions on pypi license

A small command-line tool to modify BitTorrent .torrent files.

This tool is designed to perform simple metadata edits without recreating the torrent. It supports Transmission & qBittorrent resume files.


Features

  • Toggle torrent private/public flag
  • Add new trackers
  • Remove existing trackers
  • Replace the entire tracker list
  • Automatic .bak backup before writing
  • Synchronize .resume & .fastresume files for torrents already loaded in a client

Installation

From pypi

pip install torrent-edit

From source

git clone https://github.com/yourname/torrent-edit.git
cd torrent-edit
pip install .

Editable install (recommended for development)

pip install -e .

Usage

usage: torrent-edit [-h] [--public | --private] [--add URL [URL ...]] [--remove URL [URL ...]] [--replace URL [URL ...]] [-v] torrent

Edit BitTorrent metadata (private flag and trackers).

positional arguments:
  torrent               Path to the .torrent file(s)

options:
  -h, --help            show this help message and exit
  --public              Remove the private flag
  --private             Set the torrent as private (disable DHT/PEX)
  --inplace             Modify the torrent inplace even if the hash has changed instead of recreating it
                        (if the privacy flag has been toggled)(not recommended)
  --resume_path [RESUME_PATH]
                        Directory of the .resume or .fastresume file(s). Used for qBittorrent and Transmission.
  --add URL [URL ...]   Add all trackers with the provided list
  --remove URL [URL ...]
                        Remove all trackers with the provided list.
                        If no tracker is found, the file will be skipped, even if private is set.
  --replace URL [URL ...]
                        Replace all trackers with the provided list
  -v, --verbose         Enable verbose output (debug logging)

Examples

You can specify multiple files:

$ torrent-edit *.torrent [...]
  • Make a torrent private / public
$ torrent-edit "Mr.and.Mr.Macron's.holidays.financed.by.your.taxes.mkv.torrent" --private

This sets the private flag in the torrent metadata. Most BitTorrent clients will disable DHT, PEX, and LSD when the torrent is private.

$ torrent-edit movie.torrent --public

Removes the private flag.

⚠️ Notice: By doing this, you are changing the torrent's hash. The file will therefore be different for the network, and your old peers will no longer be able to find you. However, you may have two torrents pointing to the same file, and the hash obtained is exactly the same as the hash that would have been obtained if the torrent had been generated from the start with this option.

⚠️ Notice: When doing this, you may need to update the path to the file in your application. This is because the torrent client treats it as a new pending download. To AVOID this, use the --resume_path parameter that points to the .resume or .fastresume files of Transmission or qBittorrent. The updates will be made automatically and visible once the client is restarted.

Use the --inplace parameter to force editing the torrent file in place (even if the hash is modified). This can be useful if you are working with torrents that not already loaded in a BitTorrent client.

  • Add a tracker
$ torrent-edit movie.torrent \
    --add https://tracker/announce

You can specify multiple trackers:

$ torrent-edit movie.torrent \
    --add \
    https://tracker1/announce \
    https://tracker2/announce
  • Remove a tracker
$ torrent-edit movie.torrent \
    --remove http://oldtracker/announce
  • Replace all trackers
$ torrent-edit movie.torrent \
    --replace \
    https://tracker1/announce \
    https://tracker2/announce

This removes all existing trackers and replaces them with the provided ones.

How to use in real life (GNU/Linux)

  • Stop the BitTorrent service or application (Transmission, qBittorrent, etc.)

  • Find the directory with the torrents used by your application, and go into it.

    • For Transmission server: /var/lib/transmission-daemon/info/torrents/ (torrents), /var/lib/transmission-daemon/info/resume/ (resume files)

    • For Transmission client: ~/.config/transmission/torrents/ (torrents), ~/.config/transmission/resume/ (resume files)

    • For qBittorrent (Linux): ~/.local/share/qBittorrent/BT_backup/ (torrent & fastresume files)

    • For qBittorrent (Windows): %LOCALAPPDATA%/qBittorrent/BT_backup (torrent & fastresume files)

  • Execute the script with your own arguments.

  • If you are using a simple client, just restart it, it's done.

  • If you are using Transmission server, you may have to restart the service and reload the torrents with the remote administration tool.

sudo find . -iname "*.torrent" -exec transmission-remote 127.0.0.1:9091 -n transmission_login:transmission_pass -a {} \;

Done!

Alternative

The tool transmission-edit allows you to update the tracker list, but will NOT allow you to toggle the private flag.

Example:

cd /var/lib/transmission-daemon/info/torrents
sudo transmission-edit -r "old_url" "new_url" *.torrent

Contributions

This project is open for any contribution! Any bug report can be posted by opening an issue.

License

torrent-edit is released under the GNU General Public License v3 (GPLv3+).

Metadata

Release files for torrent-edit 0.1.5

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

Source distribution (sdist)

Source distribution for torrent-edit 0.1.5
File Size Uploaded
torrent_edit-0.1.5.tar.gz 22.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torrent-edit 0.1.5
File Interpreter ABI Platform
torrent_edit-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 43.1 kB

Release files / torrent_edit-0.1.5.tar.gz

Download URL torrent_edit-0.1.5.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7189daaa2f8308e1e331c779d3742d51017c0af2ad6aa2e69ed40f19aef9f2d
BLAKE2b-256 checksum
How to use checksums
f9aaa074ef0a35cfa0dd0ae29726c7e17e8044a2aa3b4c778374ca1df24b9022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / torrent_edit-0.1.5-py3-none-any.whl

Download URL torrent_edit-0.1.5-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c982544e74df4d6ad303ac6376608e5082b3918a5dd2eb7932b90d9e89f62c5c
BLAKE2b-256 checksum
How to use checksums
1de04e16408d15b2390156793c8d343aa55229d1a7e7ef34eb370d6fdec6aa63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.5 This release

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