Jump to content

Torrent File Structure


Recommended Posts

Hi, does anyone know the format for the .torrent files?

i want to make a program that reads a torrent file and checks which parts of the files that i have are correct and which parts are not. i don't want to make a bittorrent client, i want to use it as a file checker.

So if anyone can help me out with the structure of the file, i'd be greatfull.

P.S. when i say structure of the file i mean, for example: announceurl - X bytes, date - X bytes, .....

Thanx in advance....

Link to comment
Share on other sites

Thanx, but that's not what i'm looking for. as i said i'm not going to make a client, so i don't care about the protocol. i only want to make a program just to check what parts of a file are correct, so i only need the format of the torrent file.

i.e. i only want to implement the checking part of utorrent (open .torrent file, check for file parts i have) and that's it.

Link to comment
Share on other sites

This part I'm referring:

Metainfo files are bencoded dictionaries with the following keys:


The URL of the tracker.


This maps to a dictionary, with keys described below.

The name key maps to a string which is the suggested name to save the file (or directory) as. It is purely advisory.

piece length maps to the number of bytes in each piece the file is split into. For the purposes of transfer, files are split into fixed-size pieces which are all the same length except for possibly the last one which may be truncated. piece length is almost always a power of two, most commonly 2 18 = 256 K (BitTorrent prior to version 3.2 uses 2 20 = 1 M as default).

pieces maps to a string whose length is a multiple of 20. It is to be subdivided into strings of length 20, each of which is the SHA1 hash of the piece at the corresponding index.

There is also a key length or a key files, but not both or neither. If length is present then the download represents a single file, otherwise it represents a set of files which go in a directory structure.

In the single file case, length maps to the length of the file in bytes.

For the purposes of the other keys, the multi-file case is treated as only having a single file by concatenating the files in the order they appear in the files list. The files list is the value files maps to, and is a list of dictionaries containing the following keys:

length - The length of the file, in bytes.

path - A list of strings corresponding to subdirectory names, the last of which is the actual file name (a zero length list is an error case).

In the single file case, the name key is the name of a file, in the muliple file case, it's the name of a directory.

This does not describe the .torrent file? What else do you want to know?

For bencode format, see http://en.wikipedia.org/wiki/Bencode

Link to comment
Share on other sites

Yeah, and if you check the links on bencode page, you come back to bittorrent.org.

You should read the posts, and not only the direct links we give. Also the links on the page and subpages are readable.

Try to read, and make your life easier (and ours too). :/

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...