added embed config and adde dedicated section for config

This commit is contained in:
2026-11-15 20:39:42 -08:00
parent 6b51a76ed4
commit bf7c5885b2
4 changed files with 552 additions and 55 deletions

View File

@@ -1,4 +1,5 @@
import SOURCES, { SOURCE_MAP } from "./config.js";
import SOURCES, { AGGREGATOR_SOURCES, DEDICATED_SOURCES, SOURCE_MAP } from "./config.js";
import EMBEDS, { EMBED_MAP } from "./embed_config.js";
import { fetchDownloads } from "./downloads/downloads.js";
import { probeSource } from "./health.js";
import { getChapterPages, getMangaDetails, searchManga } from "./manga/atsu.js";
@@ -20,11 +21,37 @@ export default class VylaSDK {
this.tmdbApiKey = tmdbApiKey || null;
this.penguManifest = penguManifest || null;
}
getSources(excludeDisabled = false) {
if (excludeDisabled) {
return SOURCES.filter(cfg => !cfg.disabled);
getSources(excludeDisabled = false, dedicated = null) {
let list = SOURCES;
if (dedicated === true) {
list = DEDICATED_SOURCES;
} else if (dedicated === false) {
list = AGGREGATOR_SOURCES;
}
return SOURCES;
if (excludeDisabled) {
return list.filter(cfg => !cfg.disabled);
}
return list;
}
getEmbeds({ ads = null } = {}) {
if (typeof ads === 'boolean') {
return EMBEDS.filter(cfg => cfg.ads === ads);
}
return EMBEDS;
}
getEmbedUrl(key, id, s = null, e = null) {
const cfg = EMBED_MAP[key];
if (!cfg) throw new Error(`Embed with key "${key}" not found`);
const isTv = s != null && e != null;
const template = isTv ? cfg.tv : cfg.movie;
if (!template || id == null) return null;
let url = template.replace('{id}', encodeURIComponent(String(id)));
if (isTv) {
url = url
.replace('{s}', encodeURIComponent(String(s)))
.replace('{e}', encodeURIComponent(String(e)));
}
return url;
}
async probeAllSources() {
const active = SOURCES.filter(cfg => !cfg.disabled);