mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-04-21 02:42:03 +00:00
[scraper] moves timeout to provider seeders update level
This commit is contained in:
parent
a7b23a1313
commit
99bfbb058a
1 changed files with 2 additions and 7 deletions
|
|
@ -15,12 +15,7 @@ const statistics = {};
|
||||||
function scheduleUpdateSeeders() {
|
function scheduleUpdateSeeders() {
|
||||||
console.log('Starting seeders update...')
|
console.log('Starting seeders update...')
|
||||||
return repository.getUpdateSeedersTorrents()
|
return repository.getUpdateSeedersTorrents()
|
||||||
.then(torrents => Promise.all(torrents.map(torrent => limiter
|
.then(torrents => Promise.all(torrents.map(torrent => limiter.schedule(() => _updateSeeders(torrent)))))
|
||||||
.schedule(() => timeout(TIMEOUT_MS, _updateSeeders(torrent)))
|
|
||||||
.catch(error => {
|
|
||||||
console.log(`Failed [${torrent.infoHash}] ${torrent.title} seeders update: `, error);
|
|
||||||
return []
|
|
||||||
}))))
|
|
||||||
.then(torrents => updateStatistics(torrents))
|
.then(torrents => updateStatistics(torrents))
|
||||||
.then(() => console.log('Finished seeders update:', statistics))
|
.then(() => console.log('Finished seeders update:', statistics))
|
||||||
.catch(error => console.warn('Failed seeders update:', error))
|
.catch(error => console.warn('Failed seeders update:', error))
|
||||||
|
|
@ -34,7 +29,7 @@ async function _updateSeeders(torrent) {
|
||||||
console.log(`No provider found for ${torrent.provider} [${torrent.infoHash}]`)
|
console.log(`No provider found for ${torrent.provider} [${torrent.infoHash}]`)
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
const updatedTorrents = await provider.scraper.updateSeeders(torrent, getImdbIdsMethod(torrent))
|
const updatedTorrents = await timeout(TIMEOUT_MS, provider.scraper.updateSeeders(torrent, getImdbIdsMethod(torrent)))
|
||||||
.then(updated => Array.isArray(updated) ? updated : [updated])
|
.then(updated => Array.isArray(updated) ? updated : [updated])
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn(`Failed seeders update ${torrent.provider} [${torrent.infoHash}]: `, error)
|
console.warn(`Failed seeders update ${torrent.provider} [${torrent.infoHash}]: `, error)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue