File Formats Wiki
Advertisement
Check
Blank

Filename extension .torrent
Internet media type c706de10d03b7d5c5007692e89418f20e192973d
File formats category - v  e   edit
Torrent file
Blank

File formats category - v  e   edit

A torrent file (.torrent file, BitTorrent metainfo file) is required by a BitTorrent client to initiate file transfer using the BitThborrent protocol.

bencoding[]

bencoding is a way to store some data structures in the torrent file format.

Strings
Strings are stored as <length of string>:<string>:
4:

wiki

Integers
Integers are stored as i<integer>e:
i

90 e

List
Lists are stored as l[value 1][value2][value3][...]e. For example, {spam, eggs, cheeseburger} is stored as:
l4:

spam 4: eggs 12: cheeseburger e

Dictionary
Dictionaries are stored as d[key1][value1][key2][value2][...]e. Keys and values appear alternately. Keys must be strings and must be ordered alphabetically. For example, {apple-red, lemon-yellow, violet-blue, banana-yellow} is stored as:
d5:

apple 3: red 6: banana 6: yellow 5: lemon 6: yellow 6: violet 4: blue e

Specification[]

Data in a torrent file is bencoded as a dictionary, with no other header. The top-level dictionary has the following keys:

Key Type Description
info dictionary File information for the torrent.
announce string The URL of the tracker for the torrent. For example, 29:

http://tracker.example.com:80

announce-list list A listing of the URLs of alternate trackers for the torrent. The URLs are divided into groups (each is a list), trackers in each group may be shuffled, and groups are processed in the order they appear. Optional.
creation date integer The creation date and time, expressed as the number of seconds since January 1, 1970 12:00. Optional.
comment string Any user comment for the torrent. Optional.
created by string Application-generated string that may include its name, version, etc. Optional.

File information (info)[]

The info key corresponds to the files in the torrent. There are two-forms: a single-file format that contains only a single file, and a multi-file format that may contain multiple files and directories. The info key itself corresponds to another (essentially "nested") dictionary with the keys as follows:

Common file keys[]

Key Type Description
piece length integer The number of bytes in each piece. Files in a torrents are divided into "pieces" with a specific length.
pieces string A (byte) string consisting of the concatenation of all 20-byte SHA1 hash values, one per piece.

Single-file format keys[]

Key Type Description
name string The proposed filename of the file.
length integer The length of the file, in bytes.

Multi-file format keys[]

Key Type Description
name string The proposed name of directory to store the files.
files list (of dictionary) A list of dictionaries, one dictionary for each file in the torrent, which is described in the next table.

A dictionary in the file list corresponds to one file and contains the following:

Key Type Description
length integer The length of the file, in bytes.
path list (of string) A list of strings representing the relative path to the file. For example, l6:

source 3: bin 8: test.exe e corresponds to the path "<directory name>\source\bin\test.exe".

References[]

Advertisement