public function testScrape() { if (!(bool) ini_get('allow_url_fopen')) { $this->markTestSkipped(); } // Decode the torrent $File_Bittorrent2_Decode = new File_Bittorrent2_Decode(); $temp = tempnam(sys_get_temp_dir(), __CLASS__); file_put_contents($temp, file_get_contents('http://torrents.thepiratebay.org/4442311/Brothers.and .Sisters.S03E03.HDTV.XviD-NoTV.avi.4442311.TPB.torrent')); $File_Bittorrent2_Decode->decodeFile($temp); $stats = $File_Bittorrent2_Decode->getStats(); unlink($temp); }
* * Usage: * # php scrape.php -t file * * @author Markus Tacker <*****@*****.**> * @version $Id$ */ // Includes require_once 'File/Bittorrent2/Decode.php'; require_once 'Console/Getargs.php'; // Get filename from command line $args_config = array('torrent' => array('short' => 't', 'min' => 1, 'max' => 1, 'desc' => 'Filename of the torrent')); $args =& Console_Getargs::factory($args_config); if (PEAR::isError($args) or !($torrent = $args->getValue('torrent'))) { echo Console_Getargs::getHelp($args_config) . "\n"; exit; } if (!is_readable($torrent)) { echo 'ERROR: "' . $torrent . "\" is not readable.\n"; exit; } // Decode the torrent $File_Bittorrent2_Decode = new File_Bittorrent2_Decode(); $File_Bittorrent2_Decode->decodeFile($torrent); echo "\nStatistics\n"; echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; echo 'Tracker: ' . $File_Bittorrent2_Decode->getAnnounce() . "\n"; echo 'info hash: ' . $File_Bittorrent2_Decode->getInfoHash() . "\n"; foreach ($File_Bittorrent2_Decode->getStats() as $key => $val) { echo str_pad($key . ':', 20) . $val . "\n"; }