try to handle common debrid error for catalog retrieval

This commit is contained in:
TheBeastLT
2023-10-31 22:26:26 +02:00
parent 8a2f0093c6
commit 25313192d2
9 changed files with 73 additions and 23 deletions

View File

@@ -49,11 +49,8 @@ async function _getInstantAvailable(hashes, apiKey, retries = 3, maxChunkSize =
.then(results => cacheAvailabilityResults(results))
.then(results => Object.assign(cachedResults, results))
.catch(error => {
if (error && error.code === 8) {
return Promise.reject(BadTokenError);
}
if (error && accessDeniedError(error)) {
return Promise.reject(AccessDeniedError);
if (toCommonError(error)) {
return Promise.reject(error);
}
if (!error && maxChunkSize !== 1) {
// sometimes due to large response size RD responds with an empty body. Reduce chunk size to reduce body
@@ -355,6 +352,16 @@ async function _unrestrictFileLink(RD, fileLink, torrent, fileIndex, isBrowser)
});
}
export function toCommonError(error) {
if (error && error.code === 8) {
return BadTokenError;
}
if (error && accessDeniedError(error)) {
return AccessDeniedError;
}
return undefined;
}
function statusError(status) {
return ['error', 'magnet_error'].includes(status);
}