mirror of
https://gitlab.com/vyla-entertainment/sdk.git
synced 2026-11-19 16:47:24 -05:00
added embed config and adde dedicated section for config
This commit is contained in:
37
src/sdk.js
37
src/sdk.js
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user