6

I downloaded a torrent file http://cdimage.debian.org/cdimage/stretch_di_rc1/amd64/bt-cd/debian-stretch-DI-rc1-amd64-netinst.iso.torrent

Now I want to parse/read it so that I can find out things like -

a. Which software was used to create the torrent file ?

b. The size of the iso image, the size and number of pieces

c. Number of trackers which the iso image.

All of which is meta-data.

I guess I'm looking for what mediainfo is for a media file -

[$] mediainfo Big_Buck_Bunny_small.ogv                                                                                              
General
ID                                       : 30719 (0x77FF)
Complete name                            : Big_Buck_Bunny_small.ogv
Format                                   : Ogg
File size                                : 2.65 MiB
Duration                                 : 1 min 19 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 280 kb/s
Writing application                      : ffmpeg2theora-0.25
SOURCE_OSHASH                            : cc9e38e85baf7573

Video
ID                                       : 20319 (0x4F5F)
Format                                   : Theora
Duration                                 : 1 min 19 s
Bit rate                                 : 212 kb/s
Nominal bit rate                         : 238 kb/s
Width                                    : 240 pixels
Height                                   : 134 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 24.000 FPS
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.275
Stream size                              : 2.01 MiB (76%)
Writing library                          : Xiph.Org libtheora 1.1 20090822 (Thusnelda)

Audio
ID                                       : 13221 (0x33A5)
Format                                   : Vorbis
Format settings, Floor                   : 1
Duration                                 : 1 min 19 s
Bit rate mode                            : Variable
Bit rate                                 : 48.0 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Stream size                              : 465 KiB (17%)
Writing library                          : libVorbis 20090709 (UTC 2009-07-09)

Is there something similar ? I am looking for a CLI tool .

7
  • 3
    dumptorrent Jan 31, 2017 at 21:40
  • saw it, couldn't find the source-code :(
    – shirish
    Jan 31, 2017 at 22:04
  • that is the source code... Jan 31, 2017 at 22:06
  • lol...yes. I was able to compile and use it, so it works :)
    – shirish
    Jan 31, 2017 at 22:46
  • Well, if you find/test more of them you can always post an answer and list the pros/cons of each - I'm sure some people will find it useful. Feb 1, 2017 at 21:32

4 Answers 4

9

transmission has a tool for that

$ transmission-show debian-stretch-DI-rc1-amd64-netinst.iso.torrent 
Name: debian-stretch-DI-rc1-amd64-netinst.iso
File: debian-stretch-DI-rc1-amd64-netinst.iso.torrent

GENERAL

  Name: debian-stretch-DI-rc1-amd64-netinst.iso
  Hash: 13d51b233d37965a7137dd65858d73c5a2e7ded4
  Created by: 
  Created on: Fri Jan 13 12:29:09 2017
  Comment: "Debian CD from cdimage.debian.org"
  Piece Count: 1184
  Piece Size: 256.0 KiB
  Total Size: 310.4 MB
  Privacy: Public torrent

TRACKERS

  Tier #1
  http://bttracker.debian.org:6969/announce

FILES

  debian-stretch-DI-rc1-amd64-netinst.iso (310.4 MB)

Another one would be intermodal which besides showing metadata can also create and verify it: https://rodarmor.com/blog/intermodal

2
  • I actually do use that, but do find that the output could probably be optimised a bit.
    – shirish
    Feb 2, 2017 at 11:24
  • Transmission-show doesn't seem to get installed by transmission in Ubuntu 22.04 (although it looks like it's still in the source code). Intermodal works great though!
    – Joe
    Oct 15 at 9:16
5

Another alternative is torrenttools.

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

For output that is easy to use in shell scripts you can use the torrenttools show subcommand.

A. Which software was used to create the torrent file ?

torrenttools show created-by bittorrent-v2-hybrid-test.torrent

b. The size of the file contents.

torrenttools show size bittorrent-v2-hybrid-test.torrent

c. Number of trackers.

torrenttools show announce CAMELYON17.torrent | wc -l

You can find torrenttools here: https://github.com/fbdtemme/torrenttools

Disclaimer: I am the author of this tool.

4
  • have you tried packaging it for debian, it would be a good tool to have it in there.
    – shirish
    Apr 20, 2021 at 15:50
  • A package for Debian Unstable is now available. For older Debian releases you can use the AppImage.
    – fbdtemme
    Apr 24, 2021 at 15:00
  • what is the name of the package under which you packaged it. When did you upload it on the archive. I'm using sid or Debian unstable and can't find it. A search for torrenttools gives nada - tracker.debian.org/search?package_name=torrenttools
    – shirish
    May 2, 2021 at 22:39
  • I did not upload to the official debian repo's because of all the bureaucracy needed to become a maintainer. I created repo using OpenSUSE build system (OBS). You can add it to apt with the commands listed here: github.com/fbdtemme/torrenttools#debian.
    – fbdtemme
    May 5, 2021 at 12:19
4

One alternative is lstor. And you did not say what you mean by "optimize a bit".

$ lstor debian-stretch-DI-rc1-amd64-netinst.iso.torrent 
NAME debian-stretch-DI-rc1-amd64-netinst.iso.torrent
SIZE 296.0 MiB (1184 * 256.0 KiB + 0 bytes)
META 23.6 KiB (pieces 23.1 KiB 98.1%)
HASH 13D51B233D37965A7137DD65858D73C5A2E7DED4
URL  http://bttracker.debian.org:6969/announce
PRV  NO (DHT/PEX enabled)
TIME 2017-01-13 12:29:09
REM  "Debian CD from cdimage.debian.org"

FILE LISTING
debian-stretch-DI-rc1-amd64-netinst.iso                               296.0 MiB
3

I was looking for a tool that could do this that was available in the Debian package repository, and I found BtCheck (btcheck package in Debian/Ubuntu). It's intended first and foremost as a verification utility and its metadata interrogation capabilities are limited, but with the -iinfo, -verbose, and -no-check flags, it gives everything you're looking for:

$ btcheck -i -v -n bbb_sunflower_1080p_60fps_normal.mp4.torrent
Announce URL : udp://tracker.openbittorrent.com:80/announce
    announce : udp://tracker.openbittorrent.com:80/announce
    announce : udp://tracker.publicbt.com:80/announce
    web seed : http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4
File Name    : bbb_sunflower_1080p_60fps_normal.mp4
File Length  : 355856562
Piece Length : 524288
Torrent Hash : 565db305a27ffb321fcc7b064afd7bd73aedda2b
Creat. Date  : Tue Dec 17 19:22:39 2013
Created By   : uTorrent/3320
Comment      : Big Buck Bunny, Sunflower version

Which software was used to create the torrent file ?

That's given by “Created By”.

The size of the iso image, the size and number of pieces

The first two of those are given by “File Length” and “Piece Length”, respectively. The number of pieces can be calculated as “File Length” / “Piece Length”.

Number of trackers which the iso image.

If the torrent has multiple announce URLs, BtCheck will print each one on its own line. Everything after the first one is just labelled “announce”. Weirdly, BtCheck repeats the first announce URL, but only when there's more than one announce URL – if there's only one, you'll just get a single “Announce URL” line, and no “announce”s. An only-slightly-fragile way to deduplicate and count these:

$ btcheck -i -v -n bbb_sunflower_1080p_60fps_normal.mp4.torrent | grep '^Announce URL\|^    announce' | cut -c 16- | uniq | wc -l
2
3
  • I only included it because I thought it did include enough information to answer the OP's, yes. They asked for: a. “Which software was used to create the torrent file ?” – given by “Created By”. b. “The size of the iso image, the size and number of pieces” – given by “File Length”, “Piece Length”, and “File Length” / “Piece Length”, respectively. c. “Number of trackers which the iso image.” – given by the number of “Announce URL” lines printed. It's not a general-purpose metadata exploration tool, but it does answer OP's questions (as well as my own).
    – Mr. DOS
    Feb 23 at 10:46
  • Fair enough! I've expanded my answer to demonstrate how BtCheck can answer the OP's questions.
    – Mr. DOS
    Feb 23 at 13:50
  • Nice! In the meantime your answer prompted me to install btcheck. It's always nice to have basic tools like this straight from the distro's repos :-) Feb 23 at 15:13

You must log in to answer this question.

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