Check | |
---|---|
Filename extension | .torrent |
Internet media type | c706de10d03b7d5c5007692e89418f20e192973d |
File formats category - |
Torrent file | |
---|---|
File formats category - |
A torrent file (.torrent file, BitTorrent metainfo file) is required by a BitTorrent client to initiate file transfer using the BitTorrent protocol.
Contents
bencoding[edit | edit source]
bencoding is a way to store some data structures in the torrent file format.
- Strings
- Strings are stored as <length of string>:<string>:
<span class="c-key">4:<span class="c-string">wiki
- Integers
- Integers are stored as
i<integer>e
:<span class="c-key">i<span class="c-number">90<span class="c-key">e
- List
- Lists are stored as
l[value 1][value2][value3][...]e
. For example, {spam, eggs, cheeseburger} is stored as:<span class="c-key">l4:<span class="c-string">spam<span class="c-key">4:<span class="c-string">eggs<span class="c-key">12:<span class="c-string">cheeseburger<span class="c-key">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:<span class="c-key">d5:<span class="c-string">apple<span class="c-key">3:<span class="c-string">red<span class="c-key">6:<span class="c-string">banana<span class="c-key">6:<span class="c-string">yellow<span class="c-key">5:<span class="c-string">lemon<span class="c-key">6:<span class="c-string">yellow<span class="c-key">6:<span class="c-string">violet<span class="c-key">4:<span class="c-string">blue<span class="c-key">e
Specification[edit | edit source]
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, <span class="c-key">29:<span class="c-string">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
)[edit | edit source]
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[edit | edit source]
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[edit | edit source]
Key | Type | Description |
---|---|---|
name | string | The proposed filename of the file. |
length | integer | The length of the file, in bytes. |
Multi-file format keys[edit | edit source]
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, <span class="c-key">l6:<span class="c-string">source<span class="c-key">3:<span class="c-string">bin<span class="c-key">8:<span class="c-string">test.exe<span class="c-key">e corresponds to the path "<directory name>\source\bin\test.exe".
|
References[edit | edit source]
- BitTorrent Specification
- Unofficial BitTorrent Specification at theory.org
Community content is available under CC-BY-SA unless otherwise noted.
... more about "Torrent file"
c706de10d03b7d5c5007692e89418f20e192973d +