From 0cd3bd4d226b8d699aedf0fb534a2093eef6ef8b Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Fri, 29 Nov 2024 11:08:11 +0200 Subject: [PATCH] handle too big entry for RD and TB --- addon/moch/realdebrid.js | 10 +++++++++- addon/moch/torbox.js | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addon/moch/realdebrid.js b/addon/moch/realdebrid.js index f3d18c6..4e16b9b 100644 --- a/addon/moch/realdebrid.js +++ b/addon/moch/realdebrid.js @@ -132,6 +132,10 @@ export async function resolve({ ip, isBrowser, apiKey, infoHash, fileIndex }) { console.log(`Limits exceeded in RealDebrid ${infoHash} [${fileIndex}]`); return StaticResponse.LIMITS_EXCEEDED; } + if (isTorrentTooBigError(error)) { + console.log(`Torrent too big for RealDebrid ${infoHash} [${fileIndex}]`); + return StaticResponse.FAILED_TOO_BIG; + } return Promise.reject(`Failed RealDebrid adding torrent ${JSON.stringify(error)}`); }); } @@ -350,7 +354,11 @@ function isInfringingFileError(error) { } function isLimitExceededError(error) { - return [21, 23, 26, 29, 36].includes(error?.code); + return [21, 23, 26, 36].includes(error?.code); +} + +function isTorrentTooBigError(error) { + return [29].includes(error?.code); } async function getDefaultOptions(ip) { diff --git a/addon/moch/torbox.js b/addon/moch/torbox.js index 9558045..5462d27 100644 --- a/addon/moch/torbox.js +++ b/addon/moch/torbox.js @@ -79,6 +79,10 @@ export async function resolve({ ip, apiKey, infoHash, cachedEntryInfo, fileIndex console.log(`Limits exceeded to TorBox ${infoHash} [${fileIndex}]`); return StaticResponse.LIMITS_EXCEEDED; } + if (isTorrentTooBigError(error)) { + console.log(`Torrent too big for TorBox ${infoHash} [${fileIndex}]`); + return StaticResponse.FAILED_TOO_BIG; + } return Promise.reject(`Failed TorBox adding torrent: ${JSON.stringify(error.message || error)}`); }); } @@ -246,5 +250,9 @@ function isAccessDeniedError(error) { } function isLimitExceededError(error) { - return ['DOWNLOAD_TOO_LARGE', 'MONTHLY_LIMIT', 'COOLDOWN_LIMIT', 'ACTIVE_LIMIT'].includes(error?.error); + return ['MONTHLY_LIMIT', 'COOLDOWN_LIMIT', 'ACTIVE_LIMIT'].includes(error?.error); +} + +function isTorrentTooBigError(error) { + return ['DOWNLOAD_TOO_LARGE'].includes(error?.error); }