From 1a9b2ba4f7e1c96ccaafe3de78b90bfe68dcab74 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Thu, 28 Nov 2024 20:17:12 +0200 Subject: [PATCH] handle too big entry for debridlink --- addon/moch/debridlink.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/addon/moch/debridlink.js b/addon/moch/debridlink.js index 9a6b852..e0d214e 100644 --- a/addon/moch/debridlink.js +++ b/addon/moch/debridlink.js @@ -63,10 +63,18 @@ export async function resolve({ ip, apiKey, infoHash, fileIndex }) { return _resolve(DL, infoHash, fileIndex) .catch(error => { - if (errorExpiredSubscriptionError(error)) { + if (isAccessDeniedError(error)) { console.log(`Access denied to DebridLink ${infoHash} [${fileIndex}]`); return StaticResponse.FAILED_ACCESS; } + if (isLimitsExceededError(error)) { + console.log(`Limits exceeded in DebridLink ${infoHash} [${fileIndex}]`); + return StaticResponse.LIMITS_EXCEEDED; + } + if (isTorrentTooBigError(error)) { + console.log(`Torrent too big for DebridLink ${infoHash} [${fileIndex}]`); + return StaticResponse.FAILED_TOO_BIG; + } return Promise.reject(`Failed DebridLink adding torrent ${JSON.stringify(error)}`); }); } @@ -135,6 +143,14 @@ function statusReady(torrent) { return torrent.downloadPercent === 100; } -function errorExpiredSubscriptionError(error) { - return ['freeServerOverload', 'maxTorrent', 'maxLink', 'maxLinkHost', 'maxData', 'maxDataHost'].includes(error); +function isAccessDeniedError(error) { + return ['badToken', 'accountLocked'].includes(error); +} + +function isLimitsExceededError(error) { + return ['freeServerOverload', 'maxTorrent', 'maxLink', 'maxLinkHost', 'maxData', 'maxDataHost', 'floodDetected'].includes(error); +} + +function isTorrentTooBigError(error) { + return ['torrentTooBig'].includes(error); }