mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] try to fix seeders update startup error
This commit is contained in:
@@ -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.*/, '');
|
||||
|
||||
Reference in New Issue
Block a user