scrape() public method

* static
public scrape ( $announce = null, $hash_info = null, $timeout = self::timeout )
require_once 'Torrent.class.php';
// create torrent
$torrent = new Torrent('./torrents', 'http://torrent.tracker/annonce');
if (!($error = $torrent->error())) {
    $torrent->save('test.torrent');
    // save to disk
} else {
    echo '<br>DEBUG: ', $error;
    // error method return the last error message
}
// print torrent info
$torrent = new Torrent('./test.torrent');
echo '<pre>private: ', $torrent->is_private() ? 'yes' : 'no', '<br>annonce: ';
var_dump($torrent->announce());
echo '<br>name: ', $torrent->name(), '<br>comment: ', $torrent->comment(), '<br>piece_length: ', $torrent->piece_length(), '<br>size: ', $torrent->size(2), '<br>hash info: ', $torrent->hash_info(), '<br>stats: ';
var_dump($torrent->scrape());
echo '<br>content: ';
var_dump($torrent->content());
echo '<br>source: ', $torrent;
// modify torrent
$torrent->announce('http://alternate-torrent.tracker/annonce');
// add a tracker
$torrent->announce(false);
// reset announce trackers
$torrent->announce(array('http://torrent.tracker/annonce', 'http://alternate-torrent.tracker/annonce'));
// set tracker(s), it also works with a 'one tracker' array...
$torrent->announce(array(array('http://torrent.tracker/annonce', 'http://alternate-torrent.tracker/annonce'), 'http://another-torrent.tracker/annonce'));
// set tiered trackers
$torrent->comment('hello world');
$torrent->name('test torrent');
$torrent->is_private(true);
Beispiel #2
0
<?php

require_once 'Torrent.php';
header('Content-type: text/plain');
$torrent = new Torrent(file_get_contents('/media/htpc/bit.torrents/tv/Squidbillies.torrent'));
$hash = $torrent->hash_info();
$files = $torrent->content();
$scrape = $torrent->scrape(null, null, 3);
print_r(array('hash' => $hash, 'files' => $files, 'scrape' => $scrape));