[scraper] adds pagination to new tpb browse api

This commit is contained in:
TheBeastLT
2020-04-27 12:22:43 +02:00
parent 33ecee4a8a
commit a6f3e85c34
2 changed files with 3 additions and 2 deletions

View File

@@ -93,8 +93,9 @@ function search(keyword, config = {}, retries = 2) {
function browse(config = {}, retries = 2) {
const category = config.category || 0;
const page = config.page - 1 || 0;
return _request(`q.php?q=category:${category}`)
return _request(`q.php?q=category:${category}:${page}`)
.then(results => results.map((result) => toTorrent(result)))
.catch(error => retries ? browse(config, retries - 1) : Promise.reject(error));
}

View File

@@ -7,7 +7,7 @@ const Promises = require('../../lib/promises');
const { createTorrentEntry, getStoredTorrentEntry, updateTorrentSeeders } = require('../../lib/torrentEntries');
const NAME = 'ThePirateBay';
const UNTIL_PAGE = 1;
const UNTIL_PAGE = 5;
const limiter = new Bottleneck({ maxConcurrent: 40 });