medariox / scrapeer

Essential PHP library that scrapes HTTP(S) and UDP trackers for torrent information.
93 stars 29 forks source link

My Srape return information from 1 tracker inseatd of 30 #19

Closed Machou closed 5 years ago

Machou commented 5 years ago

Hi

I use this code :

require 'cfg/class.scraper.php';
$scraper = new Scrapeer\Scraper();

$trackers = array(_ARRAY_OF_30_TRACKERS_);
$hash = array( '03BB57EA1F7E8DC9CC7DA349B549D7A7C5BC3359' );

$info = $scraper->scrape( $hash, $trackers );

He return only 1 info :

Array ( [03BB57EA1F7E8DC9CC7DA349B549D7A7C5BC3359] => Array ( [seeders] => 293 [completed] => 19740 [leechers] => 38 )

)

Why doesn't it return the information from all the scrapped trackers?

medariox commented 5 years ago

This is how it is supposed to work, see: https://github.com/medariox/scrapeer#single-info-hash-and-multiple-trackers-recommended-usage

First tracker in the array will be used, if it fails (invalid tracker, invalid info-hash or invalid info-hash for that tracker) the second tracker will be used and so on.

Machou commented 5 years ago

In fact, I thought that if I scrapped 30 trackers, he would give me the information from the 30 trackers, not the 1st functional one.

So I made a loop that checks each tracker 1 by 1 and returns the results in a array.

medariox commented 5 years ago

That's the correct way to do it. Scrapeer won't provide that functionality, because scraping every tracker for each torrent is something very inefficient to do, that should possibly be avoided.

Machou commented 5 years ago

ok thanks, so it's not a bug; i close :p