mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scrapper] fixes rarbg api error handling
This commit is contained in:
@@ -102,11 +102,11 @@ async function singleRequest(params = {}, config = {}, retries = 5) {
|
|||||||
token = undefined;
|
token = undefined;
|
||||||
return singleRequest(params, config);
|
return singleRequest(params, config);
|
||||||
}
|
}
|
||||||
if ((!response.body || [5, 20].includes(response.body.error_code)) && retries > 0) {
|
if ((!response.body || !response.body.length || [5, 20].includes(response.body.error_code)) && retries > 0) {
|
||||||
// too many requests
|
// too many requests
|
||||||
return Promises.delay(2100).then(() => singleRequest(params, config, retries - 1));
|
return Promises.delay(2100).then(() => singleRequest(params, config, retries - 1));
|
||||||
}
|
}
|
||||||
if (response.statusCode !== 200) {
|
if (response.statusCode !== 200 || (response.body && response.body.error)) {
|
||||||
// something went wrong
|
// something went wrong
|
||||||
return Promise.reject(response.body || `Failed RARGB request with status=${response.statusCode}`);
|
return Promise.reject(response.body || `Failed RARGB request with status=${response.statusCode}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user