From f77929213033f73c8e26e5d8a9c265f392ab03e3 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Thu, 28 Nov 2024 20:11:59 +0200 Subject: [PATCH] handle too big entry for all debrid --- addon/moch/alldebrid.js | 13 ++++++++++--- addon/moch/static.js | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addon/moch/alldebrid.js b/addon/moch/alldebrid.js index 04ae984..f58c146 100644 --- a/addon/moch/alldebrid.js +++ b/addon/moch/alldebrid.js @@ -83,14 +83,17 @@ export async function resolve({ ip, apiKey, infoHash, cachedEntryInfo, fileIndex async function _resolve(AD, infoHash, cachedEntryInfo, fileIndex) { const torrent = await _createOrFindTorrent(AD, infoHash); - if (torrent && statusReady(torrent.statusCode)) { + if (statusReady(torrent?.statusCode)) { return _unrestrictLink(AD, torrent, cachedEntryInfo, fileIndex); - } else if (torrent && statusDownloading(torrent.statusCode)) { + } else if (statusDownloading(torrent?.statusCode)) { console.log(`Downloading to AllDebrid ${infoHash} [${fileIndex}]...`); return StaticResponse.DOWNLOADING; - } else if (torrent && statusHandledError(torrent.statusCode)) { + } else if (statusHandledError(torrent?.statusCode)) { console.log(`Retrying downloading to AllDebrid ${infoHash} [${fileIndex}]...`); return _retryCreateTorrent(AD, infoHash, cachedEntryInfo, fileIndex); + } else if (statusTooBigEntry(torrent?.statusCode)) { + console.log(`Torrent too big for AllDebrid ${infoHash} [${fileIndex}]`); + return StaticResponse.FAILED_TOO_BIG; } return Promise.reject(`Failed AllDebrid adding torrent ${JSON.stringify(torrent)}`); @@ -182,6 +185,10 @@ function statusReady(statusCode) { return statusCode === 4; } +function statusTooBigEntry(statusCode) { + return statusCode === 8; +} + function isExpiredSubscriptionError(error) { return ['AUTH_BAD_APIKEY', 'MUST_BE_PREMIUM', 'MAGNET_MUST_BE_PREMIUM', 'FREE_TRIAL_LIMIT_REACHED', 'AUTH_USER_BANNED'] .includes(error.code); diff --git a/addon/moch/static.js b/addon/moch/static.js index b0f079d..6e85015 100644 --- a/addon/moch/static.js +++ b/addon/moch/static.js @@ -3,6 +3,7 @@ const staticVideoUrls = { FAILED_DOWNLOAD: `videos/download_failed_v2.mp4`, FAILED_ACCESS: `videos/failed_access_v2.mp4`, FAILED_RAR: `videos/failed_rar_v2.mp4`, + FAILED_TOO_BIG: 'failed_too_big_v1.mp4', FAILED_OPENING: `videos/failed_opening_v2.mp4`, FAILED_UNEXPECTED: `videos/failed_unexpected_v2.mp4`, FAILED_INFRINGEMENT: `videos/failed_infringement_v2.mp4`,