Edit BitTorrent metadata (trackers and private flag)
Project description
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
.bakbackup before writing - Synchronize
.resume&.fastresumefiles 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_pathparameter that points to the.resumeor.fastresumefiles 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+).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torrent_edit-0.1.5.tar.gz.
File metadata
- Download URL: torrent_edit-0.1.5.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7189daaa2f8308e1e331c779d3742d51017c0af2ad6aa2e69ed40f19aef9f2d
|
|
| MD5 |
494c491a7c359e32410d6bfbc85e78b8
|
|
| BLAKE2b-256 |
f9aaa074ef0a35cfa0dd0ae29726c7e17e8044a2aa3b4c778374ca1df24b9022
|
File details
Details for the file torrent_edit-0.1.5-py3-none-any.whl.
File metadata
- Download URL: torrent_edit-0.1.5-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c982544e74df4d6ad303ac6376608e5082b3918a5dd2eb7932b90d9e89f62c5c
|
|
| MD5 |
43dfeb78edcf1f440d6ac6ea4ff804b6
|
|
| BLAKE2b-256 |
1de04e16408d15b2390156793c8d343aa55229d1a7e7ef34eb370d6fdec6aa63
|