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

@@ -16,8 +16,8 @@ export async function getCachedStreams(streams, apiKey) {
.then(results => results.map(result => result.value))
.then(results => results.reduce((all, result) => Object.assign(all, result), {}))
.catch(error => {
if (error === 'badToken') {
return Promise.reject(BadTokenError);
if (toCommonError(error)) {
return Promise.reject(error);
}
console.warn('Failed DebridLink cached torrent availability request:', error);
return undefined;
@@ -135,6 +135,13 @@ async function getDefaultOptions(ip) {
return { ip, timeout: 30000 };
}
export function toCommonError(error) {
if (error === 'badToken') {
return BadTokenError;
}
return undefined;
}
function statusDownloading(torrent) {
return torrent.downloadPercent < 100
}