From 9b1982abfeca3a8a7baa062dc9842e684b9b4b0f Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Sat, 2 May 2020 22:40:51 +0200 Subject: [PATCH] [scraper] limits pages per category for 1337x --- scraper/scrapers/1337x/1337x_scraper.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scraper/scrapers/1337x/1337x_scraper.js b/scraper/scrapers/1337x/1337x_scraper.js index 10bb40a..b9daff6 100644 --- a/scraper/scrapers/1337x/1337x_scraper.js +++ b/scraper/scrapers/1337x/1337x_scraper.js @@ -49,7 +49,7 @@ async function scrapeLatestTorrentsForCategory(category, page = 1) { return Promise.resolve([]); }) .then(torrents => Promise.all(torrents.map(torrent => limiter.schedule(() => processTorrentRecord(torrent))))) - .then(resolved => resolved.length > 0 && page < UNTIL_PAGE + .then(resolved => resolved.length > 0 && page < untilPage(category) ? scrapeLatestTorrentsForCategory(category, page + 1) : Promise.resolve()); @@ -94,4 +94,14 @@ function typeMapping() { return mapping; } +function untilPage(category) { + if (leetx.Categories.ANIME === category) { + return 5; + } + if (leetx.Categories.DOCUMENTARIES === category) { + return 1; + } + return UNTIL_PAGE; +} + module.exports = { scrape, updateSeeders, NAME }; \ No newline at end of file