torf-cli


Nametorf-cli JSON
Version 5.2.0 PyPI version JSON
download
home_pageNone
SummaryCLI tool to create, read and edit torrent files
upload_time2024-03-25 10:55:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseGPL-3.0-or-later
keywords bittorrent torrent magnet cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            torf-cli
========

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
<https://rndusr.github.io/torf-cli/torf.1.html>`_.

The only dependencies are `torf <https://pypi.org/project/torf/>`_ and `pyxdg
<https://pypi.org/project/pyxdg/>`_.


Examples
--------

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

.. code:: sh

    $ 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:

.. code:: sh

    $ 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:

.. code:: sh

    $ 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``:

.. code:: sh

    $ <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``:

.. code:: sh

    $ 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 <https://stedolan.github.io/jq/>`_:

.. code:: sh

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

Get metainfo as JSON:

.. code:: sh

    $ 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 <https://pypi.org/project/torf-cli>`_
and on `AUR <https://aur.archlinux.org/packages/torf-cli/>`_.


pipx
````

The easiest and cleanest installation method is `pipx
<https://pipxproject.github.io/pipx/>`__, which installs each application with all
dependencies in a separate virtual environment in ``~/.local/venvs/`` and links
the executable to ``~/.local/bin/``.

.. code:: sh

    $ 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
<https://rndusr.github.io/torf-cli/torf.1.html>`_.


pip
```

The alternative is regular `pip <https://pypi.org/project/torf/>`__, but if you
decide to uninstall, you have to manually uninstall the dependencies.

.. code:: sh

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

The `latest development version <https://github.com/rndusr/torf-cli>`_ is
available on GitHub in the master branch.

.. code:: sh

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


Contributing
------------

Bug reports and feature requests are welcome in the `issue tracker
<https://github.com/rndusr/torf-cli/issues>`_.


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
<https://www.gnu.org/licenses/gpl-3.0.txt>`_ for more details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "torf-cli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "bittorrent, torrent, magnet, cli",
    "author": null,
    "author_email": "Random User <rndusr@posteo.de>",
    "download_url": "https://files.pythonhosted.org/packages/1b/2a/7f0a7dd35f5e7b7f292681102ed5e996f40201d1ea190167f56b40703f92/torf-cli-5.2.0.tar.gz",
    "platform": null,
    "description": "torf-cli\n========\n\ntorf-cli is a command line tool that can create, read and edit torrent files and\nmagnet URIs. It can also verify a file system path against a torrent and provide\ndetailed errors. When creating a torrent, it can find an existing torrent with\nthe same files and copy its piece hashes to the freshly created torrent to avoid\nhashing the files again.\n\nThe output is pleasant to read for humans or easy to parse with common CLI\ntools.\n\nAn optional configuration file specifies custom default options and profiles\nthat combine commonly used options.\n\nDocumentation is available as a man page, or you can `read it here\n<https://rndusr.github.io/torf-cli/torf.1.html>`_.\n\nThe only dependencies are `torf <https://pypi.org/project/torf/>`_ and `pyxdg\n<https://pypi.org/project/pyxdg/>`_.\n\n\nExamples\n--------\n\nCreate private torrent with two trackers and a specific creation date:\n\n.. code:: sh\n\n    $ torf ./docs -t http://bar:123/announce -t http://baz:321/announce \\\n                  --private --date '2020-03-31 21:23:42'\n           Name  docs\n           Size  74.43 KiB\n        Created  2020-03-31 21:23:42\n     Created By  torf 3.1.0\n        Private  yes\n       Trackers  http://bar:123/announce\n                 http://baz:321/announce\n     Piece Size  16 KiB\n    Piece Count  5\n     File Count  3\n          Files  docs\n                 \u251c\u2500torf.1 [14.53 KiB]\n                 \u251c\u2500torf.1.asciidoc [10.56 KiB]\n                 \u2514\u2500torf.1.html [49.34 KiB]\n       Progress  100.00 % | 0:00:00 total | 72.69 MiB/s\n      Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02\n         Magnet  magnet:?xt=urn:btih:0a9dfcf07feb2a82da11b509e8929266d8510a02&dn=docs&xl=76217&tr=http%3A%2F%2Fbar%3A123%2Fannounce&tr=http%3A%2F%2Fbaz%3A321%2Fannounce\n        Torrent  docs.torrent\n\nDisplay information about an existing torrent:\n\n.. code:: sh\n\n    $ torf -i docs.torrent\n           Name  docs\n      Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02\n           Size  74.43 KiB\n        Created  2020-03-31 21:23:42\n     Created By  torf 3.1.0\n        Private  yes\n       Trackers  http://bar:123/announce\n                 http://baz:321/announce\n     Piece Size  16 KiB\n    Piece Count  5\n     File Count  3\n          Files  docs\n                 \u251c\u2500torf.1 [14.53 KiB]\n                 \u251c\u2500torf.1.asciidoc [10.56 KiB]\n                 \u2514\u2500torf.1.html [49.34 KiB]\n         Magnet  magnet:?xt=urn:btih:0a9dfcf07feb2a82da11b509e8929266d8510a02&dn=docs&xl=76217&tr=http%3A%2F%2Fbar%3A123%2Fannounce&tr=http%3A%2F%2Fbaz%3A321%2Fannounce\n\nQuickly add a comment to an existing torrent:\n\n.. code:: sh\n\n    $ torf -i docs.torrent --comment 'Forgot to add this comment.' -o docs.revised.torrent\n           Name  docs\n      Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02\n           Size  74.43 KiB\n        Comment  Forgot to add this comment.\n        Created  2020-03-31 21:23:42\n     Created By  torf 3.1.0\n        Private  yes\n       Trackers  http://bar:123/announce\n                 http://baz:321/announce\n     Piece Size  16 KiB\n    Piece Count  5\n     File Count  3\n          Files  docs\n                 \u251c\u2500torf.1 [14.53 KiB]\n                 \u251c\u2500torf.1.asciidoc [10.56 KiB]\n                 \u2514\u2500torf.1.html [49.34 KiB]\n         Magnet  magnet:?xt=urn:btih:0a9dfcf07feb2a82da11b509e8929266d8510a02&dn=docs&xl=76217&tr=http%3A%2F%2Fbar%3A123%2Fannounce&tr=http%3A%2F%2Fbaz%3A321%2Fannounce\n        Torrent  docs.revised.torrent\n\nVerify the files in ``docs``:\n\n.. code:: sh\n\n    $ <edit torf.1.html>\n    $ torf -i docs.revised.torrent docs\n           Name  docs\n      Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02\n           Size  74.43 KiB\n        Comment  Forgot to add this comment.\n        Created  2020-03-31 21:23:42\n     Created By  torf 3.1.0\n        Private  yes\n       Trackers  http://bar:123/announce\n                 http://baz:321/announce\n     Piece Size  16 KiB\n    Piece Count  5\n     File Count  3\n          Files  docs\n                 \u251c\u2500torf.1 [14.53 KiB]\n                 \u251c\u2500torf.1.asciidoc [10.56 KiB]\n                 \u2514\u2500torf.1.html [49.34 KiB]\n           Path  docs\n      Info Hash  0a9dfcf07feb2a82da11b509e8929266d8510a02\n          Error  docs/torf.1.html: Too big: 50523 instead of 50522 bytes\n          Error  Corruption in piece 2, at least one of these files is corrupt:\n                   docs/torf.1.asciidoc\n                   docs/torf.1.html\n       Progress  100.00 % | 0:00:00 total | 72.69 MiB/s\n    torf: docs does not satisfy docs.revised.torrent\n\nGet a list of files via ``grep`` and ``cut``:\n\n.. code:: sh\n\n    $ torf -i docs.revised.torrent | grep '^Files' | cut -f2-\n    docs/torf.1     docs/torf.1.asciidoc    docs/torf.1.html\n    # Files are delimited by a horizontal tab (``\\t``)\n\nGet a list of files via `jq <https://stedolan.github.io/jq/>`_:\n\n.. code:: sh\n\n    $ torf -i docs.revised.torrent --json | jq .Files\n    [\n      \"docs/torf.1\",\n      \"docs/torf.1.asciidoc\",\n      \"docs/torf.1.html\"\n    ]\n\nGet metainfo as JSON:\n\n.. code:: sh\n\n    $ torf -i docs.revised.torrent -m\n    {\n        \"announce\": \"http://bar:123/announce\",\n        \"announce-list\": [\n            [\n                \"http://bar:123/announce\"\n            ],\n            [\n                \"http://baz:321/announce\"\n            ]\n        ],\n        \"comment\": \"Forgot to add this comment.\",\n        \"created by\": \"torf 3.1.0\",\n        \"creation date\": 1585682622,\n        \"info\": {\n            \"name\": \"docs\",\n            \"piece length\": 16384,\n            \"private\": 1,\n            \"files\": [\n                {\n                    \"length\": 14877,\n                    \"path\": [\n                        \"torf.1\"\n                    ]\n                },\n                {\n                    \"length\": 10818,\n                    \"path\": [\n                        \"torf.1.asciidoc\"\n                    ]\n                },\n                {\n                    \"length\": 50522,\n                    \"path\": [\n                        \"torf.1.html\"\n                    ]\n                }\n            ]\n        }\n    }\n\n\nInstallation\n------------\n\nThe latest release is available on `PyPI <https://pypi.org/project/torf-cli>`_\nand on `AUR <https://aur.archlinux.org/packages/torf-cli/>`_.\n\n\npipx\n````\n\nThe easiest and cleanest installation method is `pipx\n<https://pipxproject.github.io/pipx/>`__, which installs each application with all\ndependencies in a separate virtual environment in ``~/.local/venvs/`` and links\nthe executable to ``~/.local/bin/``.\n\n.. code:: sh\n\n    $ pipx install torf-cli\n    $ pipx upgrade torf-cli\n    $ pipx uninstall torf-cli  # Also removes dependencies\n\nThe only drawback is that, at the time of writing, pipx doesn't make the man\npage available, but `it's also available here\n<https://rndusr.github.io/torf-cli/torf.1.html>`_.\n\n\npip\n```\n\nThe alternative is regular `pip <https://pypi.org/project/torf/>`__, but if you\ndecide to uninstall, you have to manually uninstall the dependencies.\n\n.. code:: sh\n\n    $ pip3 install torf-cli         # Installs system-wide (/usr/local/)\n    $ pip3 install --user torf-cli  # Installs in your home (~/.local/)\n\nThe `latest development version <https://github.com/rndusr/torf-cli>`_ is\navailable on GitHub in the master branch.\n\n.. code:: sh\n\n    $ pip3 install [--user] git+https://github.com/rndusr/torf-cli.git\n\n\nContributing\n------------\n\nBug reports and feature requests are welcome in the `issue tracker\n<https://github.com/rndusr/torf-cli/issues>`_.\n\n\nLicense\n-------\n\ntorf-cli is free software: you can redistribute it and/or modify it under the\nterms of the GNU General Public License as published by the Free Software\nFoundation, either version 3 of the License, or (at your option) any later\nversion.\n\nThis program is distributed in the hope that it will be useful but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE. See the `GNU General Public License\n<https://www.gnu.org/licenses/gpl-3.0.txt>`_ for more details.\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "CLI tool to create, read and edit torrent files",
    "version": "5.2.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/rndusr/torf-cli/issues",
        "Changelog": "https://raw.githubusercontent.com/rndusr/torf-cli/master/CHANGELOG",
        "Documentation": "https://rndusr.github.io/torf-cli/torf.1.html",
        "Repository": "https://github.com/rndusr/torf-cli"
    },
    "split_keywords": [
        "bittorrent",
        " torrent",
        " magnet",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "656b3e5ed8d8f40ece21e5b47d330aad608d35d6435dca39cc82cdf0070af30a",
                "md5": "9215c2bc409b79a25bf72c96716bcb05",
                "sha256": "8a9cd9e625ed809b445b62531cc66c065d9b74faaf0e63a3f437b85c04fdaac7"
            },
            "downloads": -1,
            "filename": "torf_cli-5.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9215c2bc409b79a25bf72c96716bcb05",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 68929,
            "upload_time": "2024-03-25T10:55:38",
            "upload_time_iso_8601": "2024-03-25T10:55:38.838608Z",
            "url": "https://files.pythonhosted.org/packages/65/6b/3e5ed8d8f40ece21e5b47d330aad608d35d6435dca39cc82cdf0070af30a/torf_cli-5.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b2a7f0a7dd35f5e7b7f292681102ed5e996f40201d1ea190167f56b40703f92",
                "md5": "06e94bdc41defdd5ce976b5937d93f2e",
                "sha256": "35a9d5b60d47f6c9a8362d3fabfc3326f7aa54229d734926ee3b9167e8c34e88"
            },
            "downloads": -1,
            "filename": "torf-cli-5.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "06e94bdc41defdd5ce976b5937d93f2e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 59359,
            "upload_time": "2024-03-25T10:55:41",
            "upload_time_iso_8601": "2024-03-25T10:55:41.571337Z",
            "url": "https://files.pythonhosted.org/packages/1b/2a/7f0a7dd35f5e7b7f292681102ed5e996f40201d1ea190167f56b40703f92/torf-cli-5.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 10:55:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rndusr",
    "github_project": "torf-cli",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "tox": true,
    "lcname": "torf-cli"
}
        
Elapsed time: 0.25946s