This commit is contained in:
Roman Kelesidis 2025-01-08 12:50:20 +07:00
commit 13369c16c9
2 changed files with 28 additions and 5 deletions

View file

@ -731,6 +731,7 @@ $bb_cfg['tracker'] = [
'multitracker' => [ // multi-tracker settings
'enabled' => true,
'update_interval' => 0,
'max_trackers' => 3,
'timeout' => 5, // per announcer (in secs)
'torrents_per_cycle' => 20,
],

View file

@ -15,27 +15,49 @@ namespace TorrentPier;
*/
class MultiTracker
{
/**
* Leechers count
*
* @var int
*/
public int $leechers;
/**
* Seeders count
*
* @var int
*/
public int $seeders;
/**
* MultiTracker constructor
*
* @param array $infoHashes
* @param array $trackers
*/
public function __construct(array $infoHashes, array $trackers)
{
global $bb_cfg;
$scraper = new Scraper();
$announcerInfo = $scraper->scrape($infoHashes, $trackers);
$announcerInfo = $scraper->scrape(
$infoHashes,
$trackers,
$bb_cfg['tracker']['multitracker']['max_trackers'],
$bb_cfg['tracker']['multitracker']['timeout'],
);
$seeders = $leechers = 0;
if (!$scraper->hasErrors()) {
foreach ($infoHashes as $infoHash) {
$announcerInfo = $announcerInfo[$infoHash];
$seeders = $announcerInfo['seeders'];
$leechers = $announcerInfo['leechers'];
$seeders = (int)$announcerInfo['seeders'];
$leechers = (int)$announcerInfo['leechers'];
}
} else {
dump($scraper->getErrors());
}
//dd([$seeders, $leechers]);
$this->leechers = $leechers;
$this->seeders = $seeders;
}