How to use the Bitsnoop API

1

I would like to know how I can get the seeders and leechers from a .torrent file using API of Bitsnoop. How can I be performing the requisition?

    
asked by anonymous 12.05.2015 / 04:44

1 answer

2

You must make a GET request, and send as a parameter the hash key, the HASH value of the .torrent file, json .

error_reporting(E_STRICT);
include 'Torrent.php';

function obterSeedLeech($hash){
    $apiURL = "http://bitsnoop.com/api/trackers.php?hash={$hash}&json=1";
    $resultado = file_get_contents($apiURL);
    return $resultado;
}

$torrent = new Torrent('tails-i386-1.2.3.torrent'); // Especifique o arquivo torrent aqui
$torrentHash = $torrent->hash_info(); // HASH do arquivo torrent

$SeedsLeechs = obterSeedLeech($torrentHash);
$SeedsLeechs = json_decode($SeedsLeechs);
$seeds = $leechs = 0;

if (is_array($SeedsLeechs)){
    foreach($SeedsLeechs as $anuncios){
        $leechs += $anuncios->NUM_LEECHERS;
        $seeds += $anuncios->NUM_SEEDERS;
        echo "Anúncio: ". $anuncios->ANNOUNCE. " Seed: ". $anuncios->NUM_SEEDERS. " Leech: ". $anuncios->NUM_LEECHERS. "<br>";
    }
} else {
    // Fazer algo aqui caso não seja retornado as informações da hash.
}

//echo "Total de seeds: ". $seeds. "<br>";
//echo "Total de leechs: ". $leechs. "<br>";
    
12.05.2015 / 06:26