mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
small adjustments to the scrapers
This commit is contained in:
@@ -6,6 +6,7 @@ const { getRandomUserAgent } = require("../../lib/requestHelper");
|
||||
const baseUrl = 'https://torrentapi.org/pubapi_v2.php';
|
||||
const appId = 'torrentio-addon';
|
||||
const defaultTimeout = 30000;
|
||||
const retryDelay = 3000;
|
||||
|
||||
let token;
|
||||
|
||||
@@ -109,7 +110,7 @@ async function singleRequest(params = {}, config = {}, retries = 15) {
|
||||
}
|
||||
if ((!response.data || !response.data.length || [5, 20].includes(response.data.error_code)) && retries > 0) {
|
||||
// too many requests
|
||||
return Promises.delay(3000).then(() => singleRequest(params, config, retries - 1));
|
||||
return Promises.delay(retryDelay).then(() => singleRequest(params, config, retries - 1));
|
||||
}
|
||||
if (response.status !== 200 || (response.data && response.data.error)) {
|
||||
// something went wrong
|
||||
@@ -120,7 +121,7 @@ async function singleRequest(params = {}, config = {}, retries = 15) {
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.response && [429].includes(error.response.status) && retries > 0) {
|
||||
return Promises.delay(3000).then(() => singleRequest(params, config, retries - 1));
|
||||
return Promises.delay(retryDelay).then(() => singleRequest(params, config, retries - 1));
|
||||
}
|
||||
return Promise.reject(error.message || error);
|
||||
});
|
||||
|
||||
@@ -12,14 +12,10 @@ const allowedCategories = [
|
||||
rarbg.Options.category.MOVIES_XVID,
|
||||
rarbg.Options.category.MOVIES_XVID_720P,
|
||||
rarbg.Options.category.MOVIES_X265_1080P,
|
||||
rarbg.Options.category.MOVIES_X265_4K,
|
||||
rarbg.Options.category.MOVIES_X265_4K_HDR,
|
||||
rarbg.Options.category.MOVIES_X264,
|
||||
rarbg.Options.category.MOVIES_X264_720P,
|
||||
rarbg.Options.category.MOVIES_X264_1080P,
|
||||
rarbg.Options.category.MOVIES_X264_3D,
|
||||
rarbg.Options.category.MOVIES_X264_4K,
|
||||
rarbg.Options.category.MOVIES_BD_REMUX,
|
||||
rarbg.Options.category.MOVIES_HIGH_RES,
|
||||
rarbg.Options.category.TV_EPISODES,
|
||||
rarbg.Options.category.TV_UHD_EPISODES,
|
||||
rarbg.Options.category.TV_HD_EPISODES
|
||||
@@ -32,8 +28,8 @@ async function scrape() {
|
||||
//const allImdbIds = [].concat(movieImdbIds).concat(seriesImdbIds);
|
||||
|
||||
return Promise.all(
|
||||
seriesImdbIds.map(imdbId => limiter.schedule(() => getTorrentsForImdbId(imdbId))
|
||||
.then(torrents => Promise.all(torrents.map(t => entryLimiter.schedule(() => processTorrentRecord(t)))))))
|
||||
seriesImdbIds.map(imdbId => limiter.schedule(() => getTorrentsForImdbId(imdbId))
|
||||
.then(torrents => Promise.all(torrents.map(t => entryLimiter.schedule(() => processTorrentRecord(t)))))))
|
||||
.then(() => console.log(`[${moment()}] finished ${NAME} dump scrape`));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user