From 683776ab6d4990f5612e6c9dad0c3d46cb31fb23 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Sun, 8 Jan 2023 20:38:20 +0200 Subject: [PATCH] retry downloading single file when no link found or only torrent rar available --- addon/moch/realdebrid.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addon/moch/realdebrid.js b/addon/moch/realdebrid.js index 72da648..a48f76a 100644 --- a/addon/moch/realdebrid.js +++ b/addon/moch/realdebrid.js @@ -283,7 +283,8 @@ async function _unrestrictLink(RD, torrent, fileIndex, isBrowser) { : torrent.links[selectedFiles.indexOf(targetFile)]; if (!fileLink || !fileLink.length) { - return Promise.reject(`No RealDebrid links found for ${torrent.hash} [${fileIndex}]: ${JSON.stringify(torrent)}`); + console.log(`No RealDebrid links found for ${torrent.hash} [${fileIndex}]`); + return _retryCreateTorrent(RD, torrent.hash, fileIndex) } return _unrestrictFileLink(RD, fileLink, torrent, fileIndex, isBrowser); @@ -293,6 +294,9 @@ async function _unrestrictFileLink(RD, fileLink, torrent, fileIndex, isBrowser) return RD.unrestrict.link(fileLink) .then(response => { if (isArchive(response.download)) { + if (torrent.files.filter(file => file.selected).length > 1) { + return _retryCreateTorrent(RD, torrent.hash, fileIndex) + } return StaticResponse.FAILED_RAR; } // if (isBrowser && response.streamable) {