Example: d4:spaml1:a1:bee represents the dictionary { "spam" => ["a", "b"] }
Metainfo File Structure
All data in a metainfo file is bencoded. The specification for bencoding is defined above.
The content of a metainfo file (the file ending in ".torrent") is a bencoded dictionary, containing the keys listed below. All character string values are UTF-8 encoded. Keys not marked 'optional' are required fields:
-
info: a dictionary that describes the file(s) of the torrent. There are two possible forms: one for the case of a 'single-file' torrent with no directory structure, and one for the case of a 'multi-file' torrent, which can contain subdirectory trees.
- For the case of the single-file mode, the info dictionary contains the following structure
-
- length: length of the file in bytes (integer)
- md5sum: (optional) a 32-character hexadecimal string corresponding to the MD5 sum of the file. This is not used by BitTorrent at all, but it is included by some programs for greater compatibility.
- name: the filename of the file. This is purely advisory. (string)
- piece length: number of bytes in each piece (integer)
- pieces: string consisting of the concatenation of all 20-byte SHA1 hash values, one per piece (byte string)
- For the case of the multi-file mode, the info dictionary contains the following structure
-
-
files: a list of dictionaries, one for each file. Each dictionary in this list contains the following keys:
- length: length of the file in bytes (integer)
- md5sum: (optional) a 32-character hexadecimal string corresponding to the MD5 sum of the file. This is not used by BitTorrent at all, but it is included by some programs for greater compatibility.
- path: a list containing one or more string elements that together represent the path and filename. Each element in the list corresponds to either a directory name or (in the case of the final element) the filename. For example, a the file "dir1/dir2/file.ext" would consist of three string elements: "dir1", "dir2", and "file.ext". This is encoded as a bencoded list of strings such as l4:dir14:dir28:file.exte
- name: the name of the top-most directory in the structure -- the directory which contains all of the files listed in the above files list. (character string)
- piece length: number of bytes in each piece (integer)
- pieces: string consisting of the concatenation of all 20-byte SHA1 hash values, one per piece (byte string)
-
- announce: The announce URL of the tracker (string)
- announce-list: (optional) this is an extention to the official specification, which is also backwards compatible. This key is used to implement lists of backup trackers. The full specification can be found at
http://home.elp.rr.com/tur/multitracker-spec.txt
- creation date: (optional) the creation time of the torrent, in standard Unix epoch format (integer seconds since 1-Jan-1970 00:00:00 UTC)
- comment: (optional) free-form textual comments of the author (string)
- created by: (optional) name and version of the program used to create the .torrent (string)
- Notes
-
- The piece length specifies the nominal piece size, and is usually a power of 2. The piece size is typically chosen based on the total amount of file data in the torrent, constrained by the fact that too small a piece size will result in a large .torrent metadata file, and piece sizes too large cause inefficiency. The general rule of thumb seems to be to pick the smallest piece size that result