[scraper] adds scheduling flag to enable it
This commit is contained in:
@@ -26,17 +26,27 @@ async function scrape() {
|
||||
return PROVIDERS
|
||||
.reduce(async (previousPromise, nextProvider) => {
|
||||
await previousPromise;
|
||||
return nextProvider.scrape().catch(() => Promise.resolve());
|
||||
return nextProvider.scrape().catch(error => {
|
||||
console.warn(`Failed ${nextProvider.NAME} scraping due: `, error);
|
||||
return Promise.resolve()
|
||||
});
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
function enableScheduling() {
|
||||
if (process.env.ENABLE_SCHEDULING) {
|
||||
schedule.scheduleJob(SCRAPE_CRON, () => scrape());
|
||||
} else {
|
||||
scrape();
|
||||
}
|
||||
}
|
||||
|
||||
server.get('/', function (req, res) {
|
||||
res.send(200);
|
||||
});
|
||||
|
||||
server.listen(process.env.PORT || 7000, async function () {
|
||||
await connect();
|
||||
// schedule.scheduleJob(SCRAPE_CRON, () => scrape());
|
||||
console.log('Scraper started');
|
||||
scrape();
|
||||
enableScheduling();
|
||||
});
|
||||
@@ -86,4 +86,4 @@ function typeMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -193,4 +193,4 @@ async function checkIfExists(torrent) {
|
||||
return { ...torrent, size: existingTorrent.size, seeders: existingTorrent.seeders };
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -95,4 +95,4 @@ async function findTorrent(record) {
|
||||
return Promise.reject("not found");
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -84,4 +84,4 @@ function typeMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -73,4 +73,4 @@ function getType(category) {
|
||||
return Type.MOVIE;
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -100,4 +100,4 @@ function getType(category) {
|
||||
return Type.MOVIE;
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -178,4 +178,4 @@ function downloadDump(dump) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -82,4 +82,4 @@ async function processTorrentRecord(record) {
|
||||
return createTorrentEntry(torrent);
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
@@ -109,4 +109,4 @@ async function processTorrentRecord(record) {
|
||||
return createTorrentEntry(torrent);
|
||||
}
|
||||
|
||||
module.exports = { scrape };
|
||||
module.exports = { scrape, NAME };
|
||||
Reference in New Issue
Block a user