return auth blocked error for ad

This commit is contained in:
TheBeastLT 2024-11-17 12:31:06 +02:00
parent 029f956563
commit a2c126e072
3 changed files with 13 additions and 2 deletions

View file

@ -3,7 +3,7 @@ import { Type } from '../lib/types.js';
import { isVideo, isArchive } from '../lib/extension.js'; import { isVideo, isArchive } from '../lib/extension.js';
import StaticResponse from './static.js'; import StaticResponse from './static.js';
import { getMagnetLink } from '../lib/magnetHelper.js'; import { getMagnetLink } from '../lib/magnetHelper.js';
import { BadTokenError, AccessDeniedError, sameFilename, streamFilename } from './mochHelper.js'; import { BadTokenError, AccessDeniedError, sameFilename, streamFilename, AccessBlockedError } from './mochHelper.js';
const KEY = 'alldebrid'; const KEY = 'alldebrid';
const AGENT = 'torrentio'; const AGENT = 'torrentio';
@ -167,6 +167,9 @@ export function toCommonError(error) {
if (error && error.code === 'AUTH_USER_BANNED') { if (error && error.code === 'AUTH_USER_BANNED') {
return AccessDeniedError; return AccessDeniedError;
} }
if (error && error.code === 'AUTH_BLOCKED') {
return AccessBlockedError;
}
return undefined; return undefined;
} }

View file

@ -9,7 +9,7 @@ import * as putio from './putio.js';
import StaticResponse, { isStaticUrl } from './static.js'; import StaticResponse, { isStaticUrl } from './static.js';
import { cacheWrapResolvedUrl } from '../lib/cache.js'; import { cacheWrapResolvedUrl } from '../lib/cache.js';
import { timeout } from '../lib/promises.js'; import { timeout } from '../lib/promises.js';
import { BadTokenError, streamFilename, AccessDeniedError, enrichMeta } from './mochHelper.js'; import { BadTokenError, streamFilename, AccessDeniedError, enrichMeta, AccessBlockedError } from './mochHelper.js';
import { createNamedQueue } from "../lib/namedQueue.js"; import { createNamedQueue } from "../lib/namedQueue.js";
const RESOLVE_TIMEOUT = 2 * 60 * 1000; // 2 minutes const RESOLVE_TIMEOUT = 2 * 60 * 1000; // 2 minutes
@ -232,5 +232,12 @@ function errorStreamResponse(mochKey, error, config) {
url: `${config.host}/${StaticResponse.FAILED_ACCESS}` url: `${config.host}/${StaticResponse.FAILED_ACCESS}`
}; };
} }
if (error === AccessBlockedError) {
return {
name: `Torrentio\n${MochOptions[mochKey].shortName} error`,
title: `Access to ${MochOptions[mochKey].name} is blocked!\nCheck you account or email.`,
url: `${config.host}/${StaticResponse.FAILED_ACCESS}`
};
}
return undefined; return undefined;
} }

View file

@ -3,6 +3,7 @@ import * as repository from '../lib/repository.js';
const METAHUB_URL = 'https://images.metahub.space' const METAHUB_URL = 'https://images.metahub.space'
export const BadTokenError = { code: 'BAD_TOKEN' } export const BadTokenError = { code: 'BAD_TOKEN' }
export const AccessDeniedError = { code: 'ACCESS_DENIED' } export const AccessDeniedError = { code: 'ACCESS_DENIED' }
export const AccessBlockedError = { code: 'ACCESS_BLOCKED' }
export function chunkArray(arr, size) { export function chunkArray(arr, size) {
return arr.length > size return arr.length > size