Owez / torro

A correct and easy-to-use BitTorrent library
MIT License
9 stars 0 forks source link

Torrent struct #6

Closed Owez closed 3 years ago

Owez commented 3 years ago

A new Torrent structure has been added, acting as the "key" for the library once parsed by the parse function

Owez commented 3 years ago

Need to figure out private data fields and what the following spec means:

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 UTF-8 encoded 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.