mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-25 15:45:33 -07:00
Updated
This commit is contained in:
parent
76fcbfed91
commit
7e8f24ead8
2 changed files with 28 additions and 6 deletions
|
@ -397,12 +397,15 @@ class Torrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting multi-peers
|
// Getting multi-peers
|
||||||
|
$external_seeders = $external_leechers = 0;
|
||||||
if ($bb_cfg['tracker']['multitracker']['enabled']) {
|
if ($bb_cfg['tracker']['multitracker']['enabled']) {
|
||||||
$torrent = \Arokettu\Torrent\TorrentFile::loadFromString($file_contents);
|
$tor['announce-list'] = array_merge(array_column($tor['announce-list'], 0), [$tor['announce']]);
|
||||||
$announcers = $torrent->getAnnounceList()->toArray();
|
$announcers = array_unique($tor['announce-list'], SORT_REGULAR);
|
||||||
$multiTracker = new MultiTracker([
|
$multiTracker = new MultiTracker([
|
||||||
bin2hex($info_hash ?? $info_hash_v2)
|
bin2hex($info_hash ?? $info_hash_v2)
|
||||||
], $announcers[0]);
|
], $announcers);
|
||||||
|
$external_seeders = $multiTracker->seeders;
|
||||||
|
$external_leechers = $multiTracker->leechers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " $info_hash_where LIMIT 1")) {
|
if ($row = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " $info_hash_where LIMIT 1")) {
|
||||||
|
@ -454,8 +457,8 @@ class Torrent
|
||||||
|
|
||||||
$size = sprintf('%.0f', (float)$totallen);
|
$size = sprintf('%.0f', (float)$totallen);
|
||||||
|
|
||||||
$columns = 'info_hash, info_hash_v2, post_id, poster_id, topic_id, forum_id, attach_id, size, reg_time, tor_status';
|
$columns = 'info_hash, info_hash_v2, post_id, poster_id, topic_id, forum_id, attach_id, size, reg_time, tor_status, ext_seeders, ext_leechers';
|
||||||
$values = "'$info_hash_sql', '$info_hash_v2_sql', $post_id, $poster_id, $topic_id, $forum_id, $attach_id, '$size', $reg_time, $tor_status";
|
$values = "'$info_hash_sql', '$info_hash_v2_sql', $post_id, $poster_id, $topic_id, $forum_id, $attach_id, '$size', $reg_time, $tor_status, $external_seeders, $external_leechers";
|
||||||
|
|
||||||
$sql = "INSERT INTO " . BB_BT_TORRENTS . " ($columns) VALUES ($values)";
|
$sql = "INSERT INTO " . BB_BT_TORRENTS . " ($columns) VALUES ($values)";
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,28 @@ namespace TorrentPier;
|
||||||
*/
|
*/
|
||||||
class MultiTracker
|
class MultiTracker
|
||||||
{
|
{
|
||||||
|
public int $leechers;
|
||||||
|
public int $seeders;
|
||||||
|
|
||||||
public function __construct(array $infoHashes, array $trackers)
|
public function __construct(array $infoHashes, array $trackers)
|
||||||
{
|
{
|
||||||
$scraper = new Scraper();
|
$scraper = new Scraper();
|
||||||
$info = $scraper->scrape($infoHashes, $trackers);
|
$announcerInfo = $scraper->scrape($infoHashes, $trackers);
|
||||||
|
|
||||||
|
$seeders = $leechers = 0;
|
||||||
|
if (!$scraper->hasErrors()) {
|
||||||
|
foreach ($infoHashes as $infoHash) {
|
||||||
|
$announcerInfo = $announcerInfo[$infoHash];
|
||||||
|
$seeders = $announcerInfo['seeders'];
|
||||||
|
$leechers = $announcerInfo['leechers'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dump($scraper->getErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
//dd([$seeders, $leechers]);
|
||||||
|
|
||||||
|
$this->leechers = $leechers;
|
||||||
|
$this->seeders = $seeders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue