From 13369c16c9e99cbd72fa18bef3a1612b2df4e64a Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Wed, 8 Jan 2025 12:50:20 +0700 Subject: [PATCH] Updated --- library/config.php | 1 + src/MultiTracker.php | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/library/config.php b/library/config.php index 74a31728a..6751d77a8 100644 --- a/library/config.php +++ b/library/config.php @@ -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, ], diff --git a/src/MultiTracker.php b/src/MultiTracker.php index 90c904fb0..f5e13e09a 100644 --- a/src/MultiTracker.php +++ b/src/MultiTracker.php @@ -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; }