mirror of
https://github.com/Inside4ndroid/TMDB-Embed-API.git
synced 2026-10-22 09:35:11 +00:00
docs: update README (unified stream schema, MoviesClub, registry mapping, docker run)\nchore(release): 1.0.4 tag prep\nchore: ignore restart.trigger and .vscode
This commit is contained in:
+44
-28
@@ -52,6 +52,19 @@ function writeOverrideFile(obj) {
|
||||
}
|
||||
}
|
||||
|
||||
function getProviderNames() {
|
||||
try {
|
||||
const providersDir = path.join(process.cwd(), 'providers');
|
||||
if (!fs.existsSync(providersDir)) return [];
|
||||
return fs.readdirSync(providersDir)
|
||||
.filter(file => file.endsWith('.js') && file !== 'registry.js' && file !== 'vidsrcextractor.js')
|
||||
.map(file => path.parse(file).name.toLowerCase());
|
||||
} catch (e) {
|
||||
console.warn('[config] Failed to scan providers directory:', e.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeConfig(base) {
|
||||
const cfg = { ...base };
|
||||
// Marker: if user explicitly provided an empty array for tmdbApiKeys in override file we should not resurrect legacy key
|
||||
@@ -80,20 +93,21 @@ function normalizeConfig(base) {
|
||||
cfg.tmdbApiKeys = Array.from(new Set(cfg.tmdbApiKeys.map(k=>String(k).trim()).filter(Boolean)));
|
||||
// Do not expose legacy single-key field in merged config output
|
||||
delete cfg.tmdbApiKey;
|
||||
// Booleans normalization
|
||||
const boolKeys = [
|
||||
'enableShowboxProvider','enableXprimeProvider','enable4khdhubProvider','enableMoviesmodProvider','enableMp4hydraProvider','enableVidzeeProvider','enableVixsrcProvider',
|
||||
'disableCache','enablePStreamApi','disableUrlValidation','disable4khdhubUrlValidation'
|
||||
];
|
||||
|
||||
// Dynamic provider enable flags
|
||||
const providerNames = getProviderNames();
|
||||
const boolKeys = providerNames.map(name => `enable${name.charAt(0).toUpperCase() + name.slice(1)}Provider`);
|
||||
boolKeys.push('disableCache', 'enablePStreamApi', 'disableUrlValidation', 'disable4khdhubUrlValidation');
|
||||
|
||||
boolKeys.forEach(k=>{ if (cfg[k] === 'true') cfg[k] = true; else if (cfg[k] === 'false') cfg[k] = false; });
|
||||
// Default values if undefined
|
||||
if (cfg.enableShowboxProvider === undefined) cfg.enableShowboxProvider = true;
|
||||
if (cfg.enableXprimeProvider === undefined) cfg.enableXprimeProvider = true;
|
||||
if (cfg.enable4khdhubProvider === undefined) cfg.enable4khdhubProvider = true;
|
||||
if (cfg.enableMoviesmodProvider === undefined) cfg.enableMoviesmodProvider = true;
|
||||
if (cfg.enableMp4hydraProvider === undefined) cfg.enableMp4hydraProvider = true;
|
||||
if (cfg.enableVidzeeProvider === undefined) cfg.enableVidzeeProvider = true;
|
||||
if (cfg.enableVixsrcProvider === undefined) cfg.enableVixsrcProvider = true;
|
||||
|
||||
// Set defaults for provider enable flags
|
||||
providerNames.forEach(name => {
|
||||
const flag = `enable${name.charAt(0).toUpperCase() + name.slice(1)}Provider`;
|
||||
if (cfg[flag] === undefined) cfg[flag] = true; // Default to enabled
|
||||
});
|
||||
|
||||
// Default values for other flags
|
||||
if (cfg.disableCache === undefined) cfg.disableCache = false;
|
||||
if (cfg.enablePStreamApi === undefined) cfg.enablePStreamApi = true;
|
||||
// Proxy features removed; always use direct connections
|
||||
@@ -114,14 +128,15 @@ function applyConfigToEnv(cfg){
|
||||
if (cfg.febboxCookies && cfg.febboxCookies.length) process.env.FEBBOX_COOKIES = cfg.febboxCookies.join(',');
|
||||
else delete process.env.FEBBOX_COOKIES;
|
||||
if (cfg.defaultRegion) process.env.DEFAULT_REGION = cfg.defaultRegion; else delete process.env.DEFAULT_REGION;
|
||||
// Provider enable flags
|
||||
process.env.ENABLE_SHOWBOX_PROVIDER = cfg.enableShowboxProvider ? 'true':'false';
|
||||
process.env.ENABLE_XPRIME_PROVIDER = cfg.enableXprimeProvider ? 'true':'false';
|
||||
process.env.ENABLE_4KHDHUB_PROVIDER = cfg.enable4khdhubProvider ? 'true':'false';
|
||||
process.env.ENABLE_MOVIESMOD_PROVIDER = cfg.enableMoviesmodProvider ? 'true':'false';
|
||||
process.env.ENABLE_MP4HYDRA_PROVIDER = cfg.enableMp4hydraProvider ? 'true':'false';
|
||||
process.env.ENABLE_VIDZEE_PROVIDER = cfg.enableVidzeeProvider ? 'true':'false';
|
||||
process.env.ENABLE_VIXSRC_PROVIDER = cfg.enableVixsrcProvider ? 'true':'false';
|
||||
|
||||
// Dynamic provider enable flags
|
||||
const providerNames = getProviderNames();
|
||||
providerNames.forEach(name => {
|
||||
const flag = `enable${name.charAt(0).toUpperCase() + name.slice(1)}Provider`;
|
||||
const envName = `ENABLE_${name.toUpperCase()}_PROVIDER`;
|
||||
process.env[envName] = cfg[flag] ? 'true' : 'false';
|
||||
});
|
||||
|
||||
// Caching / validation / PStream
|
||||
process.env.DISABLE_CACHE = cfg.disableCache ? 'true':'false';
|
||||
process.env.ENABLE_PSTREAM_API = cfg.enablePStreamApi ? 'true':'false';
|
||||
@@ -152,13 +167,6 @@ function loadConfig() {
|
||||
tmdbApiKeys: parseJsonMaybe(process.env.TMDB_API_KEYS) || null,
|
||||
febboxCookies: parseCookies(process.env.FEBBOX_COOKIES),
|
||||
// Extended advanced config (may not exist in env)
|
||||
enableShowboxProvider: process.env.ENABLE_SHOWBOX_PROVIDER,
|
||||
enableXprimeProvider: process.env.ENABLE_XPRIME_PROVIDER,
|
||||
enable4khdhubProvider: process.env.ENABLE_4KHDHUB_PROVIDER,
|
||||
enableMoviesmodProvider: process.env.ENABLE_MOVIESMOD_PROVIDER,
|
||||
enableMp4hydraProvider: process.env.ENABLE_MP4HYDRA_PROVIDER,
|
||||
enableVidzeeProvider: process.env.ENABLE_VIDZEE_PROVIDER,
|
||||
enableVixsrcProvider: process.env.ENABLE_VIXSRC_PROVIDER,
|
||||
disableCache: process.env.DISABLE_CACHE,
|
||||
enablePStreamApi: process.env.ENABLE_PSTREAM_API,
|
||||
showboxCacheDir: process.env.SHOWBOX_CACHE_DIR || null,
|
||||
@@ -166,6 +174,14 @@ function loadConfig() {
|
||||
disableUrlValidation: process.env.DISABLE_URL_VALIDATION,
|
||||
disable4khdhubUrlValidation: process.env.DISABLE_4KHDHUB_URL_VALIDATION
|
||||
};
|
||||
|
||||
// Dynamic provider enable flags from env
|
||||
const providerNames = getProviderNames();
|
||||
providerNames.forEach(name => {
|
||||
const envName = `ENABLE_${name.toUpperCase()}_PROVIDER`;
|
||||
envCfg[`enable${name.charAt(0).toUpperCase() + name.slice(1)}Provider`] = process.env[envName];
|
||||
});
|
||||
|
||||
const override = readOverrideFile();
|
||||
const merged = { ...envCfg, ...override };
|
||||
const normalized = normalizeConfig(merged);
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
class JsUnpacker {
|
||||
static Unbase = class {
|
||||
constructor(radix) {
|
||||
this.ALPHABET_62 =
|
||||
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
this.ALPHABET_95 =
|
||||
' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
|
||||
this.alphabet = null;
|
||||
this.dictionary = {};
|
||||
this.radix = radix;
|
||||
|
||||
if (radix > 36) {
|
||||
if (radix < 62) {
|
||||
this.alphabet = this.ALPHABET_62.substring(0, radix);
|
||||
} else if (radix > 62 && radix < 95) {
|
||||
this.alphabet = this.ALPHABET_95.substring(0, radix);
|
||||
} else if (radix === 62) {
|
||||
this.alphabet = this.ALPHABET_62;
|
||||
} else if (radix === 95) {
|
||||
this.alphabet = this.ALPHABET_95;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.alphabet.length; i++) {
|
||||
this.dictionary[this.alphabet[i]] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unbase(str) {
|
||||
let ret = 0;
|
||||
|
||||
if (this.alphabet === null) {
|
||||
ret = parseInt(str, this.radix);
|
||||
} else {
|
||||
const tmp = str.split('').reverse().join('');
|
||||
for (let i = 0; i < tmp.length; i++) {
|
||||
ret += Math.pow(this.radix, i) * this.dictionary[tmp[i]];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
constructor(packedJS) {
|
||||
this.packedJS = packedJS;
|
||||
}
|
||||
|
||||
detect() {
|
||||
const js = this.packedJS.replace(/\s/g, '');
|
||||
const regex = /eval\(function\(p,a,c,k,e,(?:r|d)/;
|
||||
return regex.test(js);
|
||||
}
|
||||
|
||||
unpack() {
|
||||
let js = this.packedJS;
|
||||
try {
|
||||
const regex =
|
||||
/}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)/s;
|
||||
const match = js.match(regex);
|
||||
if (match && match.length === 5) {
|
||||
let payload = match[1].replace(/\\'/g, "'");
|
||||
const radixStr = match[2];
|
||||
const countStr = match[3];
|
||||
const symtab = match[4].split('|');
|
||||
|
||||
let radix = 36;
|
||||
let count = 0;
|
||||
try {
|
||||
radix = parseInt(radixStr);
|
||||
} catch (e) {}
|
||||
try {
|
||||
count = parseInt(countStr);
|
||||
} catch (e) {}
|
||||
|
||||
if (symtab.length !== count) {
|
||||
throw new Error('Unknown p.a.c.k.e.r. encoding');
|
||||
}
|
||||
|
||||
const unbase = new this.constructor.Unbase(radix);
|
||||
const wordRegex = /\b\w+\b/g;
|
||||
let decoded = payload;
|
||||
let replaceOffset = 0;
|
||||
let wordMatch;
|
||||
|
||||
while ((wordMatch = wordRegex.exec(payload)) !== null) {
|
||||
const word = wordMatch[0];
|
||||
const x = unbase.unbase(word);
|
||||
let value = null;
|
||||
if (x < symtab.length) {
|
||||
value = symtab[x];
|
||||
}
|
||||
|
||||
if (value && value.length > 0) {
|
||||
const start = wordMatch.index + replaceOffset;
|
||||
const end = start + word.length;
|
||||
decoded =
|
||||
decoded.substring(0, start) +
|
||||
value +
|
||||
decoded.substring(end);
|
||||
replaceOffset += value.length - word.length;
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// CommonJS exports
|
||||
module.exports = JsUnpacker;
|
||||
@@ -16,4 +16,4 @@
|
||||
"disable4khdhubUrlValidation": false,
|
||||
"excludeCodecsRaw": "{\"excludeDV\":false,\"excludeHDR\":false}",
|
||||
"minQualitiesRaw": "all"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user