How to get information from .torrent files?

5

I would like to know how to get information from a .torrent file using some of these classes:

asked by anonymous 09.05.2015 / 22:20

1 answer

5

To display information for a torrent file with class Torrent-RW , do the following:

require "Torrent.php";

$torrent = new Torrent('ubuntu-14.10-desktop-i386.iso.torrent');
echo '<pre>Privado? ', $torrent->is_private() ? 'Sim' : 'Não',
     '<br>Anúncio: ';
var_dump($torrent->announce());
echo '<br>Arquivo: ', $torrent->name(),
     '<br>Comentário: ', $torrent->comment(),
     '<br>Tamanho em pedaços: ', $torrent->piece_length(),
     '<br>Tamanho: ', $torrent->size(2),
     '<br>HASH: ', $torrent->hash_info(),
     '<br>Status: ';
var_dump($torrent->scrape());

The result will look something like this:

Privado? Não
Anúncio: array(2) {
  [0]=>
  array(1) {
    [0]=>
    string(39) "http://torrent.ubuntu.com:6969/announce"
  }
  [1]=>
  array(1) {
    [0]=>
    string(44) "http://ipv6.torrent.ubuntu.com:6969/announce"
  }
}

Arquivo: ubuntu-14.10-desktop-i386.iso
Comentário: Ubuntu CD releases.ubuntu.com
Tamanho em pedaços: 524288
Tamanho: 1.11 Go
HASH: 1619ecc9373c3639f4ee3e261638f29b33a6cbd6
Status: array(2) {
  ["http://ipv6.torrent.ubuntu.com:6969/scrape"]=>
  string(29) "Tracker request timeout (30s)"
  ["http://torrent.ubuntu.com:6969/scrape"]=>
  array(4) {
    ["complete"]=>
    int(1609)
    ["downloaded"]=>
    int(29)
    ["incomplete"]=>
    int(72)
    ["name"]=>
    string(29) "ubuntu-14.10-desktop-i386.iso"
  }
}
    
09.05.2015 / 22:44