Browse Source

fix scrape totals, reset counters on zero results

main
ghost 1 year ago
parent
commit
68fdc3c28c
  1. 31
      src/Service/TorrentService.php

31
src/Service/TorrentService.php

@ -67,6 +67,11 @@ class TorrentService
$hashes[] = $hash; $hashes[] = $hash;
} }
// Init default values
$seeders = 0;
$peers = 0;
$leechers = 0;
// Get scrape // Get scrape
if ($hashes && $trackers) if ($hashes && $trackers)
{ {
@ -77,29 +82,35 @@ class TorrentService
{ {
if (isset($result['seeders'])) if (isset($result['seeders']))
{ {
$torrent->setSeeders( $seeders = $seeders + (int) $result['seeders'];
(int) $result['seeders']
);
} }
if (isset($result['completed'])) if (isset($result['completed']))
{ {
$torrent->setPeers( $peers = $peers + (int) $result['completed'];
(int) $result['completed']
);
} }
if (isset($result['leechers'])) if (isset($result['leechers']))
{ {
$torrent->setLeechers( $leechers = $leechers + (int) $result['leechers'];
(int) $result['leechers']
);
} }
} }
} }
} }
// Update time scraped // Update torrent scrape
$torrent->setSeeders(
$seeders
);
$torrent->setPeers(
$peers
);
$torrent->setLeechers(
$leechers
);
$torrent->setScraped( $torrent->setScraped(
time() time()
); );

Loading…
Cancel
Save