diff --git a/addon/moch/alldebrid.js b/addon/moch/alldebrid.js index 9a6f50a..af217e4 100644 --- a/addon/moch/alldebrid.js +++ b/addon/moch/alldebrid.js @@ -160,7 +160,7 @@ async function _unrestrictLink(AD, torrent, encodedFileName, fileIndex) { } async function getDefaultOptions(ip) { - return { base_agent: AGENT, timeout: 5000 }; + return { base_agent: AGENT, timeout: 10000 }; } export function toCommonError(error) { diff --git a/addon/moch/offcloud.js b/addon/moch/offcloud.js index 5988169..f6fc6f7 100644 --- a/addon/moch/offcloud.js +++ b/addon/moch/offcloud.js @@ -101,6 +101,9 @@ async function _resolve(OC, infoHash, cachedEntryInfo, fileIndex) { } else if (torrent && statusDownloading(torrent)) { console.log(`Downloading to Offcloud ${infoHash} [${fileIndex}]...`); return StaticResponse.DOWNLOADING; + } else if (torrent && statusError(torrent)) { + console.log(`Retry failed download in Offcloud ${infoHash} [${fileIndex}]...`); + return _retryCreateTorrent(OC, infoHash, cachedEntryInfo, fileIndex); } return Promise.reject(`Failed Offcloud adding torrent ${JSON.stringify(torrent)}`); @@ -124,6 +127,13 @@ async function _createTorrent(OC, infoHash) { return OC.cloud.download(magnetLink) } +async function _retryCreateTorrent(OC, infoHash, cachedEntryInfo, fileIndex) { + const newTorrent = await _createTorrent(OC, infoHash); + return newTorrent && statusReady(newTorrent.status) + ? _unrestrictLink(OC, infoHash, newTorrent, cachedEntryInfo, fileIndex) + : StaticResponse.FAILED_DOWNLOAD; +} + async function _unrestrictLink(OC, infoHash, torrent, cachedEntryInfo, fileIndex) { const targetFileName = decodeURIComponent(cachedEntryInfo); const files = await _getFileUrls(OC, torrent)