[scraper] fixes seeders updating if provider not found

This commit is contained in:
TheBeastLT
2020-04-23 17:08:18 +02:00
parent 9ea3932af1
commit aa0bf8da44
4 changed files with 5 additions and 3 deletions

View File

@@ -14,12 +14,17 @@ function scheduleUpdateSeeders() {
return repository.getUpdateSeedersTorrents()
.then(torrents => Promise.all(torrents.map(torrent => limiter.schedule(() => _updateSeeders(torrent)))))
.then(() => console.log('Finished seeders update'))
.catch(error => console.warn('Failed seeders update: ', error))
.then(() => delay(DELAY))
.then(() => scheduleUpdateSeeders());
}
async function _updateSeeders(torrent) {
const provider = await scrapers.find(provider => provider.name === torrent.provider);
if (!provider) {
console.log(`No provider found for ${torrent.provider} [${torrent.infoHash}]`)
return Promise.resolve();
}
const updatedTorrents = await provider.scraper.updateSeeders(torrent, getImdbIdsMethod(torrent))
.then(updated => Array.isArray(updated) ? updated : [updated])
.catch(() => []);

View File

@@ -4,7 +4,6 @@ const leetx = require('./1337x_api');
const { Type } = require('../../lib/types');
const repository = require('../../lib/repository');
const Promises = require('../../lib/promises');
const { updateCurrentSeeders } = require('../../lib/torrent');
const { createTorrentEntry, getStoredTorrentEntry, updateTorrentSeeders } = require('../../lib/torrentEntries');
const NAME = '1337x';

View File

@@ -4,7 +4,6 @@ const kickass = require('./kickass_api');
const { Type } = require('../../lib/types');
const repository = require('../../lib/repository');
const Promises = require('../../lib/promises');
const { updateCurrentSeeders } = require('../../lib/torrent');
const { createTorrentEntry, getStoredTorrentEntry, updateTorrentSeeders } = require('../../lib/torrentEntries');
const NAME = 'KickassTorrents';

View File

@@ -4,7 +4,6 @@ const thepiratebay = require('./thepiratebay_api.js');
const { Type } = require('../../lib/types');
const repository = require('../../lib/repository');
const Promises = require('../../lib/promises');
const { updateCurrentSeeders } = require('../../lib/torrent');
const { createTorrentEntry, getStoredTorrentEntry, updateTorrentSeeders } = require('../../lib/torrentEntries');
const NAME = 'ThePirateBay';