mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] check if RD cached availability response is an object
This commit is contained in:
@@ -28,6 +28,13 @@ async function _getInstantAvailable(hashes, apiKey, retries = 3) {
|
|||||||
const options = await getDefaultOptions(apiKey);
|
const options = await getDefaultOptions(apiKey);
|
||||||
const RD = new RealDebridClient(apiKey, options);
|
const RD = new RealDebridClient(apiKey, options);
|
||||||
return RD.torrents.instantAvailability(hashes)
|
return RD.torrents.instantAvailability(hashes)
|
||||||
|
.then(response => {
|
||||||
|
if (typeof response !== 'object') {
|
||||||
|
console.warn('RD returned non JSON response: ', response);
|
||||||
|
return uncacheProxy('moch').then(() => _getInstantAvailable(hashes, apiKey, retries - 1));
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (retries > 0 && ['ENOTFOUND', 'ETIMEDOUT'].some(v => error.message && error.message.includes(v))) {
|
if (retries > 0 && ['ENOTFOUND', 'ETIMEDOUT'].some(v => error.message && error.message.includes(v))) {
|
||||||
blacklistProxy(options.proxy);
|
blacklistProxy(options.proxy);
|
||||||
|
|||||||
Reference in New Issue
Block a user