diff --git a/scraper/scheduler/seeders.js b/scraper/scheduler/seeders.js index a5cdf6f..3b51dfb 100644 --- a/scraper/scheduler/seeders.js +++ b/scraper/scheduler/seeders.js @@ -10,7 +10,7 @@ const statistics = {}; function scheduleUpdateSeeders() { console.log('Starting seeders update...') - return repository.getUpdateSeedersTorrents(50) + return getTorrents() .then(torrents => updateCurrentSeeders(torrents)) .then(updatedTorrents => Promise.all( updatedTorrents.map(updated => updateLimiter.schedule(() => updateTorrentSeeders(updated))))) @@ -21,6 +21,11 @@ function scheduleUpdateSeeders() { .then(() => scheduleUpdateSeeders()); } +async function getTorrents() { + return repository.getUpdateSeedersTorrents(50) + .catch(() => delay(5000).then(() => getTorrents())) +} + function updateStatistics(updatedTorrents) { const totalTorrents = updatedTorrents.map(nested => nested.length).reduce((a, b) => a + b, 0); const date = new Date().toISOString().replace(/T.*/, '');