From 4c2f4306b120a8fa468542d290882fbe9445302e Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Sat, 11 Nov 2023 12:30:29 +0200 Subject: [PATCH] add resolver queue per debrid --- addon/moch/moch.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addon/moch/moch.js b/addon/moch/moch.js index 540b737..5deca58 100644 --- a/addon/moch/moch.js +++ b/addon/moch/moch.js @@ -59,9 +59,12 @@ export const MochOptions = { } }; -const unrestrictQueue = new namedQueue((task, callback) => task.method() - .then(result => callback(false, result)) - .catch((error => callback(error))), 20); +const unrestrictQueues = {} +Object.values(MochOptions) + .map(moch => moch.key) + .forEach(mochKey => unrestrictQueues[mochKey] = new namedQueue((task, callback) => task.method() + .then(result => callback(false, result)) + .catch((error => callback(error))), 20)); export function hasMochConfigured(config) { return Object.keys(MochOptions).find(moch => config?.[moch]) @@ -107,6 +110,7 @@ export async function resolve(parameters) { return StaticResponse.FAILED_UNEXPECTED; }) .then(url => isStaticUrl(url) ? `${parameters.host}/${url}` : url); + const unrestrictQueue = unrestrictQueues[moch.key]; return new Promise(((resolve, reject) => { unrestrictQueue.push({ id, method }, (error, result) => result ? resolve(result) : reject(error)); }));