45

I am interested in rendering a torrent file into a readable form (to see what files does it reference, what tracker information does it contain etc.). What a tool can I use to do just this?

8 Answers 8

56

You can use transmission-show, included in the Gnome Transmission BitTorrent client.

$ transmission-show amd64cd-5.1.2.iso.torrent
Name: amd64cd-5.1.2.iso
File: amd64cd-5.1.2.iso.torrent

GENERAL

  Name: amd64cd-5.1.2.iso
  Hash: e30c05f2330ba4869eefb90bf5978a505303b235
  Created by: 
  Created on: Sun Feb  5 01:31:29 2012
  Piece Count: 967
  Piece Size: 256.0 KiB
  Total Size: 253.3 MB
  Privacy: Public torrent

TRACKERS

  Tier #1
  http://tracker.netbsd.org:6969/announce

FILES

  amd64cd-5.1.2.iso (253.3 MB)

If you're using an older version of Transmission, you can use the older transmissioncli --info command:

$ transmissioncli --info amd64cd-5.1.2.iso.torrent
Transmission 2.03 (11030) - http://www.transmissionbt.com/
hash:   e30c05f2330ba4869eefb90bf5978a505303b235
name:   amd64cd-5.1.2.iso

tracker tier #1:
        announce:       http://tracker.netbsd.org:6969/announce
size:   253325312 (966 * 262144 + 94208)
file(s):
        amd64cd-5.1.2.iso (253325312)
5
  • -1 my version of transmission-cli (2.51 Debian testing amd64) does not have this option
    – ixtmixilix
    May 17, 2012 at 23:48
  • @ixtmixilix: Answer updated to use new "transmission-show" command.
    – Teddy
    May 24, 2012 at 16:54
  • 4
    For archlinux users, this is in extra/ as of April 2017. Win
    – user3356
    Apr 9, 2017 at 21:51
  • Is there a way to get transmission-show output to include exact file size? Useful to see if 2 torrents of the same thing might not be the exact same file after all. Oct 4, 2019 at 19:55
  • Very good works as expected!
    – Smeterlink
    Jun 21, 2023 at 19:12
34

You can use aria2.  From the aria2c(1) man page:

-S, --show-files[=true|false]

    Print file listing of ".torrent", ".meta4" and ".metalink" file and exit. In case of ".torrent" file, additional information (infohash, piece length, etc) is also printed.

$ aria2c -S ubuntu-14.04.2-desktop-i386.iso.torrent 
>>> Printing the contents of file 'ubuntu-14.04.2-desktop-i386.iso.torrent'...
*** BitTorrent File Information ***
Comment: Ubuntu CD releases.ubuntu.com
Creation Date: Thu, 19 Feb 2015 22:17:32 GMT
Mode: single
Announce:
 http://torrent.ubuntu.com:6969/announce
 http://ipv6.torrent.ubuntu.com:6969/announce
Info Hash: 33678ec8b0dfb8a9061348c8af7194268c0b8310
Piece Length: 512KiB
The Number of Pieces: 2006
Total Length: 0.9GiB (1,051,721,728)
Name: ubuntu-14.04.2-desktop-i386.iso
Magnet URI: magnet:?xt=urn:btih:33678EC8B0DFB8A9061348C8AF7194268C0B8310&dn=ubuntu-14.04.2-desktop-i386.iso&tr=http%3A%2F%2Ftorrent.ubuntu.com%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.torrent.ubuntu.com%3A6969%2Fannounce
Files:
idx|path/length
===+===========================================================================
  1|./ubuntu-14.04.2-desktop-i386.iso
   |0.9GiB (1,051,721,728)
---+---------------------------------------------------------------------------
3
  • 1
    it support glob pattern, aria2c -S *.torrent works.
    – Oboo Cheng
    Aug 16, 2019 at 11:08
  • 1
    @ObooCheng Actually, it's the shell that expands the glob pattern, not aria2c. Aug 14, 2020 at 7:55
  • Useful, as this is an app which works on my OSes.
    – Jiri B
    Mar 23, 2021 at 10:01
30

btshowmetainfo, formerly included in the BitTorrent distribution but now largely installed with BitTornado (a fork of the BitTorrent 3.x codebase), does just that.

$ btshowmetainfo amd64cd-5.1.2.iso.torrent 
btshowmetainfo 20030621 - decode BitTorrent metainfo files

metainfo file.: amd64cd-5.1.2.iso.torrent
info hash.....: e30c05f2330ba4869eefb90bf5978a505303b235
file name.....: amd64cd-5.1.2.iso
file size.....: 253325312 (966 * 262144 + 94208)
announce url..: http://tracker.netbsd.org:6969/announce
1
  • 6
    You can clone https://github.com/effigies/BitTornado and run python3 btshowmetainfo.py to run the script, since BitTornado seems long-since abandoned.
    – zymhan
    Dec 9, 2016 at 14:01
12

lstor, including the ability to calculate the hash, which can be quite useful in shell scripts:

$ lstor Chakra\ 2012.02\ Archimedes\ x86.torrent -qo __hash__
B3472076574BC666396766AB3B28C0054D740B46

$ lstor Chakra\ 2012.02\ Archimedes\ x86.torrent -q
NAME Chakra 2012.02 Archimedes x86.torrent
SIZE 1.4 GiB (1461 * 1.0 MiB + 0 bytes)
HASH B3472076574BC666396766AB3B28C0054D740B46
URL  http://linuxtracker.org:2710/********************************/announce
PRV  YES (DHT/PEX disabled)
TIME 2012-02-13 17:10:28
BY   qBittorrent v2.9.3

FILE LISTING
chakra-2012.02-Archimedes-i686.iso                                      1.4 GiB

$ lstor Chakra\ 2012.02\ Archimedes\ x86.torrent -q --raw
{'announce': 'http://linuxtracker.org:2710/********************************/announce',
 'created by': 'qBittorrent v2.9.3',
 'creation date': 1329149428,
 'info': {'length': 1531969536,
          'name': 'chakra-2012.02-Archimedes-i686.iso',
          'piece length': 1048576,
          'pieces': '<1461 piece hashes>',
          'private': 1},
 'url-list': ''}
4

You can use torrenttools.

torrenttools info test.torrent

Metafile:         /home/fbdtemme/Downloads/Fedora-Workstation-Live-x86_64-33.torrent
Protocol version: v1
Infohash:         7707056a138a00dd9b9eff4fab29f46233e2bad9
Piece size:       256 KiB (262144 bytes)
Created by:       
Created on:       2020-10-26 15:52:05 UTC
Private:          false
Name:             Fedora-Workstation-Live-x86_64-33
Source:           
Comment:          

Announces:
tier 1  - http://torrent.fedoraproject.org:6969/announce

Files:
Fedora-Workstation-Live-x86_64-33
  ├── [1.04 KiB] Fedora-Workstation-33-1.2-x86_64-CHECKSUM
  └── [1.91 GiB] Fedora-Workstation-Live-x86_64-33-1.2.iso

  1.91 GiB in 0 directories, 2 files

You can also retrieve specific fields only which can be useful in shell scripts.

torrenttools show infohash test.torrent

17ebe3685a498afcc06e2241e875a1726e7c38c2

torrenttools show announce Fedora-Workstation-Live-x86_64-33.torrent

http://torrent.fedoraproject.org:6969/announce

It can be useful to view the decoded torrent file in json format.

torrenttools info --raw Fedora-Workstation-Live-x86_64-33.torrent

{
    "announce": "http://torrent.fedoraproject.org:6969/announce",
    "creation date": 1603727525,
    "info": {
        "files": [
            {
                "length": 1062,
                "path": [
                    "Fedora-Workstation-33-1.2-x86_64-CHECKSUM"
                ]
            },
            {
                "length": 2049490944,
                "path": [
                    "Fedora-Workstation-Live-x86_64-33-1.2.iso"
                ]
            }
        ],
        "name": "Fedora-Workstation-Live-x86_64-33",
        "piece length": 262144,
        "pieces": "<7819 piece hashes>"
    }
}

You can expand the pieces field with the --show-pieces options.

torrenttools info --raw --show-pieces Fedora-Workstation-Live-x86_64-33.torrent

{
    "announce": "http://torrent.fedoraproject.org:6969/announce",
    "creation date": 1603727525,
    "info": {
        "files": [
            {
                "length": 1062,
                "path": [
                    "Fedora-Workstation-33-1.2-x86_64-CHECKSUM"
                ]
            },
            {
                "length": 2049490944,
                "path": [
                    "Fedora-Workstation-Live-x86_64-33-1.2.iso"
                ]
            }
        ],
        "name": "Fedora-Workstation-Live-x86_64-33",
        "piece length": 262144,
        "pieces": [
            "<piece: 0, SHA1: 52095a748e9337d31631fce7fe6d7d5a40f60352>",
            "<piece: 1, SHA1: 5a241db1f3d0e6b794d04594253b5c1931cacafe>",
            "<piece: 2, SHA1: 06adbe76ca7764c142fd2c00f57fab5dc7667171>",
            "<piece: 3, SHA1: 40893918608f042fe41abcc4e4f4e04f92ad3665>",
            "<piece: 4, SHA1: 0b491f424e765b64ef38329e1935bd2c3ceff4e0>",
            "<piece: 5, SHA1: deffa6b0a4ca6b11b04caa785a4ef80b0ee4a238>",
            ...

torrenttools can also work with the new BitTorrent v2 metafiles and hybrid torrents.

torrenttools info bittorrent-v2-hybrid-test.torrent

Metafile:         /home/fbdtemme/Documents/project/torrent/torrenttools/tests/resources/bittorrent-v2-hybrid-test.torrent
Protocol version: v1 + v2 (hybrid)
Infohash:         v1: 8c9a2f583949c757c32e085413b581067eed47d0
                  v2: d8dd32ac93357c368556af3ac1d95c9d76bd0dff6fa9833ecdac3d53134efabb
Piece size:       512 KiB (524288 bytes)
Created by:       libtorrent
Created on:       2020-06-03 08:45:06 UTC
Private:          false
Name:             bittorrent-v1-v2-hybrid-test
Source:           
Comment:          

Announces:

Files:
bittorrent-v1-v2-hybrid-test
  ├── [6.23 MiB] Darkroom (Stellar, 1994, Amiga ECS) HQ.mp4
  ├── [19.6 MiB] Spaceballs-StateOfTheArt.avi
  ├── [ 326 MiB] cncd_fairlight-ceasefire_(all_falls_down)-1080p.mp4
  ├── [58.8 MiB] eld-dust.mkv
  ├── [ 265 MiB] fairlight_cncd-agenda_circling_forth-1080p30lq.mp4
  ├── [42.5 MiB] meet the deadline - Still _ Evoke 2014.mp4
  ├── [61.0   B] readme.txt
  ├── [25.1 MiB] tbl-goa.avi
  └── [ 111 MiB] tbl-tint.mpg

  854.06 MiB in 0 directories, 9 files

Disclaimer: I am the author of this tool.

For more information see:

2

You can use Torrent File Editor Files tab
(source: fsdn.com)
Raw tab

Also .torrent file can be converted to .json format with command line --to-json.

2

exiftool can show basic information and list the files:

$ exiftool my.torrent
ExifTool Version Number         : 10.20
File Name                       : my.torrent
...
Announce                        : udp://ammounce.url:80/announce
Create Date                     : 2023:01:15 04:00:00+01:00
File 1 Length                   : 15 MB
File 1 Path                     : afile.zip
File 2 Length                   : 33 MB
File 2 Length                   : anotherfile.zip
...
Name                            : some-random-files
Piece Length                    : 16777200
Pieces                          : (Binary data 161000 bytes, use option -b to extract)
1

Use btshowmetainfo.py from https://github.com/effigies/BitTornado. Clone it and run python3 btshowmetainfo.py file.torrent to run the script.

For, convenience, I created a container for it. Example usage:

wget https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso.torrent

docker run \
    --rm \
    --volume "$(pwd)/ubuntu-20.04.2-live-server-amd64.iso.torrent:/a.torrent" \
    btshowmetainfo/btshowmetainfo

gives

btshowmetainfo 20130326 - decode BitTorrent metainfo files

metainfo file.: a.torrent
info hash.....: 126f82fb33119d2acf93a16cfba6eb1c5787a59f
file name.....: ubuntu-20.04.2-live-server-amd64.iso
file size.....: 1215168512 (4635 * 262144 + 131072)
announce url..: https://torrent.ubuntu.com/announce
announce-list.: https://torrent.ubuntu.com/announce|https://ipv6.torrent.ubuntu.com/announce
comment.......: Ubuntu CD releases.ubuntu.com

See:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .