handle more statuses for torbox to return correct responses

This commit is contained in:
TheBeastLT 2024-11-28 20:03:06 +02:00
parent 4c50c505ed
commit 2003debe37
2 changed files with 7 additions and 3 deletions

View file

@ -168,7 +168,7 @@ export function toCommonError(error) {
}
function statusDownloading(torrent) {
return ['downloading', 'created'].includes(torrent.status);
return ['downloading', 'created', 'queued'].includes(torrent.status);
}
function statusError(torrent) {

View file

@ -146,6 +146,9 @@ async function _unrestrictLink(apiKey, infoHash, torrent, cachedEntryInfo, fileI
|| videos[0];
if (!targetVideo) {
if (torrent.files.every(file => file.zipped)) {
return StaticResponse.FAILED_RAR;
}
return Promise.reject(`No TorBox file found for index ${fileIndex} in: ${JSON.stringify(torrent)}`);
}
return getDownloadLink(apiKey, 'torrents', torrent.id, targetVideo.id, ip);
@ -226,11 +229,12 @@ export function toCommonError(data) {
}
function statusDownloading(torrent) {
return ['metaDL', 'downloading', 'stalled', 'processing', 'completed'].includes(torrent?.download_state);
return ['metaDL', 'downloading', 'stalled (no seeds)', 'processing', 'checking', 'completed']
.includes(torrent?.download_state);
}
function statusError(torrent) {
return !torrent?.active && !torrent?.download_finished;
return (!torrent?.active && !torrent?.download_finished) || torrent?.download_state === 'error';
}
function statusReady(torrent) {