Skip to main content

torf-cli is a command line tool that can create, read and edit torrent files and magnet URIs. It can also verify a file system path against a torrent and provide detailed errors. When creating a torrent, it can find an existing torrent with the same files and copy its piece hashes to the freshly created torrent to avoid hashing the files again.

The output is pleasant to read for humans or easy to parse with common CLI tools.

An optional configuration file specifies custom default options and profiles that combine commonly used options.

Documentation is available as a man page, or you can read it here.

The only dependencies are torf and pyxdg.

Examples

Create private torrent with two trackers and a specific creation date:

$ torf ./docs -t http://bar:123/announce -t http://baz:321/announce \
              --private --date '2020-03-31 21:23:42'
       Name  docs
       Size  74.43 KiB
    Created  2020-03-31 21:23:42
 Created By  torf 3.1.0
    Private  yes
   Trackers  http://bar:123/announce
             http://baz:321/announce
 Piece Size  16 KiB
Piece Count  5
 File Count  3
      Files  docs
             ├─torf.1 [14.53 KiB]
             ├─torf.1.asciidoc [10.56 KiB]
             └─torf.1.html [49.34 KiB]
   Progress  100.00 % | 0:00:00 total | 72.69 MiB/s
  Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02
     Magnet  magnet:?xt=urn:btih:0a9dfcf07feb2a82da11b509e8929266d8510a02&dn=docs&xl=76217&tr=http%3A%2F%2Fbar%3A123%2Fannounce&tr=http%3A%2F%2Fbaz%3A321%2Fannounce
    Torrent  docs.torrent

Display information about an existing torrent:

$ torf -i docs.torrent
       Name  docs
  Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02
       Size  74.43 KiB
    Created  2020-03-31 21:23:42
 Created By  torf 3.1.0
    Private  yes
   Trackers  http://bar:123/announce
             http://baz:321/announce
 Piece Size  16 KiB
Piece Count  5
 File Count  3
      Files  docs
             ├─torf.1 [14.53 KiB]
             ├─torf.1.asciidoc [10.56 KiB]
             └─torf.1.html [49.34 KiB]
     Magnet  magnet:?xt=urn:btih:0a9dfcf07feb2a82da11b509e8929266d8510a02&dn=docs&xl=76217&tr=http%3A%2F%2Fbar%3A123%2Fannounce&tr=http%3A%2F%2Fbaz%3A321%2Fannounce

Quickly add a comment to an existing torrent:

$ torf -i docs.torrent --comment 'Forgot to add this comment.' -o docs.revised.torrent
       Name  docs
  Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02
       Size  74.43 KiB
    Comment  Forgot to add this comment.
    Created  2020-03-31 21:23:42
 Created By  torf 3.1.0
    Private  yes
   Trackers  http://bar:123/announce
             http://baz:321/announce
 Piece Size  16 KiB
Piece Count  5
 File Count  3
      Files  docs
             ├─torf.1 [14.53 KiB]
             ├─torf.1.asciidoc [10.56 KiB]
             └─torf.1.html [49.34 KiB]
     Magnet  magnet:?xt=urn:btih:0a9dfcf07feb2a82da11b509e8929266d8510a02&dn=docs&xl=76217&tr=http%3A%2F%2Fbar%3A123%2Fannounce&tr=http%3A%2F%2Fbaz%3A321%2Fannounce
    Torrent  docs.revised.torrent

Verify the files in docs:

$ <edit torf.1.html>
$ torf -i docs.revised.torrent docs
       Name  docs
  Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02
       Size  74.43 KiB
    Comment  Forgot to add this comment.
    Created  2020-03-31 21:23:42
 Created By  torf 3.1.0
    Private  yes
   Trackers  http://bar:123/announce
             http://baz:321/announce
 Piece Size  16 KiB
Piece Count  5
 File Count  3
      Files  docs
             ├─torf.1 [14.53 KiB]
             ├─torf.1.asciidoc [10.56 KiB]
             └─torf.1.html [49.34 KiB]
       Path  docs
  Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02
      Error  docs/torf.1.html: Too big: 50523 instead of 50522 bytes
      Error  Corruption in piece 2, at least one of these files is corrupt:
               docs/torf.1.asciidoc
               docs/torf.1.html
   Progress  100.00 % | 0:00:00 total | 72.69 MiB/s
torf: docs does not satisfy docs.revised.torrent

Get a list of files via grep and cut:

$ torf -i docs.revised.torrent | grep '^Files' | cut -f2-
docs/torf.1     docs/torf.1.asciidoc    docs/torf.1.html
# Files are delimited by a horizontal tab (``\t``)

Get a list of files via jq:

$ torf -i docs.revised.torrent --json | jq .Files
[
  "docs/torf.1",
  "docs/torf.1.asciidoc",
  "docs/torf.1.html"
]

Get metainfo as JSON:

$ torf -i docs.revised.torrent -m
{
    "announce": "http://bar:123/announce",
    "announce-list": [
        [
            "http://bar:123/announce"
        ],
        [
            "http://baz:321/announce"
        ]
    ],
    "comment": "Forgot to add this comment.",
    "created by": "torf 3.1.0",
    "creation date": 1585682622,
    "info": {
        "name": "docs",
        "piece length": 16384,
        "private": 1,
        "files": [
            {
                "length": 14877,
                "path": [
                    "torf.1"
                ]
            },
            {
                "length": 10818,
                "path": [
                    "torf.1.asciidoc"
                ]
            },
            {
                "length": 50522,
                "path": [
                    "torf.1.html"
                ]
            }
        ]
    }
}

Installation

The latest release is available on PyPI and on AUR.

pipx

The easiest and cleanest installation method is pipx, which installs each application with all dependencies in a separate virtual environment in ~/.local/venvs/ and links the executable to ~/.local/bin/.

$ pipx install torf-cli
$ pipx upgrade torf-cli
$ pipx uninstall torf-cli  # Also removes dependencies

The only drawback is that, at the time of writing, pipx doesn’t make the man page available, but it’s also available here.

pip

The alternative is regular pip, but if you decide to uninstall, you have to manually uninstall the dependencies.

$ pip3 install torf-cli         # Installs system-wide (/usr/local/)
$ pip3 install --user torf-cli  # Installs in your home (~/.local/)

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

$ pip3 install [--user] git+https://github.com/rndusr/torf-cli.git

Contributing

Bug reports and feature requests are welcome in the issue tracker.

License

torf-cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Release files for torf-cli 5.2.1

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

Source distribution (sdist)

Source distribution for torf-cli 5.2.1
File Size Uploaded
torf_cli-5.2.1.tar.gz 52.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torf-cli 5.2.1
File Interpreter ABI Platform
torf_cli-5.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 90.3 kB

Release files / torf_cli-5.2.1.tar.gz

Download URL torf_cli-5.2.1.tar.gz
Size 52.7 kB
Tags Source
SHA-256 checksum
How to use checksums
96f64e3f2408e8ca5a3567ced9f5ad2e9ef1d63e13cfe8836145ac36bad8ed54
BLAKE2b-256 checksum
How to use checksums
3190b67f5f73353f419b172c8d22ebaf744750fa22af9eb4b52adff52a7706f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.9

Release files / torf_cli-5.2.1-py3-none-any.whl

Download URL torf_cli-5.2.1-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
953fe8834205a341aec065055c719a002f8152b27a2099272fc00f0a12d4b355
BLAKE2b-256 checksum
How to use checksums
f73ed497d3a747d1467214aebda4b866c505127965f38729aea28edf2805bcab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

5.2.1 This release

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.0

2 release files

1.1

1 release file

1.0

1 release file

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