metatorrent v1.0.0 Metatorrent View Source

Decodes BitTorrent metainfo files.

The Metatorrent module can be used to decode a binary read from a file ending in .torrent.

iex> {:ok, metainfo} = Metatorrent.decode(File.read! "test/linuxmint-18.3-cinnamon-64bit.iso.torrent")
...> metainfo
#Metatorrent.Metainfo<["linuxmint-18.3-cinnamon-64bit.iso" d2e53fb603652d991991b6ad2357a7a2845a5319]>

Metatorrent also sticks some additional useful information into the map, like :info_hash, and the total :length for multi-file torrents. The data structure looks like this:

%Metatorrent.Metainfo{
  announce: "https://torrents.linuxmint.com/announce.php",
  announce_list: nil,
  comment: nil,
  created_by: "Transmission/2.84 (14307)",
  creation_date: 1511774851,
  info: %Metatorrent.SingleFileInfo{
    length: 1899528192,
    md5sum: nil,
    name: "linuxmint-18.3-cinnamon-64bit.iso",
    piece_length: 1048576,
    pieces: [
      <<167, 53, 69, 58, 13, 103, 134, 251, 174, 104, 105, 210, 94, 112, 197, 52,
  205, 246, 155, 130>>,
      ...
    ]
  },
  info_hash: <<210, 229, 63, 182, 3, 101, 45, 153, 25, 145, 182, 173, 35, 87,
    167, 162, 132, 90, 83, 25>>
}

Link to this section Summary

Functions

Decodes a metadata binary into an Elixir data structure.

Link to this section Functions

Decodes a metadata binary into an Elixir data structure.

Examples

iex> {:ok, metainfo} = Metatorrent.decode(File.read! "test/linuxmint-18.3-cinnamon-64bit.iso.torrent")
...> metainfo
#Metatorrent.Metainfo<["linuxmint-18.3-cinnamon-64bit.iso" d2e53fb603652d991991b6ad2357a7a2845a5319]>