organized/fixed streams

This commit is contained in:
2026-10-31 12:37:24 -07:00
parent 95f4991914
commit 7473c0fa15
51 changed files with 2920 additions and 3059 deletions

View File

@@ -2,7 +2,8 @@
"name": "@vyla-entertainment/sdk", "name": "@vyla-entertainment/sdk",
"version": "1.20.0", "version": "1.20.0",
"scripts": { "scripts": {
"test": "node test/index.js" "test": "node test/index.js",
"test:all": "node test/index.js all"
}, },
"author": "vyla-entertainment", "author": "vyla-entertainment",
"contributors": [ "contributors": [

View File

@@ -94,24 +94,6 @@ export const SOURCES = [
}], }],
}, },
{
key: 'cinezo',
label: 'Cinezo',
sourceFile: 'cinezo',
proxyParam: 'czo',
timeout: 25000,
jitter: 500,
retries: 2,
multiUrl: true,
cdnHeaders: [{
pattern: /yenime\.net|flikhub\.net|hakunaymatata\.com/i,
headers: {
Referer: 'https://player.cinezo.live/',
Origin: 'https://player.cinezo.live',
},
}],
},
{ {
key: 'cno', key: 'cno',
label: 'Cno', label: 'Cno',
@@ -355,7 +337,7 @@ export const SOURCES = [
retries: 1, retries: 1,
multiUrl: true, multiUrl: true,
skipProxy: true, skipProxy: true,
disabled: false, // Enabled, but only returns streams when a manifest is provided disabled: false,
}, },
{ {
@@ -499,26 +481,6 @@ export const SOURCES = [
multiUrl: true, multiUrl: true,
}, },
{
key: 'vidrock',
label: 'VidRock',
sourceFile: 'vidrock',
proxyParam: 'vr',
timeout: 20000,
jitter: 800,
retries: 3,
multiUrl: true,
cdnHeaders: [{
pattern: /./,
headers: {
Accept: '/',
'Accept-Language': 'en-US,en;q=0.9',
Referer: 'https://vidrock.ru/',
Origin: 'https://vidrock.ru',
},
},],
},
{ {
key: 'vidup', key: 'vidup',
label: 'VidUp', label: 'VidUp',

33
src/sdk.d.ts vendored
View File

@@ -20,10 +20,12 @@ export interface SourceConfig {
disabled?: boolean; disabled?: boolean;
sourcesTimeout?: number; sourcesTimeout?: number;
} }
export interface ProbeResult { export interface ProbeResult {
ok: boolean; ok: boolean;
ms: number | null; ms: number | null;
} }
export interface StreamResult { export interface StreamResult {
url: string; url: string;
headers: { headers: {
@@ -46,6 +48,7 @@ export interface DownloadResult {
type: "mkv"; type: "mkv";
active: boolean; active: boolean;
} }
export interface SubtitleResult { export interface SubtitleResult {
label: string; label: string;
file: string; file: string;
@@ -64,30 +67,12 @@ export default class VylaSDK {
constructor(options?: VylaSDKOptions); constructor(options?: VylaSDKOptions);
/**
* Get the list of configured sources.
* @param excludeDisabled If true, filters out disabled sources.
*/
getSources(excludeDisabled?: boolean): SourceConfig[]; getSources(excludeDisabled?: boolean): SourceConfig[];
/**
* Probe all active (non-disabled) sources for availability.
*/
probeAllSources(): Promise<ProbeAllResult>; probeAllSources(): Promise<ProbeAllResult>;
/**
* Probe a single source by key.
*/
probeSource(key: string): Promise<ProbeResult>; probeSource(key: string): Promise<ProbeResult>;
/**
* Get a playable stream for a given source/media id.
* @param key Source key
* @param id Media id (e.g. TMDB id)
* @param s Season number (for TV), or null for movies
* @param e Episode number (for TV), or null for movies
* @param clientIP Optional client IP for source-specific logic
*/
getStream( getStream(
key: string, key: string,
id: string | number, id: string | number,
@@ -96,24 +81,12 @@ export default class VylaSDK {
clientIP?: string | null clientIP?: string | null
): Promise<StreamResult | { allUrls: StreamResult[] }>; ): Promise<StreamResult | { allUrls: StreamResult[] }>;
/**
* Get subtitles for a movie or TV episode.
* @param id Media id
* @param s Season number (for TV), or null for movies
* @param e Episode number (for TV), or null for movies
*/
getSubtitles( getSubtitles(
id: string | number, id: string | number,
s?: number | null, s?: number | null,
e?: number | null e?: number | null
): Promise<SubtitleResult[]>; ): Promise<SubtitleResult[]>;
/**
* Get download links for a movie or TV episode.
* @param id Media id
* @param s Season number (for TV), or null for movies
* @param e Episode number (for TV), or null for movies
*/
getDownloads( getDownloads(
id: string | number, id: string | number,
s?: number | null, s?: number | null,

View File

@@ -1,78 +1,82 @@
import SOURCES, { SOURCE_MAP } from "./config.js"; import SOURCES, { SOURCE_MAP } from "./config.js";
import { fetchDownloads } from "./downloads/downloads.js"; import { fetchDownloads } from "./downloads/downloads.js";
import { probeSource } from "./health.js"; import { probeSource } from "./health.js";
import { getChapterPages, getMangaDetails, searchManga } from "./manga/atsu.js"; import { getChapterPages, getMangaDetails, searchManga } from "./manga/atsu.js";
import { fetchSubtitles, getSubPathsMovie, getSubPathsTv } from "./subtitles.js"; import { fetchSubtitles, getSubPathsMovie, getSubPathsTv } from "./subtitles.js";
import { createStreamArgs } from "./utils/helpers.js"; import { createStreamArgs } from "./utils/helpers.js";
const ALL_SOURCE_MODULES = Object.fromEntries( const ALL_SOURCE_MODULES = Object.fromEntries(
await Promise.all(SOURCES.map(async cfg => [cfg.key, await import(`./sources/${cfg.sourceFile}.js`)])) await Promise.all(SOURCES.map(async cfg => [cfg.key, await import(`./sources/${cfg.sourceFile}.js`)]))
); );
const SOURCE_MODULES = Object.fromEntries( const SOURCE_MODULES = Object.fromEntries(
Object.entries(ALL_SOURCE_MODULES).filter(([key]) => !SOURCE_MAP[key]?.disabled) Object.entries(ALL_SOURCE_MODULES).filter(([key]) => !SOURCE_MAP[key]?.disabled)
); );
export default class VylaSDK { export default class VylaSDK {
tmdbApiKey = null; tmdbApiKey = null;
penguManifest = null; penguManifest = null;
constructor({ tmdbApiKey, penguManifest } = {}) { constructor({ tmdbApiKey, penguManifest } = {}) {
this.tmdbApiKey = tmdbApiKey || null; this.tmdbApiKey = tmdbApiKey || null;
this.penguManifest = penguManifest || null; this.penguManifest = penguManifest || null;
} }
getSources(excludeDisabled = false) { getSources(excludeDisabled = false) {
if (excludeDisabled) { if (excludeDisabled) {
return SOURCES.filter(cfg => !cfg.disabled); return SOURCES.filter(cfg => !cfg.disabled);
} }
return SOURCES; return SOURCES;
} }
async probeAllSources() { async probeAllSources() {
const active = SOURCES.filter(cfg => !cfg.disabled); const active = SOURCES.filter(cfg => !cfg.disabled);
const results = await Promise.allSettled( const results = await Promise.allSettled(
active.map(async cfg => await probeSource(cfg, SOURCE_MODULES[cfg.key])) active.map(async cfg => await probeSource(this, cfg, SOURCE_MODULES[cfg.key]))
); );
const sources = Object.fromEntries( const sources = Object.fromEntries(
active.map((cfg, i) => [ active.map((cfg, i) => [
cfg.key, cfg.key,
results[i].status === 'fulfilled' ? results[i].value : { ok: false, ms: null }, results[i].status === 'fulfilled' ? results[i].value : { ok: false, ms: null },
]) ])
); );
return sources; return sources;
} }
async probeSource(key) { async probeSource(key) {
const cfg = SOURCES.find(cfg => cfg.key === key); const cfg = SOURCES.find(cfg => cfg.key === key);
if (!cfg) throw new Error(`Source with key "${key}" not found`); if (!cfg) throw new Error(`Source with key "${key}" not found`);
const mod = SOURCE_MODULES[key]; const mod = SOURCE_MODULES[key];
if (!mod) throw new Error(`Source module for key "${key}" not found`); if (!mod) throw new Error(`Source module for key "${key}" not found`);
return await probeSource(this, cfg, mod); return await probeSource(this, cfg, mod);
} }
async getStream(key, id, s = null, e = null, clientIP = null) { async getStream(key, id, s = null, e = null, clientIP = null) {
const cfg = SOURCES.find(cfg => cfg.key === key); const cfg = SOURCES.find(cfg => cfg.key === key);
if (!cfg) throw new Error(`Source with key "${key}" not found`); if (!cfg) throw new Error(`Source with key "${key}" not found`);
const mod = SOURCE_MODULES[key]; const mod = SOURCE_MODULES[key];
if (!mod) throw new Error(`Source module for key "${key}" not found`); if (!mod) throw new Error(`Source module for key "${key}" not found`);
const streamArgs = await createStreamArgs(cfg, this, id, s, e, clientIP); const streamArgs = await createStreamArgs(cfg, this, id, s, e, clientIP);
return await mod.getStream(streamArgs); const result = await mod.getStream(streamArgs);
} if (result && typeof result === 'object') {
async getSubtitles(id, s = null, e = null) { delete result.subtitles;
const paths = s != null && e != null }
? await getSubPathsTv(id, s, e) return result;
: await getSubPathsMovie(id); }
return await fetchSubtitles(paths); async getSubtitles(id, s = null, e = null) {
} const paths = s != null && e != null
async getDownloads(id, s = null, e = null) { ? await getSubPathsTv(id, s, e)
return await fetchDownloads(this, id, s, e); : await getSubPathsMovie(id);
} return await fetchSubtitles(paths);
async searchManga(query, page = 1, perPage = 12) { }
return await searchManga(query, page, perPage); async getDownloads(id, s = null, e = null) {
} return await fetchDownloads(this, id, s, e);
async getManga(id) { }
return await getMangaDetails(id); async searchManga(query, page = 1, perPage = 12) {
} return await searchManga(query, page, perPage);
async getMangaChapter(mangaId, chapterId) { }
return await getChapterPages(mangaId, chapterId); async getManga(id) {
} return await getMangaDetails(id);
} }
async getMangaChapter(mangaId, chapterId) {
return await getChapterPages(mangaId, chapterId);
}
}

View File

@@ -1,11 +1,11 @@
import { getUA } from '../utils/helpers.js'; import { getUA, resolveImdbId, resolveTmdbKey } from '../utils/helpers.js';
const SERVICE_ORIGIN = 'https://st.111477.xyz'; const SERVICE_ORIGIN = 'https://st.111477.xyz';
function generateManifestBaseUrl(tmdbKey) { function generateManifestBaseUrl(apiKey) {
let config = 'https://a.111477.xyz/::sort=file-desc::limit=3'; let config = 'https://a.111477.xyz/::sort=file-desc::limit=3';
if (tmdbKey) { if (apiKey) {
config += `::tmdb=${tmdbKey}`; config += `::tmdb=${apiKey}`;
} }
const b64 = Buffer.from(config, 'utf8') const b64 = Buffer.from(config, 'utf8')
.toString('base64') .toString('base64')
@@ -15,28 +15,13 @@ function generateManifestBaseUrl(tmdbKey) {
return `${SERVICE_ORIGIN}/config/${b64}`; return `${SERVICE_ORIGIN}/config/${b64}`;
} }
async function resolveImdbId(sdk, id, isTv) { export async function getStream(args) {
const apiKey = sdk?.tmdbApiKey || process.env.TMDB_API_KEY; const { id, s, e, sdk } = args || {};
if (!apiKey) return null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie'; const apiKey = resolveTmdbKey(args, sdk);
try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`, {
signal: AbortSignal.timeout(6000),
});
if (!res.ok) return null;
const data = await res.json();
return data.imdb_id || data.external_ids?.imdb_id || null;
} catch {
return null;
}
}
export async function getStream({ id, s, e, sdk }) {
const isTv = Boolean(s && e);
const ua = getUA(); const ua = getUA();
const apiKey = sdk?.tmdbApiKey || process.env.TMDB_API_KEY;
const imdbId = await resolveImdbId(sdk, id, isTv); const imdbId = await resolveImdbId(id, isTv, apiKey);
const targetIds = []; const targetIds = [];
if (imdbId && imdbId.startsWith('tt')) { if (imdbId && imdbId.startsWith('tt')) {
@@ -48,7 +33,7 @@ export async function getStream({ id, s, e, sdk }) {
const seenUrls = new Set(); const seenUrls = new Set();
const allUrls = []; const allUrls = [];
const defaultHeaders = { const headers = {
'User-Agent': ua, 'User-Agent': ua,
Accept: 'application/json, text/plain, */*', Accept: 'application/json, text/plain, */*',
}; };
@@ -60,7 +45,7 @@ export async function getStream({ id, s, e, sdk }) {
try { try {
const res = await fetch(endpoint, { const res = await fetch(endpoint, {
headers: defaultHeaders, headers,
signal: AbortSignal.timeout(12000), signal: AbortSignal.timeout(12000),
}); });
@@ -70,19 +55,22 @@ export async function getStream({ id, s, e, sdk }) {
if (Array.isArray(data?.streams) && data.streams.length > 0) { if (Array.isArray(data?.streams) && data.streams.length > 0) {
for (const item of data.streams) { for (const item of data.streams) {
if (!item || typeof item !== 'object') continue; if (!item || typeof item !== 'object') continue;
const url = String(item.url || '').trim(); const streamUrl = String(item.url || '').trim();
if (!url || !url.startsWith('http') || seenUrls.has(url)) continue; if (!streamUrl || !streamUrl.startsWith('http') || seenUrls.has(streamUrl)) continue;
seenUrls.add(url); seenUrls.add(streamUrl);
const rawTitle = item.title ? String(item.title).trim() : ''; const rawTitle = item.title ? String(item.title).trim() : '';
const rawName = item.name ? String(item.name).trim() : '111477'; const rawName = item.name ? String(item.name).trim() : '111477';
const label = rawTitle || rawName; const label = rawTitle || rawName;
allUrls.push({ allUrls.push({
url, url: streamUrl,
label, label,
headers: defaultHeaders, server: label,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers,
}); });
} }
@@ -95,7 +83,7 @@ export async function getStream({ id, s, e, sdk }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls,
}; };
} }

View File

@@ -1,57 +1,121 @@
import { getTmdbInfo, fetchJson, USER_AGENT } from '../utils/helpers.js'; import { fetchJson, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
async function resolveSlug(id, s, e, info) { const BASE_URL = 'https://123animehub.cc';
const titles = info?.titles || []; const CDN_ORIGIN = 'https://play2.echovideo.ru';
const keywords = [];
for (const title of titles) { async function resolveSlug(id, s, e, titles) {
const t = title.toLowerCase().replace(/[^a-z0-9\s]/g, ' ').replace(/\s+/g, ' ').trim(); const keywords = [];
if (!keywords.includes(t)) keywords.push(t); for (const title of titles) {
const words = title.split(/[\s:]+/).filter(w => w.length > 2); const t = title.toLowerCase().replace(/[^a-z0-9\s]/g, ' ').replace(/\s+/g, ' ').trim();
if (words.length >= 2) { if (!keywords.includes(t)) keywords.push(t);
const short = words.slice(0, 3).join(' ').toLowerCase(); const words = title.split(/[\s:]+/).filter(w => w.length > 2);
if (!keywords.includes(short)) keywords.push(short); if (words.length >= 2) {
} const short = words.slice(0, 3).join(' ').toLowerCase();
} if (!keywords.includes(short)) keywords.push(short);
const slugCandidates = []; }
for (const keyword of keywords) { }
try {
const data = await fetchJson(`https://123animehub.cc/ajax/film/search?keyword=${encodeURIComponent(keyword)}&_=${Date.now()}`, { headers: { 'X-Requested-With': 'XMLHttpRequest', 'Referer': 'https://123animehub.cc', 'Accept': 'application/json', 'User-Agent': USER_AGENT }, signal: AbortSignal.timeout(8000) }); const slugCandidates = [];
let html = data.html || '', idx = 0; for (const keyword of keywords) {
while ((idx = html.indexOf('href="/anime/', idx)) !== -1) { try {
const start = idx + 13; const data = await fetchJson(`${BASE_URL}/ajax/film/search?keyword=${encodeURIComponent(keyword)}&_=${Date.now()}`, {
const end = html.indexOf('"', start); headers: {
const slug = html.slice(start, end); 'X-Requested-With': 'XMLHttpRequest',
if (!slugCandidates.includes(slug)) slugCandidates.push(slug); Referer: `${BASE_URL}/`,
idx = end; Accept: 'application/json',
} 'User-Agent': USER_AGENT,
} catch { } },
if (slugCandidates.length) break; signal: AbortSignal.timeout(8000),
} });
for (const slug of slugCandidates) { let html = data.html || '';
try { let idx = 0;
const data = await fetchJson(`https://123animehub.cc/ajax/episode/info?epr=${encodeURIComponent(s ? `${slug}/${s}/${e}` : `${slug}/1`)}&ts=1&_=${Date.now()}`, { headers: { 'Referer': `https://123animehub.cc/anime/${slug}`, 'X-Requested-With': 'XMLHttpRequest', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'User-Agent': USER_AGENT }, signal: AbortSignal.timeout(10000) }); while ((idx = html.indexOf('href="/anime/', idx)) !== -1) {
if (data?.target) return data.target; const start = idx + 13;
} catch { } const end = html.indexOf('"', start);
} const slug = html.slice(start, end);
return null; if (!slugCandidates.includes(slug)) slugCandidates.push(slug);
} idx = end;
}
export async function getStream({ id, s, e }) { } catch { }
if (!s) return null; if (slugCandidates.length) break;
const info = await getTmdbInfo(id, 'tv', s); }
if (!info.isAnime) return null;
const target = await resolveSlug(id, s, e, info); for (const slug of slugCandidates) {
if (!target) return null; try {
const embedMatch = target.match(/\/embed-[^/]+\/([A-Za-z0-9+/=]+)$/); const data = await fetchJson(`${BASE_URL}/ajax/episode/info?epr=${encodeURIComponent(s ? `${slug}/${s}/${e}` : `${slug}/1`)}&ts=1&_=${Date.now()}`, {
if (!embedMatch) return null; headers: {
const origin = new URL(target).origin; Referer: `${BASE_URL}/anime/${slug}`,
try { 'X-Requested-With': 'XMLHttpRequest',
const embedRes = await fetch(target, { headers: { 'User-Agent': USER_AGENT }, signal: AbortSignal.timeout(10000) }); Accept: 'application/json, text/javascript, */*; q=0.01',
if (!embedRes.ok) return null; 'User-Agent': USER_AGENT,
const setCookie = embedRes.headers.get('set-cookie'); },
const data = await fetchJson(`${origin}/hs/getSources?id=${embedMatch[1]}`, { headers: { 'Referer': target, 'Accept': '*/*', 'User-Agent': USER_AGENT, ...(setCookie ? { 'Cookie': setCookie.split(';')[0].trim() } : {}) }, signal: AbortSignal.timeout(10000) }); signal: AbortSignal.timeout(10000),
const src = typeof data.sources === 'string' && data.sources.length ? data.sources : (Array.isArray(data.sources) && data.sources.length ? (data.sources[0].file || data.sources[0].src || data.sources[0].url) : null); });
if (src) return { url: src, headers: { 'Referer': 'https://play2.echovideo.ru/', 'Origin': 'https://play2.echovideo.ru' } }; if (data?.target) return data.target;
} catch { } } catch { }
return null; }
return null;
}
export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
if (!s) return null;
const apiKey = resolveTmdbKey(args, sdk);
const meta = await getTmdbMetadata(id, isTv, apiKey);
if (!meta?.isAnime) return null;
const target = await resolveSlug(id, s, e, meta.titles || []);
if (!target) return null;
const embedMatch = target.match(/\/embed-[^/]+\/([A-Za-z0-9+/=]+)$/);
if (!embedMatch) return null;
const origin = new URL(target).origin;
try {
const embedRes = await fetch(target, {
headers: { 'User-Agent': USER_AGENT },
signal: AbortSignal.timeout(10000),
});
if (!embedRes.ok) return null;
const setCookie = embedRes.headers.get('set-cookie');
const data = await fetchJson(`${origin}/hs/getSources?id=${embedMatch[1]}`, {
headers: {
Referer: target,
Accept: '*/*',
'User-Agent': USER_AGENT,
...(setCookie ? { Cookie: setCookie.split(';')[0].trim() } : {}),
},
signal: AbortSignal.timeout(10000),
});
const streamUrl = typeof data.sources === 'string' && data.sources.length
? data.sources
: (Array.isArray(data.sources) && data.sources.length ? (data.sources[0].file || data.sources[0].src || data.sources[0].url) : null);
if (!streamUrl) return null;
const headers = {
Referer: `${CDN_ORIGIN}/`,
Origin: CDN_ORIGIN,
};
const allUrls = [{
url: streamUrl,
server: '123Anime',
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers,
}];
return {
url: streamUrl,
headers,
allUrls,
};
} catch {
return null;
}
} }

View File

@@ -1,101 +1,45 @@
import { getUA } from "../utils/helpers.js"; import { getTmdbMetadata, getUA, resolveTmdbKey, slugify } from '../utils/helpers.js';
const BASE_URL = "https://3eyedraven.watch"; const BASE_URL = 'https://3eyedraven.watch';
const API_BASE = "https://3eyedraven.watch/api"; const API_BASE = 'https://3eyedraven.watch/api';
function getHeaders() {
return {
"User-Agent": getUA(),
Accept: "application/json",
Referer: `${BASE_URL}/`,
Origin: BASE_URL,
};
}
function resolveApiKey(args) {
return (
args?.tmdbApiKey ||
args?.sdk?.tmdbApiKey ||
process.env.TMDB_API_KEY ||
null
);
}
async function getTitle(id, isTv, apiKey) {
if (!apiKey) return null;
const type = isTv ? "tv" : "movie";
try {
const res = await fetch(
`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`,
{ signal: AbortSignal.timeout(5000) }
);
if (!res.ok) return null;
const data = await res.json();
return isTv ? data.name : data.title;
} catch {
return null;
}
}
function slugify(text) {
return text
.toLowerCase()
.normalize("NFKD")
.replace(/[\u0300-\u036f]/g, "")
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "");
}
function absolute(url) { function absolute(url) {
if (!url) return ""; if (!url) return '';
if (/^https?:\/\//.test(url)) return url; if (/^https?:\/\//.test(url)) return url;
return `${BASE_URL}${url.startsWith("/") ? "" : "/"}${url}`; return `${BASE_URL}${url.startsWith('/') ? '' : '/'}${url}`;
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s = null, e = null } = args; const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const apiKey = resolveTmdbKey(args, sdk);
const apiKey = resolveApiKey(args); const meta = await getTmdbMetadata(id, isTv, apiKey);
const title = await getTitle(id, isTv, apiKey); const title = meta?.title;
if (!title) return null;
if (!title) {
if (process.env.DEBUG_CAUSE) {
console.error(
`[3eyedraven] Could not resolve title for ${isTv ? "tv" : "movie"} ${id} ` +
`(tmdbApiKey ${apiKey ? "present" : "MISSING"})`
);
}
return null;
}
const identifier = `${slugify(title)}-${id}`; const identifier = `${slugify(title)}-${id}`;
const url = isTv const url = isTv
? `${API_BASE}/stream/${identifier}?season=${s}&episode=${e}` ? `${API_BASE}/stream/${identifier}?season=${s}&episode=${e}`
: `${API_BASE}/stream/${identifier}`; : `${API_BASE}/stream/${identifier}`;
const headers = {
'User-Agent': getUA(),
Accept: 'application/json',
Referer: `${BASE_URL}/`,
Origin: BASE_URL,
};
try { try {
const res = await fetch(url, { const res = await fetch(url, {
headers: getHeaders(), headers,
signal: AbortSignal.timeout(15000), signal: AbortSignal.timeout(15000),
}); });
if (!res.ok) return null;
if (!res.ok) {
if (process.env.DEBUG_CAUSE) {
console.error(`[3eyedraven] HTTP ${res.status} for ${url}`);
}
return null;
}
const data = await res.json(); const data = await res.json();
const stream = data?.stream; const stream = data?.stream;
if (!stream?.url) { if (!stream?.url) return null;
if (process.env.DEBUG_CAUSE) {
console.error(`[3eyedraven] No stream.url in response for ${url}`);
}
return null;
}
const streamUrl = absolute(stream.url); const streamUrl = absolute(stream.url);
if (!/^https?:\/\//.test(streamUrl)) return null; if (!/^https?:\/\//.test(streamUrl)) return null;
@@ -105,32 +49,35 @@ export async function getStream(args) {
const subUrl = absolute(sub.url); const subUrl = absolute(sub.url);
if (!subUrl) return null; if (!subUrl) return null;
return { return {
label: sub.label || sub.language || "Subtitle", label: sub.label || sub.language || 'Subtitle',
file: subUrl, file: subUrl,
type: "vtt", type: 'vtt',
source: "3eyedraven", source: '3eyedraven',
}; };
}) })
.filter(Boolean); .filter(Boolean);
return { const allUrls = [{
url: streamUrl, url: streamUrl,
headers: { headers,
"User-Agent": getUA(), server: '3eyedraven',
Referer: `${BASE_URL}/`, quality: '1080p',
Origin: BASE_URL, type: stream.format === 'hls' ? 'hls' : 'mp4',
},
server: "3eyedraven",
quality: "1080p",
type: stream.format === "hls" ? "hls" : "mp4",
subtitles, subtitles,
skipProxy: true, skipProxy: true,
}];
return {
url: streamUrl,
headers,
server: '3eyedraven',
quality: '1080p',
type: stream.format === 'hls' ? 'hls' : 'mp4',
subtitles,
skipProxy: true,
allUrls,
}; };
} catch (err) { } catch {
if (process.env.DEBUG_CAUSE) {
console.error(`[3eyedraven] fetch error for ${url}:`, err.message);
if (err.cause) console.error(" cause:", err.cause.code, err.cause.message);
}
return null; return null;
} }
} }

View File

@@ -1,19 +1,38 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://zcdn.bluevelvet.space';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const url = isTv const url = isTv
? `https://zcdn.bluevelvet.space/cdn?tmdb=${id}&type=tv&season=${s}&episode=${e}` ? `${BASE_URL}/cdn?tmdb=${id}&type=tv&season=${s}&episode=${e}`
: `https://zcdn.bluevelvet.space/cdn?tmdb=${id}&type=movie`; : `${BASE_URL}/cdn?tmdb=${id}&type=movie`;
const res = await fetchJson(url); try {
if (!res || !res.ready || !res.url) return null; const res = await fetchJson(url);
if (!res || !res.ready || !res.url) return null;
return { const headers = {
url: res.url, Referer: `${BASE_URL}/`,
headers: { Origin: BASE_URL,
Referer: 'https://zcdn.bluevelvet.space/', };
Origin: 'https://zcdn.bluevelvet.space',
} const allUrls = [{
}; url: res.url,
server: 'CineCat',
quality: 'Auto',
type: res.url.includes('.m3u8') ? 'hls' : 'mp4',
headers,
}];
return {
url: res.url,
headers,
allUrls,
};
} catch {
return null;
}
} }

View File

@@ -1,19 +1,18 @@
import crypto from "crypto"; import crypto from 'node:crypto';
import { Session, ClientIdentifier, initTLS, destroyTLS } from "node-tls-client"; import { ClientIdentifier, destroyTLS, initTLS, Session } from 'node-tls-client';
const BASE_URL = "https://cinema.army"; const BASE_URL = 'https://cinema.army';
const API_BASE = "https://cinema.army/api"; const API_BASE = `${BASE_URL}/api`;
const HMAC_KEY = 'a2cfc9eaa2a3690b5d4f6b5f958dbdeae52a097283d375bd253ee7c7062524f5';
const XOR_KEY = "f16a6b92fcd6eed3e9476297f893f2505c32f79bc6efef9b6c95496aa5914548"; const XOR_KEY = 'f16a6b92fcd6eed3e9476297f893f2505c32f79bc6efef9b6c95496aa5914548';
const HMAC_KEY = "a2cfc9eaa2a3690b5d4f6b5f958dbdeae52a097283d375bd253ee7c7062524f5"; const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
const UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
const SERVERS = [ const SERVERS = [
{ key: "cookiebakers", method: "POST", label: "CookieBakers" }, { key: 'cookiebakers', label: 'CookieBakers', method: 'POST' },
{ key: "tcloud", method: "GET", label: "TCloud" }, { key: 'tcloud', label: 'TCloud', method: 'POST' },
{ key: "ipcloud", method: "GET", label: "IPcloud" }, { key: 'ipcloud', label: 'IPCloud', method: 'POST' },
{ key: "dcloud", method: "GET", label: "Dcloud" }, { key: 'dcloud', label: 'DCloud', method: 'POST' },
{ key: 'tidb', label: 'TIDB', method: 'POST' },
]; ];
let tlsInitialized = false; let tlsInitialized = false;
@@ -40,22 +39,22 @@ function getHeaders(token, id, isTv, s, e) {
: `${BASE_URL}/watch?id=${id}&type=movie`; : `${BASE_URL}/watch?id=${id}&type=movie`;
return { return {
"User-Agent": UA, 'User-Agent': UA,
"Accept": "application/json", Accept: 'application/json',
"Accept-Language": "en-US,en;q=0.9", 'Accept-Language': 'en-US,en;q=0.9',
"Accept-Encoding": "gzip, deflate, br", 'Accept-Encoding': 'gzip, deflate, br',
"Cache-Control": "no-cache", 'Cache-Control': 'no-cache',
"Pragma": "no-cache", Pragma: 'no-cache',
"Referer": referer, Referer: referer,
"Origin": BASE_URL, Origin: BASE_URL,
"Sec-Ch-Ua": '"Chromium";v="131", "Not_A Brand";v="24"', 'Sec-Ch-Ua': '"Chromium";v="131", "Not_A Brand";v="24"',
"Sec-Ch-Ua-Mobile": "?0", 'Sec-Ch-Ua-Mobile': '?0',
"Sec-Ch-Ua-Platform": '"Windows"', 'Sec-Ch-Ua-Platform': '"Windows"',
"Sec-Fetch-Dest": "empty", 'Sec-Fetch-Dest': 'empty',
"Sec-Fetch-Mode": "cors", 'Sec-Fetch-Mode': 'cors',
"Sec-Fetch-Site": "same-origin", 'Sec-Fetch-Site': 'same-origin',
"Priority": "u=1, i", Priority: 'u=1, i',
"X-Stream-Token": token, 'X-Stream-Token': token,
}; };
} }
@@ -63,20 +62,20 @@ function generateToken(id) {
try { try {
const minute = Math.floor(Date.now() / 1000 / 60); const minute = Math.floor(Date.now() / 1000 / 60);
return crypto return crypto
.createHmac("sha256", HMAC_KEY) .createHmac('sha256', HMAC_KEY)
.update(`${id}:${minute}`) .update(`${id}:${minute}`)
.digest("hex"); .digest('hex');
} catch { } catch {
return ""; return '';
} }
} }
function decryptStreamUrl(encoded) { function decryptStreamUrl(encoded) {
if (!encoded) return ""; if (!encoded) return '';
if (encoded.startsWith("http://") || encoded.startsWith("https://")) return encoded; if (encoded.startsWith('http://') || encoded.startsWith('https://')) return encoded;
try { try {
const decoded = Buffer.from(encoded, "base64").toString("binary"); const decoded = Buffer.from(encoded, 'base64').toString('binary');
let out = ""; let out = '';
for (let i = 0; i < decoded.length; i++) { for (let i = 0; i < decoded.length; i++) {
out += String.fromCharCode( out += String.fromCharCode(
decoded.charCodeAt(i) ^ XOR_KEY.charCodeAt(i % XOR_KEY.length) decoded.charCodeAt(i) ^ XOR_KEY.charCodeAt(i % XOR_KEY.length)
@@ -89,7 +88,7 @@ function decryptStreamUrl(encoded) {
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s = null, e = null } = args; const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const token = generateToken(id); const token = generateToken(id);
@@ -107,62 +106,62 @@ export async function getStream(args) {
const results = await Promise.allSettled( const results = await Promise.allSettled(
requests.map(async ({ url, server }) => { requests.map(async ({ url, server }) => {
try { try {
const res = server.method === "POST" const res = server.method === 'POST'
? await sess.post(url, { headers }) ? await sess.post(url, { headers, body: '' })
: await sess.get(url, { headers }); : await sess.get(url, { headers });
if (res.status !== 200) { if (res?.status !== 200) return null;
if (process.env.DEBUG_CAUSE) {
console.error(`[CinemaArmy ${server.key}] HTTP ${res.status}`); const rawBody = typeof res.text === 'function' ? await res.text() : res.body;
}
return null;
}
const text = await res.text();
let data; let data;
try { try {
data = JSON.parse(text); data = typeof rawBody === 'object' && rawBody !== null ? rawBody : JSON.parse(rawBody);
} catch { } catch (err) {
return null; return null;
} }
const encrypted = data?.stream?.url; const encrypted = data?.stream?.url;
if (!encrypted) return null; if (!encrypted) {
return null;
}
const streamUrl = decryptStreamUrl(encrypted); const streamUrl = decryptStreamUrl(encrypted);
if (!streamUrl || !/^https?:\/\//.test(streamUrl)) return null;
if (!streamUrl || !/^https?:\/\//.test(streamUrl)) {
return null;
}
return { return {
url: streamUrl, url: streamUrl,
headers: { headers: {
"User-Agent": UA, 'User-Agent': UA,
Referer: `${BASE_URL}/`, Referer: `${BASE_URL}/`,
Origin: BASE_URL, Origin: BASE_URL,
}, },
server: `CinemaArmy (${server.label})`, server: `CinemaArmy (${server.label})`,
quality: "1080p", quality: '1080p',
type: streamUrl.includes(".m3u8") ? "hls" : "mp4", type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
}; };
} catch (err) { } catch (err) {
if (process.env.DEBUG_CAUSE) {
console.error(`[CinemaArmy ${server.key}] ${err.message}`);
if (err.cause) {
console.error(` cause.code: ${err.cause.code || "n/a"}`);
console.error(` cause.message: ${err.cause.message || err.cause}`);
}
}
return null; return null;
} }
}) })
); );
const allUrls = results const allUrls = results
.filter(r => r.status === "fulfilled" && r.value) .filter(r => r.status === 'fulfilled' && r.value)
.map(r => r.value); .map(r => r.value);
if (!allUrls.length) return null; if (!allUrls.length) {
return null;
}
return { allUrls }; return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} }
export async function cleanup() { export async function cleanup() {

View File

@@ -1,6 +1,6 @@
import { fetchJson, fetchText } from '../utils/helpers.js'; import { fetchJson, fetchText } from '../utils/helpers.js';
const API = "https://enc-dec.app/api"; const API = 'https://enc-dec.app/api';
async function solveStage1(challenge1, seed) { async function solveStage1(challenge1, seed) {
const K = [ const K = [
@@ -210,91 +210,93 @@ async function solveStage2(data) {
throw new Error('no solution found'); throw new Error('no solution found');
} }
export async function getStream({ id, s, e }) { export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const mediaType = isTv ? 'tv' : 'movie';
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
const url = isTv const url = isTv
? `https://cinesrc.st/embed/tv/${id}?s=${s}&e=${e}` ? `https://cinesrc.st/embed/tv/${id}?s=${s}&e=${e}`
: `https://cinesrc.st/embed/movie/${id}`; : `https://cinesrc.st/embed/movie/${id}`;
const headers = { const headers = {
"Origin": "https://cinesrc.st", Origin: 'https://cinesrc.st',
"Referer": "https://cinesrc.st/", Referer: 'https://cinesrc.st/',
"Content-Type": "text/plain;charset=UTF-8", 'Content-Type': 'text/plain;charset=UTF-8',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.37 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.37" 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.37 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.37',
}; };
const fields = [type, id, s ? String(s) : null, e ? String(e) : null]; const fields = [type, id, s ? String(s) : null, e ? String(e) : null];
const encoded = btoa(JSON.stringify(fields).replace(/ /g, '')).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); const encoded = btoa(JSON.stringify(fields).replace(/ /g, '')).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
const bootstrapHeaders = { ...headers, "x-cs-q": encoded }; const bootstrapHeaders = { ...headers, 'x-cs-q': encoded };
const bootstrap = await fetchJson("https://cinesrc.st/api/c/bootstrap", { const bootstrap = await fetchJson('https://cinesrc.st/api/c/bootstrap', {
method: "POST", method: 'POST',
headers: bootstrapHeaders, headers: bootstrapHeaders,
body: "{}" body: '{}',
}); });
const cookies = { const cookies = {
"x-cs-b": "20261014-a", 'x-cs-b': '20261014-a',
"x-cs-q": encoded, 'x-cs-q': encoded,
"x-cs-r": bootstrap.r, 'x-cs-r': bootstrap.r,
"x-cs-p": bootstrap.p, 'x-cs-p': bootstrap.p,
}; };
const challenge1 = await fetchJson("https://cinesrc.st/api/c/issue", { const challenge1 = await fetchJson('https://cinesrc.st/api/c/issue', {
headers: { ...headers, ...cookies } headers: { ...headers, ...cookies },
}); });
const payload1 = { const payload1 = {
data: { data: {
url, url,
user_agent: headers["User-Agent"], user_agent: headers['User-Agent'],
challenge_data: challenge1 challenge_data: challenge1,
}, },
type: "seed" type: 'seed',
}; };
const seedRes = await fetchJson(`${API}/enc-cinesrc`, { const seedRes = await fetchJson(`${API}/enc-cinesrc`, {
method: "POST", method: 'POST',
headers: { "Content-Type": "application/json" }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload1) body: JSON.stringify(payload1),
}); });
const seedData = seedRes.result; const seedData = seedRes.result;
const solution1 = await solveStage1(challenge1, seedData.seed); const solution1 = await solveStage1(challenge1, seedData.seed);
const challenge2 = await fetchJson("https://cinesrc.st/api/c/stage2/issue", { const challenge2 = await fetchJson('https://cinesrc.st/api/c/stage2/issue', {
headers: { ...headers, ...cookies } headers: { ...headers, ...cookies },
}); });
const solution2 = await solveStage2(challenge2); const solution2 = await solveStage2(challenge2);
const payload2 = { const payload2 = {
data: { data: {
url, url,
user_agent: headers["User-Agent"], user_agent: headers['User-Agent'],
challenge_data: { challenge_data: {
stage1: { challenge: challenge1, solution: solution1 }, stage1: { challenge: challenge1, solution: solution1 },
stage2: { challenge: challenge2, solution: solution2 } stage2: { challenge: challenge2, solution: solution2 },
}, },
state: seedData.state state: seedData.state,
}, },
type: "encrypt" type: 'encrypt',
}; };
const encryptRes = await fetchJson(`${API}/enc-cinesrc`, { const encryptRes = await fetchJson(`${API}/enc-cinesrc`, {
method: "POST", method: 'POST',
headers: { "Content-Type": "application/json" }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload2) body: JSON.stringify(payload2),
}); });
const encData = encryptRes.result; const encData = encryptRes.result;
const token = `${encData.token}::c3::${cookies["x-cs-r"]}`; const token = `${encData.token}::c3::${cookies['x-cs-r']}`;
const nextActions = encData.headers; const nextActions = encData.headers;
const providersText = await fetchText(url, { const providersText = await fetchText(url, {
method: "POST", method: 'POST',
headers: { ...headers, ...cookies, "Next-Action": nextActions.getProviderList }, headers: { ...headers, ...cookies, 'Next-Action': nextActions.getProviderList },
body: JSON.stringify([]) body: JSON.stringify([]),
}); });
const lines = providersText.split('\n'); const lines = providersText.split('\n');
@@ -320,19 +322,19 @@ export async function getStream({ id, s, e }) {
const provider = providerObj.id; const provider = providerObj.id;
const streamPayload = [ const streamPayload = [
id, id,
isTv ? "show" : type, isTv ? 'show' : type,
isTv ? String(s) : "$undefined", isTv ? String(s) : '$undefined',
isTv ? String(e) : "$undefined", isTv ? String(e) : '$undefined',
token, token,
provider provider,
]; ];
let streamRes; let streamRes;
try { try {
streamRes = await fetchText(url, { streamRes = await fetchText(url, {
method: "POST", method: 'POST',
headers: { ...headers, ...cookies, "Next-Action": nextActions.getStream }, headers: { ...headers, ...cookies, 'Next-Action': nextActions.getStream },
body: JSON.stringify(streamPayload) body: JSON.stringify(streamPayload),
}); });
} catch { } catch {
continue; continue;
@@ -343,9 +345,9 @@ export async function getStream({ id, s, e }) {
let decryptRes; let decryptRes;
try { try {
decryptRes = await fetchJson(`${API}/dec-cinesrc`, { decryptRes = await fetchJson(`${API}/dec-cinesrc`, {
method: "POST", method: 'POST',
headers: { "Content-Type": "application/json" }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: streamRes, state: encData.state }) body: JSON.stringify({ text: streamRes, state: encData.state }),
}); });
} catch { } catch {
continue; continue;
@@ -378,10 +380,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `CineSrc - ${providerObj.name || provider}`, server: `CineSrc - ${providerObj.name || provider}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: resultData.headers || { headers: resultData.headers || {
Referer: "https://cinesrc.st/", Referer: 'https://cinesrc.st/',
Origin: "https://cinesrc.st" Origin: 'https://cinesrc.st',
} },
}); });
break; break;
} }
@@ -393,6 +397,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,55 +0,0 @@
import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) {
const isTv = s != null && e != null;
const referer = isTv
? `https://player.cinezo.live/embed/tv/${id}?s=${s}&e=${e}`
: `https://player.cinezo.live/embed/movie/${id}`;
const headers = {
'Accept': '*/*',
'Origin': 'https://player.cinezo.live',
'Referer': referer,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 Edg/155.0.0.0'
};
const hosts = [
'https://proxy.yenime.net',
'https://proxy1.flikhub.net'
];
const sources = ['zendaya', 'berlin', 'jennifer', 'scarlet'];
const allUrls = [];
for (const host of hosts) {
for (const source of sources) {
const url = isTv
? `${host}/tv?id=${id}&season=${s}&episode=${e}&mode=json&sources=${source}&hevc=1`
: `${host}/movie?id=${id}&mode=json&sources=${source}&hevc=1`;
try {
const res = await fetchJson(url, { headers });
const streamUrl = res?.source?.url;
if (streamUrl) {
allUrls.push({
url: streamUrl,
server: `Cinezo - ${res.source.label || source}`,
headers: {
Referer: 'https://player.cinezo.live/',
Origin: 'https://player.cinezo.live'
}
});
}
} catch { }
}
if (allUrls.length) break;
}
if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls
};
}

View File

@@ -1,20 +1,23 @@
import { fetchText } from '../utils/helpers.js'; import { fetchText } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://cno.to';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const serverIndices = Array.from({ length: 50 }, (_, i) => i + 1); const serverIndices = Array.from({ length: 50 }, (_, i) => i + 1);
const headers = { const headers = {
'Accept': 'application/json, text/plain, */*', Accept: 'application/json, text/plain, */*',
'Referer': 'https://cno.to/', Referer: `${BASE_URL}/`,
'Origin': 'https://cno.to', Origin: BASE_URL,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
}; };
const promises = serverIndices.map(async (serverNum) => { const promises = serverIndices.map(async (serverNum) => {
const url = isTv const url = isTv
? `https://cno.to/api/s/${serverNum}/tv/${id}/${s}/${e}` ? `${BASE_URL}/api/s/${serverNum}/tv/${id}/${s}/${e}`
: `https://cno.to/api/s/${serverNum}/movie/${id}?v=3`; : `${BASE_URL}/api/s/${serverNum}/movie/${id}?v=3`;
try { try {
const raw = await fetchText(url, { headers }); const raw = await fetchText(url, { headers });
@@ -50,16 +53,18 @@ export async function getStream({ id, s, e }) {
if (streamUrl) { if (streamUrl) {
if (streamUrl.startsWith('/')) { if (streamUrl.startsWith('/')) {
streamUrl = `https://cno.to${streamUrl}`; streamUrl = `${BASE_URL}${streamUrl}`;
} }
return { return {
url: streamUrl, url: streamUrl,
server: `Cno - Server ${serverNum} (${quality})`, server: `Cno - Server ${serverNum} (${quality})`,
quality,
type: 'hls',
headers: { headers: {
Referer: 'https://cno.to/', Referer: `${BASE_URL}/`,
Origin: 'https://cno.to' Origin: BASE_URL,
} },
}; };
} }
} }
@@ -71,10 +76,12 @@ export async function getStream({ id, s, e }) {
return { return {
url: jsonUrl, url: jsonUrl,
server: `Cno - Server ${serverNum} (${json.quality || 'Auto'})`, server: `Cno - Server ${serverNum} (${json.quality || 'Auto'})`,
quality: json.quality || 'Auto',
type: jsonUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://cno.to/', Referer: `${BASE_URL}/`,
Origin: 'https://cno.to' Origin: BASE_URL,
} },
}; };
} }
} catch { } } catch { }
@@ -90,6 +97,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,28 +1,8 @@
import { getUA } from '../utils/helpers.js'; import { getTmdbMetadata, getUA, resolveTmdbKey } from '../utils/helpers.js';
const BASE_URL = 'https://dulo.mov'; const BASE_URL = 'https://dulo.mov';
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
async function resolveDetails(sdk, id, isTv) {
const apiKey = sdk?.tmdbApiKey || process.env.TMDB_API_KEY;
if (!apiKey) return null;
const type = isTv ? 'tv' : 'movie';
try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, {
signal: AbortSignal.timeout(6000),
});
if (!res.ok) return null;
const data = await res.json();
const title = isTv ? data.name : data.title;
const releaseDate = isTv ? data.first_air_date : data.release_date;
const year = releaseDate ? releaseDate.split('-')[0] : '';
const runtime = isTv ? (data.episode_run_time?.[0] || 24) : (data.runtime || 90);
return { title, year, runtime };
} catch {
return null;
}
}
async function fetchSource(url, headers) { async function fetchSource(url, headers) {
try { try {
@@ -37,15 +17,17 @@ async function fetchSource(url, headers) {
} }
} }
export async function getStream({ id, s, e, sdk }) { export async function getStream(args) {
const isTv = Boolean(s && e); const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
const mediaType = isTv ? 'tv' : 'movie'; const mediaType = isTv ? 'tv' : 'movie';
const apiKey = resolveTmdbKey(args, sdk);
const ua = getUA(); const ua = getUA();
const details = await resolveDetails(sdk, id, isTv); const meta = await getTmdbMetadata(id, isTv, apiKey);
const title = details?.title || ''; const title = meta?.title || '';
const year = details?.year || ''; const year = meta?.year || '';
const runtime = details?.runtime || ''; const runtime = meta?.runtime || '';
const referer = isTv const referer = isTv
? `${BASE_URL}/watch/tv/${id}/${s}/${e}` ? `${BASE_URL}/watch/tv/${id}/${s}/${e}`
@@ -97,7 +79,7 @@ export async function getStream({ id, s, e, sdk }) {
while (pendingUrls.length > 0 && Date.now() < maxPollTime) { while (pendingUrls.length > 0 && Date.now() < maxPollTime) {
const results = await Promise.all( const results = await Promise.all(
pendingUrls.map((url) => fetchSource(url, defaultHeaders)) pendingUrls.map(url => fetchSource(url, defaultHeaders))
); );
const nextPending = []; const nextPending = [];
@@ -119,7 +101,10 @@ export async function getStream({ id, s, e, sdk }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: src.label || 'Dulo',
label: src.label || 'Dulo', label: src.label || 'Dulo',
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
'User-Agent': ua, 'User-Agent': ua,
Referer: referer, Referer: referer,
@@ -144,7 +129,7 @@ export async function getStream({ id, s, e, sdk }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls,
}; };
} }

View File

@@ -1,106 +1,115 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { export async function getStream(args) {
const isTv = s != null && e != null; const { id, s, e } = args || {};
const allUrls = []; const isTv = s != null && e != null;
const allUrls = [];
const endpoints = [
async () => { const endpoints = [
const url = isTv async () => {
? `https://themoviebox.uk/api/resolve?type=tv&id=${id}&season=${s}&episode=${e}` const url = isTv
: `https://themoviebox.uk/api/resolve?type=movie&id=${id}`; ? `https://themoviebox.uk/api/resolve?type=tv&id=${id}&season=${s}&episode=${e}`
const res = await fetchJson(url); : `https://themoviebox.uk/api/resolve?type=movie&id=${id}`;
if (res?.success && Array.isArray(res.sources)) { const res = await fetchJson(url);
for (const item of res.sources) { if (res?.success && Array.isArray(res.sources)) {
const streamUrl = item.url || item.original_url; for (const item of res.sources) {
if (streamUrl) { const streamUrl = item.url || item.original_url;
allUrls.push({ if (streamUrl) {
url: streamUrl, allUrls.push({
server: `TheMovieBox - ${item.server || item.provider || 'Server'}`, url: streamUrl,
headers: { server: `TheMovieBox - ${item.server || item.provider || 'Server'}`,
Referer: 'https://themoviebox.uk/', quality: 'Auto',
Origin: 'https://themoviebox.uk' type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
} headers: {
}); Referer: 'https://themoviebox.uk/',
} Origin: 'https://themoviebox.uk',
} },
} });
}, }
}
async () => { }
const url = isTv },
? `https://pro2.nabilekson.workers.dev/tv/${id}/${s}/${e}`
: `https://pro2.nabilekson.workers.dev/movie/${id}`; async () => {
const res = await fetchJson(url); const url = isTv
if (res?.success && Array.isArray(res.primarySources)) { ? `https://pro2.nabilekson.workers.dev/tv/${id}/${s}/${e}`
for (const item of res.primarySources) { : `https://pro2.nabilekson.workers.dev/movie/${id}`;
const streamUrl = item.url || item.originalUrl; const res = await fetchJson(url);
if (streamUrl) { if (res?.success && Array.isArray(res.primarySources)) {
allUrls.push({ for (const item of res.primarySources) {
url: streamUrl, const streamUrl = item.url || item.originalUrl;
server: `CineBros - ${item.name || item.quality || 'Server'}`, if (streamUrl) {
headers: item.headers || { allUrls.push({
Referer: 'https://pro2.nabilekson.workers.dev/', url: streamUrl,
Origin: 'https://pro2.nabilekson.workers.dev' server: `CineBros - ${item.name || item.quality || 'Server'}`,
} quality: item.quality || 'Auto',
}); type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
} headers: item.headers || {
} Referer: 'https://pro2.nabilekson.workers.dev/',
} Origin: 'https://pro2.nabilekson.workers.dev',
}, },
});
async () => { }
const url = isTv }
? `https://praxi.nabilekson.workers.dev/tv/${id}/${s}/${e}` }
: `https://praxi.nabilekson.workers.dev/movie/${id}`; },
const res = await fetchJson(url);
if (res?.success && Array.isArray(res.primarySources)) { async () => {
for (const item of res.primarySources) { const url = isTv
const streamUrl = item.url || item.originalUrl; ? `https://praxi.nabilekson.workers.dev/tv/${id}/${s}/${e}`
if (streamUrl) { : `https://praxi.nabilekson.workers.dev/movie/${id}`;
allUrls.push({ const res = await fetchJson(url);
url: streamUrl, if (res?.success && Array.isArray(res.primarySources)) {
server: `Praxi - ${item.name || item.providerName || 'Server'}`, for (const item of res.primarySources) {
headers: item.headers || { const streamUrl = item.url || item.originalUrl;
Referer: 'https://praxi.nabilekson.workers.dev/', if (streamUrl) {
Origin: 'https://praxi.nabilekson.workers.dev' allUrls.push({
} url: streamUrl,
}); server: `Praxi - ${item.name || item.providerName || 'Server'}`,
} quality: 'Auto',
} type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
} headers: item.headers || {
}, Referer: 'https://praxi.nabilekson.workers.dev/',
Origin: 'https://praxi.nabilekson.workers.dev',
async () => { },
const url = isTv });
? `https://freakyniki.elaxo.lol/?tmdb_id=${id}&season=${s}&episode=${e}` }
: `https://freakyniki.elaxo.lol/?tmdb_id=${id}`; }
const res = await fetchJson(url); }
if (Array.isArray(res?.streams)) { },
for (const item of res.streams) {
const streamUrl = item.url || item.raw_url; async () => {
if (streamUrl) { const url = isTv
allUrls.push({ ? `https://freakyniki.elaxo.lol/?tmdb_id=${id}&season=${s}&episode=${e}`
url: streamUrl, : `https://freakyniki.elaxo.lol/?tmdb_id=${id}`;
server: `FreakyNiki - ${item.server || item.provider || 'Server'}`, const res = await fetchJson(url);
headers: { if (Array.isArray(res?.streams)) {
Referer: 'https://freakyniki.elaxo.lol/', for (const item of res.streams) {
Origin: 'https://freakyniki.elaxo.lol' const streamUrl = item.url || item.raw_url;
} if (streamUrl) {
}); allUrls.push({
} url: streamUrl,
} server: `FreakyNiki - ${item.server || item.provider || 'Server'}`,
} quality: 'Auto',
} type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
]; headers: {
Referer: 'https://freakyniki.elaxo.lol/',
await Promise.allSettled(endpoints.map(fn => fn().catch(() => { }))); Origin: 'https://freakyniki.elaxo.lol',
},
if (!allUrls.length) return null; });
}
return { }
url: allUrls[0].url, }
headers: allUrls[0].headers, },
allUrls ];
};
await Promise.allSettled(endpoints.map(fn => fn().catch(() => { })));
if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} }

View File

@@ -1,30 +1,39 @@
import { fetchJson, resolveImdbId } from '../utils/helpers.js'; import { fetchJson, resolveImdbId, resolveTmdbKey } from '../utils/helpers.js';
export async function getStream({ id, s, e, tmdbApiKey, sdk }) { const BASE_URL = 'https://froststream.cloutteam.com';
export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'series' : 'movie'; const type = isTv ? 'series' : 'movie';
const imdb = await resolveImdbId(id, isTv, tmdbApiKey || sdk?.tmdbApiKey); const apiKey = resolveTmdbKey(args, sdk);
const imdb = await resolveImdbId(id, isTv, apiKey);
if (!imdb) return null; if (!imdb) return null;
const url = isTv const url = isTv
? `https://froststream.cloutteam.com/stream/series/${imdb}:${s}:${e}.json` ? `${BASE_URL}/stream/series/${imdb}:${s}:${e}.json`
: `https://froststream.cloutteam.com/stream/movie/${imdb}.json`; : `${BASE_URL}/stream/movie/${imdb}.json`;
const res = await fetchJson(url).catch(() => null); const res = await fetchJson(url).catch(() => null);
if (!res || !Array.isArray(res.streams) || !res.streams.length) return null; if (!res || !Array.isArray(res.streams) || !res.streams.length) return null;
const allUrls = res.streams.filter(st => st.url).map(st => ({ const allUrls = res.streams
url: st.url, .filter(st => st.url)
server: `Frost - ${st.name || 'Server'} ${st.title ? `- ${st.title}` : ''}`, .map(st => ({
headers: st.behaviorHints?.proxyHeaders?.request || undefined, url: st.url,
skipProxy: st.behaviorHints?.notWebReady === false server: `Frost - ${st.name || 'Server'}${st.title ? ` - ${st.title}` : ''}`,
})); quality: 'Auto',
type: st.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: st.behaviorHints?.proxyHeaders?.request || undefined,
skipProxy: st.behaviorHints?.notWebReady === false,
}));
if (!allUrls.length) return null; if (!allUrls.length) return null;
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,48 +1,96 @@
import { fetchText, USER_AGENT, getTmdbInfo } from '../utils/helpers.js'; import { fetchText, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
const ORIGIN = 'https://www3.fsonline.app'; const ORIGIN = 'https://www3.fsonline.app';
const AJAX_URL = `${ORIGIN}/wp-admin/admin-ajax.php`; const AJAX_URL = `${ORIGIN}/wp-admin/admin-ajax.php`;
const HEADERS = { 'User-Agent': USER_AGENT, 'Origin': ORIGIN, 'Referer': `${ORIGIN}/` }; const HEADERS = {
'User-Agent': USER_AGENT,
export async function getStream({ id, s, e, sdk }) { Origin: ORIGIN,
const tmdbApiKey = sdk?.tmdbApiKey || null; Referer: `${ORIGIN}/`,
if (!tmdbApiKey) return null; };
try {
const isTv = s != null && e != null; export async function getStream(args) {
const info = await getTmdbInfo(tmdbApiKey, id, isTv ? 'tv' : 'movie'); const { id, s, e, sdk } = args || {};
if (!info?.titles?.length) return null; const isTv = s != null && e != null;
const searchHtml = await fetchText(`${ORIGIN}/?s=${encodeURIComponent(info.titles[0] + (info.year ? ' ' + info.year : ''))}`, { headers: HEADERS }); const apiKey = resolveTmdbKey(args, sdk);
const typeFolder = isTv ? 'seriale' : 'film'; if (!apiKey) return null;
const linkMatch = searchHtml.match(new RegExp(`href=["'](https?://www3\\.fsonline\\.app/${typeFolder}/([^"'/]+)/)["']`, 'i'));
if (!linkMatch) return null; try {
const targetPageUrl = isTv ? `${ORIGIN}/episoade/${linkMatch[2].replace(/-\d{4}$/, '')}-sezonul-${s}-episodul-${e}/` : linkMatch[1]; const meta = await getTmdbMetadata(id, isTv, apiKey);
const pageHtml = await fetchText(targetPageUrl, { headers: HEADERS }); if (!meta?.titles?.length) return null;
const movieId = (pageHtml.match(/movie-id=['"]([^'"]+)['"]/) || pageHtml.match(/movie-id=([^ >]+)/))?.[1];
if (!movieId) return null; const query = meta.titles[0] + (meta.year ? ` ${meta.year}` : '');
const ajaxHtml = await fetchText(AJAX_URL, { method: 'POST', headers: { ...HEADERS, 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest', 'Referer': targetPageUrl }, body: `action=lazy_player&movieID=${movieId}` }); const searchHtml = await fetchText(`${ORIGIN}/?s=${encodeURIComponent(query)}`, { headers: HEADERS });
const results = []; const typeFolder = isTv ? 'seriale' : 'film';
let idx = 0; const linkMatch = searchHtml.match(new RegExp(`href=["'](https?://www3\\.fsonline\\.app/${typeFolder}/([^"'/]+)/)["']`, 'i'));
while ((idx = ajaxHtml.indexOf('data-vs="', idx)) !== -1) { if (!linkMatch) return null;
const embedStart = idx + 9;
const embedEnd = ajaxHtml.indexOf('"', embedStart); const targetPageUrl = isTv
const embedUrl = ajaxHtml.slice(embedStart, embedEnd); ? `${ORIGIN}/episoade/${linkMatch[2].replace(/-\d{4}$/, '')}-sezonul-${s}-episodul-${e}/`
const spanStart = ajaxHtml.indexOf('<span>', embedEnd); : linkMatch[1];
const spanEnd = ajaxHtml.indexOf('</span>', spanStart);
const serverLabel = ajaxHtml.slice(spanStart + 6, spanEnd).trim().toLowerCase(); const pageHtml = await fetchText(targetPageUrl, { headers: HEADERS });
if (serverLabel.includes('filesun')) { const movieId = (pageHtml.match(/movie-id=['"]([^'"]+)['"]/) || pageHtml.match(/movie-id=([^ >]+)/))?.[1];
try { if (!movieId) return null;
const rHtml = await fetchText(embedUrl, { headers: { 'Referer': ORIGIN, 'User-Agent': USER_AGENT } });
const m3u8Match = rHtml.match(/file:\s*["'](https?:\/\/[^"']+\.m3u8[^"']*)["']/) || rHtml.match(/["']?file["']?:\s*["'](https?:\/\/[^"']+)["']/); const ajaxHtml = await fetchText(AJAX_URL, {
if (m3u8Match) results.push({ url: m3u8Match[1].replace(/\\\//g, '/'), server: 'FSOnline - FileSuN', headers: { 'Referer': embedUrl, 'Origin': 'https://player.fsonline.app', 'User-Agent': USER_AGENT } }); method: 'POST',
} catch { } headers: {
} ...HEADERS,
idx = spanEnd; 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
} 'X-Requested-With': 'XMLHttpRequest',
return results.length ? { allUrls: results } : null; Referer: targetPageUrl,
} catch { return null; } },
} body: `action=lazy_player&movieID=${movieId}`,
});
export async function getSources(args) {
const res = await getStream(args); const allUrls = [];
return res?.allUrls ? [...new Set(res.allUrls.map(u => u.server))] : []; let idx = 0;
while ((idx = ajaxHtml.indexOf('data-vs="', idx)) !== -1) {
const embedStart = idx + 9;
const embedEnd = ajaxHtml.indexOf('"', embedStart);
const embedUrl = ajaxHtml.slice(embedStart, embedEnd);
const spanStart = ajaxHtml.indexOf('<span>', embedEnd);
const spanEnd = ajaxHtml.indexOf('</span>', spanStart);
const serverLabel = ajaxHtml.slice(spanStart + 6, spanEnd).trim().toLowerCase();
if (serverLabel.includes('filesun')) {
try {
const rHtml = await fetchText(embedUrl, {
headers: { Referer: ORIGIN, 'User-Agent': USER_AGENT },
});
const m3u8Match = rHtml.match(/file:\s*["'](https?:\/\/[^"']+\.m3u8[^"']*)["']/) || rHtml.match(/["']?file["']?:\s*["'](https?:\/\/[^"']+)["']/);
if (m3u8Match) {
const streamUrl = m3u8Match[1].replace(/\\\//g, '/');
allUrls.push({
url: streamUrl,
server: 'FSOnline - FileSuN',
quality: 'Auto',
type: 'hls',
headers: {
Referer: embedUrl,
Origin: 'https://player.fsonline.app',
'User-Agent': USER_AGENT,
},
});
}
} catch { }
}
idx = spanEnd;
}
if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch {
return null;
}
}
export async function getSources(args) {
const stream = await getStream(args);
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server))] : [];
} }

View File

@@ -1,13 +1,18 @@
import { fetchJson, resolveImdbId } from '../utils/helpers.js'; import { fetchJson, resolveImdbId, resolveTmdbKey } from '../utils/helpers.js';
export async function getStream({ id, s, e, tmdbApiKey, sdk }) { const BASE_URL = 'https://hdhub.thevolecitor.qzz.io';
export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'series' : 'movie'; const type = isTv ? 'series' : 'movie';
const imdb = await resolveImdbId(id, isTv, tmdbApiKey || sdk?.tmdbApiKey); const apiKey = resolveTmdbKey(args, sdk);
const imdb = await resolveImdbId(id, isTv, apiKey);
if (!imdb) return null; if (!imdb) return null;
const CONFIG = btoa(JSON.stringify({ "torbox": "unset", "qualities": "2160p,1080p,720p", "sort": "desc", "catalogs": "featured,popular" })); const config = btoa(JSON.stringify({ torbox: 'unset', qualities: '2160p,1080p,720p', sort: 'desc', catalogs: 'featured,popular' }));
const url = `https://hdhub.thevolecitor.qzz.io/${CONFIG}/stream/${type}/${imdb}${isTv ? `:${s}:${e}` : ""}.json`; const url = `${BASE_URL}/${config}/stream/${type}/${imdb}${isTv ? `:${s}:${e}` : ''}.json`;
const res = await fetchJson(url).catch(() => null); const res = await fetchJson(url).catch(() => null);
if (!res || !Array.isArray(res.streams) || !res.streams.length) return null; if (!res || !Array.isArray(res.streams) || !res.streams.length) return null;
@@ -24,13 +29,15 @@ export async function getStream({ id, s, e, tmdbApiKey, sdk }) {
const allUrls = validStreams.map(st => ({ const allUrls = validStreams.map(st => ({
url: st.url, url: st.url,
server: `HDHub - ${st.name || 'Server'}`, server: `HDHub - ${st.name || 'Server'}`,
quality: 'Auto',
type: st.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: st.behaviorHints?.proxyHeaders?.request || undefined, headers: st.behaviorHints?.proxyHeaders?.request || undefined,
skipProxy: st.behaviorHints?.notWebReady === false skipProxy: st.behaviorHints?.notWebReady === false,
})); }));
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,54 +1,61 @@
import { fetchJson, fetchText } from '../utils/helpers.js'; import { fetchJson, fetchText, getRandomHex } from '../utils/helpers.js';
const API = "https://enc-dec.app/api"; const API_BASE = 'https://enc-dec.app/api';
const BASE_URL = 'https://hexa.su';
const TMDB_PROXY_BASE = 'https://theemoviedb.hexa.su';
function getRandomHex(size = 32) { export async function getStream(args) {
const array = new Uint8Array(size); const { id, s, e } = args || {};
crypto.getRandomValues(array);
return Array.from(array).map(b => b.toString(16).padStart(2, '0')).join('');
}
export async function getStream({ id, s, e }) {
const isTv = s != null && e != null; const isTv = s != null && e != null;
const key = getRandomHex(32); const key = getRandomHex(32);
const headers = { const headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
"Referer": "https://hexa.su/", Referer: `${BASE_URL}/`,
"Accept": "text/plain", Accept: 'text/plain',
"X-Fingerprint-Lite": "e9136c41504646444", 'X-Fingerprint-Lite': 'e9136c41504646444',
"X-Api-Key": key 'X-Api-Key': key,
}; };
const encHexaRes = await fetchJson(`${API}/enc-hexa`); const encHexaRes = await fetchJson(`${API_BASE}/enc-hexa`);
if (!encHexaRes || encHexaRes.status !== 200) return null; if (!encHexaRes || encHexaRes.status !== 200) return null;
headers["X-Cap-Token"] = encHexaRes.result.token; headers['X-Cap-Token'] = encHexaRes.result.token;
const url = isTv const url = isTv
? `https://theemoviedb.hexa.su/api/tmdb/tv/${id}/season/${s}/episode/${e}/images` ? `${TMDB_PROXY_BASE}/api/tmdb/tv/${id}/season/${s}/episode/${e}/images`
: `https://theemoviedb.hexa.su/api/tmdb/movie/${id}/images`; : `${TMDB_PROXY_BASE}/api/tmdb/movie/${id}/images`;
const encrypted = await fetchText(url, { headers }); const encrypted = await fetchText(url, { headers });
if (!encrypted) return null; if (!encrypted) return null;
const decRes = await fetchJson(`${API}/dec-hexa`, { const decRes = await fetchJson(`${API_BASE}/dec-hexa`, {
method: "POST", method: 'POST',
headers: { "Content-Type": "application/json" }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: encrypted, key }) body: JSON.stringify({ text: encrypted, key }),
}); });
if (!decRes || decRes.status !== 200 || !decRes.result) return null; if (!decRes || decRes.status !== 200 || !decRes.result) return null;
const data = decRes.result; const data = decRes.result;
const streamUrl = data.url || data.file || (Array.isArray(data.sources) ? data.sources[0]?.url : null); const streamUrl = data.url || data.file || (Array.isArray(data.sources) ? data.sources[0]?.url : null);
if (!streamUrl) return null; if (!streamUrl) return null;
const streamHeaders = {
Referer: `${BASE_URL}/`,
Origin: BASE_URL,
};
const allUrls = [{
url: streamUrl,
server: 'Hexa',
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: streamHeaders,
}];
return { return {
url: streamUrl, url: streamUrl,
headers: { headers: streamHeaders,
Referer: "https://hexa.su/", allUrls,
Origin: "https://hexa.su"
}
}; };
} }

View File

@@ -1,13 +1,18 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://hyper.stravo.site';
const DEFAULT_ORIGIN = 'https://mzfi.me';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const path = isTv const path = isTv
? `/local/stream/series/tmdb:${id}:${s}:${e}.json` ? `/local/stream/series/tmdb:${id}:${s}:${e}.json`
: `/local/stream/movie/tmdb:${id}.json`; : `/local/stream/movie/tmdb:${id}.json`;
const url = `https://hyper.stravo.site${path}`; const url = `${BASE_URL}${path}`;
const res = await fetchJson(url); const res = await fetchJson(url).catch(() => null);
if (!res || !Array.isArray(res.streams)) return null; if (!res || !Array.isArray(res.streams)) return null;
const validStreams = res.streams.filter(item => { const validStreams = res.streams.filter(item => {
@@ -21,16 +26,18 @@ export async function getStream({ id, s, e }) {
const allUrls = validStreams.map(item => ({ const allUrls = validStreams.map(item => ({
url: item.url, url: item.url,
server: `Hyper - ${item.title?.replace(/[^\x20-\x7E]+/g, '').trim() || 'Server'}`, server: `Hyper - ${item.title?.replace(/[^\x20-\x7E]+/g, '').trim() || 'Server'}`,
quality: 'Auto',
type: item.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: item.behaviorHints?.proxyHeaders?.request || { headers: item.behaviorHints?.proxyHeaders?.request || {
Referer: 'https://mzfi.me/', Referer: `${DEFAULT_ORIGIN}/`,
Accept: '*/*' Accept: '*/*',
}, },
skipProxy: item.behaviorHints?.notWebReady === false skipProxy: item.behaviorHints?.notWebReady === false,
})); }));
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,24 +1,24 @@
import { fetchJson, USER_AGENT } from '../utils/helpers.js'; import { fetchJson, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
const BASE = "https://kaa.lt"; const BASE_URL = 'https://kaa.lt';
const HLS_BASE = "https://hls.krussdomi.com/manifest"; const HLS_BASE = 'https://hls.krussdomi.com/manifest';
const HEADERS = { "User-Agent": USER_AGENT, Accept: "application/json" }; const HEADERS = { 'User-Agent': USER_AGENT, Accept: 'application/json' };
async function kaaSearch(query) { async function kaaSearch(query) {
const res = await fetchJson(`${BASE}/api/fsearch`, { const res = await fetchJson(`${BASE_URL}/api/fsearch`, {
method: "POST", method: 'POST',
headers: { ...HEADERS, "Content-Type": "application/json" }, headers: { ...HEADERS, 'Content-Type': 'application/json' },
body: JSON.stringify({ page: 1, query }), body: JSON.stringify({ page: 1, query }),
}).catch(() => null); }).catch(() => null);
return Array.isArray(res?.result) ? res.result : []; return Array.isArray(res?.result) ? res.result : [];
} }
async function kaaShowInfo(showSlug) { async function kaaShowInfo(showSlug) {
return fetchJson(`${BASE}/api/show/${showSlug}`, { headers: HEADERS }).catch(() => null); return fetchJson(`${BASE_URL}/api/show/${showSlug}`, { headers: HEADERS }).catch(() => null);
} }
async function kaaEpisodePage(showSlug, ep) { async function kaaEpisodePage(showSlug, ep) {
return fetchJson(`${BASE}/api/show/${showSlug}/episodes?ep=${ep}&lang=ja-JP`, { headers: HEADERS }).catch(() => null); return fetchJson(`${BASE_URL}/api/show/${showSlug}/episodes?ep=${ep}&lang=ja-JP`, { headers: HEADERS }).catch(() => null);
} }
async function kaaAllEpisodes(showSlug) { async function kaaAllEpisodes(showSlug) {
@@ -29,7 +29,7 @@ async function kaaAllEpisodes(showSlug) {
if (pages.length > 1) { if (pages.length > 1) {
const rest = await Promise.all( const rest = await Promise.all(
pages.slice(1).map(async (pg) => { pages.slice(1).map(async pg => {
const startEp = pg.eps?.[0]; const startEp = pg.eps?.[0];
if (!startEp) return []; if (!startEp) return [];
const d = await kaaEpisodePage(showSlug, startEp); const d = await kaaEpisodePage(showSlug, startEp);
@@ -43,35 +43,18 @@ async function kaaAllEpisodes(showSlug) {
} }
async function kaaEpisodeServers(showSlug, fullEpSlug) { async function kaaEpisodeServers(showSlug, fullEpSlug) {
return fetchJson(`${BASE}/api/show/${showSlug}/episode/${fullEpSlug}`, { headers: HEADERS }).catch(() => null); return fetchJson(`${BASE_URL}/api/show/${showSlug}/episode/${fullEpSlug}`, { headers: HEADERS }).catch(() => null);
} }
export async function getStream({ id, s, e, tmdbApiKey, sdk }) { export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
const apiKey = resolveTmdbKey(args, sdk);
const epNum = e ? Number(e) : 1;
try { try {
const apiKey = tmdbApiKey || sdk?.tmdbApiKey || process.env.TMDB_API_KEY || '45dbdd5e714da212424bda0336167447'; const meta = await getTmdbMetadata(id, isTv, apiKey);
const isTv = !!s; const titles = meta?.titles || [];
const mediaType = isTv ? 'tv' : 'movie';
const epNum = e ? Number(e) : 1;
let titles = [];
try {
const tmdbRes = await fetchJson(`https://api.themoviedb.org/3/${mediaType}/${id}?api_key=${apiKey}&append_to_response=alternative_titles`);
if (tmdbRes) {
const primary = tmdbRes.title || tmdbRes.name;
const original = tmdbRes.original_title || tmdbRes.original_name;
if (primary) titles.push(primary);
if (original && !titles.includes(original)) titles.push(original);
const alts = tmdbRes.alternative_titles?.titles || tmdbRes.alternative_titles?.results || [];
for (const alt of alts) {
const candidate = alt.title || alt.name;
if (candidate && !titles.includes(candidate)) {
titles.push(candidate);
}
}
}
} catch { }
if (!titles.length) return null; if (!titles.length) return null;
let showSlug = null; let showSlug = null;
@@ -88,12 +71,12 @@ export async function getStream({ id, s, e, tmdbApiKey, sdk }) {
const showInfo = await kaaShowInfo(showSlug); const showInfo = await kaaShowInfo(showSlug);
let fullEpSlug = null; let fullEpSlug = null;
if (showInfo?.type === "movie") { if (showInfo?.type === 'movie') {
const m = (showInfo.watch_uri || "").match(/\/(ep-(\d+)-([a-f0-9]+))$/i); const m = (showInfo.watch_uri || '').match(/\/(ep-(\d+)-([a-f0-9]+))$/i);
if (m) fullEpSlug = m[1]; if (m) fullEpSlug = m[1];
} else { } else {
const episodes = await kaaAllEpisodes(showSlug); const episodes = await kaaAllEpisodes(showSlug);
const epItem = episodes.find((item) => item.episode_number === epNum); const epItem = episodes.find(item => item.episode_number === epNum);
if (epItem) fullEpSlug = `ep-${epItem.episode_number}-${epItem.slug}`; if (epItem) fullEpSlug = `ep-${epItem.episode_number}-${epItem.slug}`;
} }
@@ -102,24 +85,34 @@ export async function getStream({ id, s, e, tmdbApiKey, sdk }) {
const episodeData = await kaaEpisodeServers(showSlug, fullEpSlug); const episodeData = await kaaEpisodeServers(showSlug, fullEpSlug);
const servers = Array.isArray(episodeData?.servers) ? episodeData.servers : []; const servers = Array.isArray(episodeData?.servers) ? episodeData.servers : [];
const urls = []; const allUrls = [];
for (const srv of servers) { for (const srv of servers) {
if (!srv.src) continue; if (!srv.src) continue;
const m = srv.src.match(/[?&]id=([^&]+)/); const m = srv.src.match(/[?&]id=([^&]+)/);
if (m) { if (m) {
urls.push({ allUrls.push({
url: `${HLS_BASE}/${m[1]}/master.m3u8`, url: `${HLS_BASE}/${m[1]}/master.m3u8`,
server: `KickAssAnime (${srv.name || 'Server'})`, server: `KickAssAnime (${srv.name || 'Server'})`,
quality: 'Auto',
type: 'hls',
headers: HEADERS,
}); });
} }
} }
return urls.length ? { allUrls: urls } : null; if (!allUrls.length) return null;
} catch (err) {
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch {
return null; return null;
} }
} }
export async function getSources() { export async function getSources(args) {
return ['KickAssAnime']; const stream = await getStream(args);
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server))] : ['KickAssAnime'];
} }

View File

@@ -1,60 +1,115 @@
import { fetchJson, USER_AGENT, getTmdbInfo } from '../utils/helpers.js'; import { cleanTitle, fetchJson, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
export const SKIP_VERIFY = true; const ENC_API = 'https://enc-dec.app/api';
export const MULTI_URL = false; const BASE_URL = 'https://kisskh.do';
const ENC_API = "https://enc-dec.app/api"; const HEADERS = { 'User-Agent': USER_AGENT, Accept: 'application/json' };
const BASE = "https://kisskh.do";
const HEADERS = { 'User-Agent': USER_AGENT, Accept: 'application/json' }; async function encKey(episodeId, type) {
try {
function cleanTitle(t) { return t ? t.toLowerCase().replace(/\(\d{4}\)/g, '').replace(/[^a-z0-9]/g, '') : ''; } const data = await fetchJson(`${ENC_API}/enc-kisskh?text=${episodeId}&type=${type}`, { signal: AbortSignal.timeout(6000) });
return data?.status === 200 ? data.result : null;
async function encKey(episodeId, type) { } catch {
try { return null;
const data = await fetchJson(`${ENC_API}/enc-kisskh?text=${episodeId}&type=${type}`, { signal: AbortSignal.timeout(6000) }); }
return data?.status === 200 ? data.result : null; }
} catch { return null; }
} export async function getStream(args) {
const { id, s, e, sdk } = args || {};
export async function getStream({ id, s, e }) { const isTv = s != null && e != null;
try { const apiKey = resolveTmdbKey(args, sdk);
const info = await getTmdbInfo(id, s ? 'tv' : 'movie', s);
if (!info) return null; try {
let drama = null, bestScore = -1; const meta = await getTmdbMetadata(id, isTv, apiKey);
for (const title of (info.titles.length > 1 ? [...info.titles].reverse() : info.titles)) { if (!meta?.titles?.length) return null;
const results = await fetchJson(`${BASE}/api/DramaList/Search?q=${encodeURIComponent(title)}`, { headers: HEADERS, signal: AbortSignal.timeout(6000) }).catch(() => []);
const targetClean = cleanTitle(title); let drama = null;
for (const item of results) { let bestScore = -1;
const parts = (item.title || '').split(/\s*-\s*/).map(cleanTitle); const searchTitles = meta.titles.length > 1 ? [...meta.titles].reverse() : meta.titles;
let score = 0;
if (parts.some(p => p === targetClean)) score += 5; for (const title of searchTitles) {
else if (parts.some(p => p.includes(targetClean) || targetClean.includes(p))) score += 3; const results = await fetchJson(`${BASE_URL}/api/DramaList/Search?q=${encodeURIComponent(title)}`, {
else continue; headers: HEADERS,
if (score > bestScore) { bestScore = score; drama = item; } signal: AbortSignal.timeout(6000),
} }).catch(() => []);
if (drama && bestScore >= 5) break;
} const targetClean = cleanTitle(title);
if (!drama) return null; for (const item of results) {
const detail = await fetchJson(`${BASE}/api/DramaList/Drama/${drama.id}`, { headers: HEADERS, signal: AbortSignal.timeout(8000) }); const parts = (item.title || '').split(/\s*-\s*/).map(cleanTitle);
const episodeId = detail?.episodes?.find(ep => Math.floor(ep.number) === Number(e || 1))?.id; let score = 0;
if (!episodeId) return null; if (parts.some(p => p === targetClean)) score += 5;
const vidKey = await encKey(episodeId, 'vid'); else if (parts.some(p => p.includes(targetClean) || targetClean.includes(p))) score += 3;
if (!vidKey) return null; else continue;
const videoData = await fetchJson(`${BASE}/api/DramaList/Episode/${episodeId}.png?err=false&ts=&time=&kkey=${vidKey}`, { headers: HEADERS, signal: AbortSignal.timeout(10000) }); if (score > bestScore) {
if (!videoData?.Video) return null; bestScore = score;
let subtitles = []; drama = item;
const subKey = await encKey(episodeId, 'sub'); }
if (subKey) { }
try { if (drama && bestScore >= 5) break;
const subList = await fetchJson(`${BASE}/api/Sub/${episodeId}?kkey=${subKey}`, { headers: HEADERS, signal: AbortSignal.timeout(8000) }); }
if (Array.isArray(subList)) subtitles = subList.map(sub => ({ url: sub.src, label: sub.label, lang: sub.land, default: !!sub.default }));
} catch { } if (!drama) return null;
}
return { allUrls: [{ url: videoData.Video, type: videoData.Video.includes('.m3u8') ? 'hls' : 'mp4', audio: 'sub', server: 'KissKH', skipProxy: false, subtitles }] }; const detail = await fetchJson(`${BASE_URL}/api/DramaList/Drama/${drama.id}`, {
} catch { return null; } headers: HEADERS,
} signal: AbortSignal.timeout(8000),
});
export async function getSources(args) {
const stream = await getStream(args); const episodeId = detail?.episodes?.find(ep => Math.floor(ep.number) === Number(e || 1))?.id;
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server))] : []; if (!episodeId) return null;
const vidKey = await encKey(episodeId, 'vid');
if (!vidKey) return null;
const videoData = await fetchJson(`${BASE_URL}/api/DramaList/Episode/${episodeId}.png?err=false&ts=&time=&kkey=${vidKey}`, {
headers: HEADERS,
signal: AbortSignal.timeout(10000),
});
if (!videoData?.Video) return null;
let subtitles = [];
const subKey = await encKey(episodeId, 'sub');
if (subKey) {
try {
const subList = await fetchJson(`${BASE_URL}/api/Sub/${episodeId}?kkey=${subKey}`, {
headers: HEADERS,
signal: AbortSignal.timeout(8000),
});
if (Array.isArray(subList)) {
subtitles = subList.map(sub => ({
url: sub.src,
label: sub.label,
lang: sub.land,
default: Boolean(sub.default),
}));
}
} catch { }
}
const streamUrl = videoData.Video;
const allUrls = [{
url: streamUrl,
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
audio: 'sub',
server: 'KissKH',
quality: 'Auto',
headers: HEADERS,
skipProxy: false,
subtitles,
}];
return {
url: streamUrl,
headers: HEADERS,
allUrls,
subtitles,
};
} catch {
return null;
}
}
export async function getSources(args) {
const stream = await getStream(args);
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server))] : ['KissKH'];
} }

View File

@@ -1,25 +1,25 @@
import { getTmdbInfo } from '../utils/helpers.js'; import { fetchJson, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
const BASE_URL = 'https://lmscript.xyz';
const REFERER = 'https://lookmovie2.to/';
export async function getStream(args) { export async function getStream(args) {
const { id, s, e, tmdbApiKey, sdk } = args; const { id, s, e, sdk } = args || {};
const type = (s != null && e != null) ? 'tv' : 'movie'; const isTv = s != null && e != null;
const apiKey = tmdbApiKey || sdk?.tmdbApiKey || process.env.TMDB_API_KEY || '45dbdd5e714da212424bda0336167447'; if (isTv) return null;
const apiKey = resolveTmdbKey(args, sdk);
try { try {
if (type === 'tv') { const meta = await getTmdbMetadata(id, isTv, apiKey);
return null; const titles = meta?.titles || [];
}
const tmdbInfo = await getTmdbInfo(apiKey, id, type, s);
const titles = tmdbInfo?.titles || [];
if (!titles.length) return null; if (!titles.length) return null;
let movie = null; let movie = null;
for (const title of titles) { for (const title of titles) {
const url = `https://lmscript.xyz/v1/movies?filters[q]=${encodeURIComponent(title)}&expand=streams`; const url = `${BASE_URL}/v1/movies?filters[q]=${encodeURIComponent(title)}&expand=streams`;
const response = await fetch(url); const data = await fetchJson(url).catch(() => null);
if (!response.ok) continue; if (!data) continue;
const data = await response.json();
const found = data.items?.find(item => { const found = data.items?.find(item => {
const tmdbPrefixMatch = `${item.tmdb_prefix}` === `${id}`; const tmdbPrefixMatch = `${item.tmdb_prefix}` === `${id}`;
@@ -37,33 +37,35 @@ export async function getStream(args) {
if (!movie) return null; if (!movie) return null;
const streams = movie.streams || {}; const streams = movie.streams || {};
const SOURCE_ORDER = ["1080p", "720p", "480p", "360p"]; const sourceOrder = ['1080p', '720p', '480p', '360p'];
const sortedStreams = Object.keys(streams).sort((a, b) => { const sortedStreams = Object.keys(streams).sort((a, b) => {
const indexA = SOURCE_ORDER.indexOf(a); const idxA = sourceOrder.indexOf(a);
const indexB = SOURCE_ORDER.indexOf(b); const idxB = sourceOrder.indexOf(b);
return (indexA === -1 ? 99 : indexA) - (indexB === -1 ? 99 : indexB); if (idxA !== -1 && idxB !== -1) return idxA - idxB;
if (idxA !== -1) return -1;
if (idxB !== -1) return 1;
return 0;
}); });
if (!sortedStreams.length) return null; const headers = {
Referer: REFERER,
'User-Agent': USER_AGENT,
};
const allUrls = sortedStreams.map(quality => { const allUrls = sortedStreams.map(res => ({
const streamUrl = streams[quality]; url: streams[res],
return { quality: res,
url: streamUrl, server: `LookMovie - ${res}`,
quality, type: streams[res].includes('.m3u8') ? 'hls' : 'mp4',
server: `LMScript - ${quality}`, headers,
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4', }));
headers: {
Referer: 'https://lookmovie2.to/', if (!allUrls.length) return null;
Origin: 'https://lookmovie2.to'
}
};
});
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} catch { } catch {
return null; return null;

View File

@@ -1,80 +1,81 @@
import { USER_AGENT, fetchText, fetchJson } from '../utils/helpers.js'; import { USER_AGENT, fetchText, fetchJson } from '../utils/helpers.js';
const TMDB_BASE = 'https://api.themoviedb.org/3'; const TMDB_BASE = 'https://api.themoviedb.org/3';
const LM_DOMAINS = ['https://www.lookmovie2.to', 'https://lookmovie2.to', 'https://lookmovie.foundation']; const LM_DOMAINS = ['https://www.lookmovie2.to', 'https://lookmovie2.to', 'https://lookmovie.foundation'];
const HEADERS_BASE = { 'User-Agent': USER_AGENT, 'Accept-Language': 'en-US,en;q=0.9' };
const HEADERS_BASE = { 'User-Agent': USER_AGENT, 'Accept-Language': 'en-US,en;q=0.9' };
async function searchLookMovie(type, title, year, clientIP) {
for (const base of LM_DOMAINS) { async function searchLookMovie(type, title, year, clientIP) {
try { for (const base of LM_DOMAINS) {
const headers = { ...HEADERS_BASE, 'Accept': 'application/json', 'Referer': `${base}/`, 'X-Requested-With': 'XMLHttpRequest', ...(clientIP && { 'X-Forwarded-For': clientIP }) }; try {
const data = await fetchJson(`${base}/api/v1/${type}/do-search/?q=${encodeURIComponent(title)}`, { headers, signal: AbortSignal.timeout(4000) }); const headers = { ...HEADERS_BASE, 'Accept': 'application/json', 'Referer': `${base}/`, 'X-Requested-With': 'XMLHttpRequest', ...(clientIP && { 'X-Forwarded-For': clientIP }) };
const results = data?.result; const data = await fetchJson(`${base}/api/v1/${type}/do-search/?q=${encodeURIComponent(title)}`, { headers, signal: AbortSignal.timeout(4000) });
if (results?.length) { const results = data?.result;
const match = results.find(r => String(r.year) === String(year)) ?? results.find(r => r.title?.toLowerCase() === title.toLowerCase()) ?? results[0]; if (results?.length) {
if (match) return { match, base }; const match = results.find(r => String(r.year) === String(year)) ?? results.find(r => r.title?.toLowerCase() === title.toLowerCase()) ?? results[0];
} if (match) return { match, base };
} catch { } }
} } catch { }
return null; }
} return null;
}
const STORAGE_RE = /window\[['"](?:movie|show)_storage['"]\]\s*=\s*\{([^}]+)\}/s;
const ID_MOVIE_RE = /['"]?(?:id_movie|movieId)['"]?\s*[:=]\s*['"]?(\d+)['"]?/i; const STORAGE_RE = /window\[['"](?:movie|show)_storage['"]\]\s*=\s*\{([^}]+)\}/s;
const SEASONS_RE = /seasons\s*:\s*(\[[\s\S]+?\])\s*[,}]/; const ID_MOVIE_RE = /['"]?(?:id_movie|movieId)['"]?\s*[:=]\s*['"]?(\d+)['"]?/i;
const SEASONS_RE = /seasons\s*:\s*(\[[\s\S]+?\])\s*[,}]/;
function getEpisodeIdFast(html, s, e) {
const sMatch = html.match(STORAGE_RE); function getEpisodeIdFast(html, s, e) {
if (sMatch) { const sMatch = html.match(STORAGE_RE);
const block = sMatch[1], sm = block.match(SEASONS_RE); if (sMatch) {
if (sm) { const block = sMatch[1], sm = block.match(SEASONS_RE);
try { if (sm) {
const seasons = JSON.parse(sm[1]); try {
const season = seasons.find(x => String(x?.season ?? x?.meta?.season) === String(s)); const seasons = JSON.parse(sm[1]);
if (season) { const season = seasons.find(x => String(x?.season ?? x?.meta?.season) === String(s));
const ep = Array.isArray(season.episodes) ? season.episodes.find(x => String(x.episode) === String(e)) : (season.episodes?.[String(e)] || Object.values(season.episodes || {}).find(x => String(x.episode) === String(e))); if (season) {
if (ep) return String(ep.id_episode ?? ep.id); const ep = Array.isArray(season.episodes) ? season.episodes.find(x => String(x.episode) === String(e)) : (season.episodes?.[String(e)] || Object.values(season.episodes || {}).find(x => String(x.episode) === String(e)));
} if (ep) return String(ep.id_episode ?? ep.id);
} catch { } }
} } catch { }
} }
const parts = html.split(/id_episode['"]?\s*[:=]\s*['"]?(\d+)['"]?/i); }
for (let i = 1; i < parts.length; i += 2) { const parts = html.split(/id_episode['"]?\s*[:=]\s*['"]?(\d+)['"]?/i);
const context = parts[i - 1].slice(-300) + parts[i + 1].slice(0, 300); for (let i = 1; i < parts.length; i += 2) {
if (context.match(new RegExp(`['"]?episode['"]?\\s*[:=]\\s*['"]?${e}['"]?`, 'i')) && context.match(new RegExp(`['"]?season['"]?\\s*[:=]\\s*['"]?${s}['"]?`, 'i'))) return parts[i]; const context = parts[i - 1].slice(-300) + parts[i + 1].slice(0, 300);
} if (context.match(new RegExp(`['"]?episode['"]?\\s*[:=]\\s*['"]?${e}['"]?`, 'i')) && context.match(new RegExp(`['"]?season['"]?\\s*[:=]\\s*['"]?${s}['"]?`, 'i'))) return parts[i];
const am = html.match(new RegExp(`data-season=["']${s}["'][^>]*?data-episode=["']${e}["'][^>]*?data-id=["'](\\d+)["']`, 'i')) || html.match(new RegExp(`data-episode=["']${e}["'][^>]*?data-season=["']${s}["'][^>]*?data-id=["'](\\d+)["']`, 'i')); }
return am ? am[1] : null; const am = html.match(new RegExp(`data-season=["']${s}["'][^>]*?data-episode=["']${e}["'][^>]*?data-id=["'](\\d+)["']`, 'i')) || html.match(new RegExp(`data-episode=["']${e}["'][^>]*?data-season=["']${s}["'][^>]*?data-id=["'](\\d+)["']`, 'i'));
} return am ? am[1] : null;
}
export async function getStream({ id, s, e, sdk, clientIP }) {
const tmdbApiKey = sdk?.tmdbApiKey || null; export async function getStream({ id, s, e, sdk, clientIP }) {
if (!tmdbApiKey) return null; const tmdbApiKey = sdk?.tmdbApiKey || null;
try { if (!tmdbApiKey) return null;
const tmdbKey = tmdbApiKey; try {
if (!tmdbKey) return null; const tmdbKey = tmdbApiKey;
const isTV = s != null && e != null; if (!tmdbKey) return null;
const typeStr = isTV ? 'shows' : 'movies'; const isTV = s != null && e != null;
const tmdbData = await fetchJson(`${TMDB_BASE}/${isTV ? 'tv' : 'movie'}/${id}?api_key=${tmdbKey}`, { signal: AbortSignal.timeout(3000) }); const typeStr = isTV ? 'shows' : 'movies';
const title = tmdbData?.title || tmdbData?.name; const tmdbData = await fetchJson(`${TMDB_BASE}/${isTV ? 'tv' : 'movie'}/${id}?api_key=${tmdbKey}`, { signal: AbortSignal.timeout(3000) });
const year = (tmdbData?.first_air_date || tmdbData?.release_date || '').slice(0, 4); const title = tmdbData?.title || tmdbData?.name;
if (!title) return null; const year = (tmdbData?.first_air_date || tmdbData?.release_date || '').slice(0, 4);
const searchRes = await searchLookMovie(typeStr, title, year, clientIP); if (!title) return null;
if (!searchRes?.match?.slug) return null; const searchRes = await searchLookMovie(typeStr, title, year, clientIP);
const { match, base } = searchRes; if (!searchRes?.match?.slug) return null;
const headers = { ...HEADERS_BASE, 'Accept': 'text/html', 'Referer': `${base}/`, ...(clientIP && { 'X-Forwarded-For': clientIP }) }; const { match, base } = searchRes;
const html = await fetchText(`${base}/${typeStr}/play/${match.slug}`, { headers, signal: AbortSignal.timeout(8000) }); const headers = { ...HEADERS_BASE, 'Accept': 'text/html', 'Referer': `${base}/`, ...(clientIP && { 'X-Forwarded-For': clientIP }) };
const storageMatch = html.match(STORAGE_RE); const html = await fetchText(`${base}/${typeStr}/play/${match.slug}`, { headers, signal: AbortSignal.timeout(8000) });
if (!storageMatch) return null; const storageMatch = html.match(STORAGE_RE);
const hashMatch = storageMatch[1].match(/hash\s*:\s*['"]([^'"]+)['"]/); if (!storageMatch) return null;
const expiresMatch = storageMatch[1].match(/expires\s*:\s*(\d+)/); const hashMatch = storageMatch[1].match(/hash\s*:\s*['"]([^'"]+)['"]/);
if (!hashMatch || !expiresMatch) return null; const expiresMatch = storageMatch[1].match(/expires\s*:\s*(\d+)/);
const streamId = isTV ? getEpisodeIdFast(html, s, e) : (match.id_movie || match.id || html.match(ID_MOVIE_RE)?.[1]); if (!hashMatch || !expiresMatch) return null;
if (!streamId) return null; const streamId = isTV ? getEpisodeIdFast(html, s, e) : (match.id_movie || match.id || html.match(ID_MOVIE_RE)?.[1]);
const accessHeaders = { ...HEADERS_BASE, 'Accept': 'application/json', 'Referer': `${base}/`, 'X-Requested-With': 'XMLHttpRequest', ...(clientIP && { 'X-Forwarded-For': clientIP }) }; if (!streamId) return null;
const data = await fetchJson(`${base}/api/v1/security/${isTV ? 'episode' : 'movie'}-access?id_${isTV ? 'episode' : 'movie'}=${streamId}&hash=${hashMatch[1]}&expires=${expiresMatch[1]}`, { headers: accessHeaders, signal: AbortSignal.timeout(8000) }); const accessHeaders = { ...HEADERS_BASE, 'Accept': 'application/json', 'Referer': `${base}/`, 'X-Requested-With': 'XMLHttpRequest', ...(clientIP && { 'X-Forwarded-For': clientIP }) };
const streams = data?.streams ?? data?.result?.streams ?? data?.data?.streams ?? data; const data = await fetchJson(`${base}/api/v1/security/${isTV ? 'episode' : 'movie'}-access?id_${isTV ? 'episode' : 'movie'}=${streamId}&hash=${hashMatch[1]}&expires=${expiresMatch[1]}`, { headers: accessHeaders, signal: AbortSignal.timeout(8000) });
const allUrls = Object.entries(streams || {}).filter(([, v]) => typeof v === 'string' && v.includes('.m3u8')).map(([quality, url]) => ({ url, quality })); const streams = data?.streams ?? data?.result?.streams ?? data?.data?.streams ?? data;
return allUrls.length ? { allUrls } : null; const allUrls = Object.entries(streams || {}).filter(([, v]) => typeof v === 'string' && v.includes('.m3u8')).map(([quality, url]) => ({ url, quality }));
} catch { return null; } return allUrls.length ? { allUrls } : null;
} catch { return null; }
} }

View File

@@ -1,125 +1,75 @@
import { getUA } from "../utils/helpers.js"; import { getTmdbMetadata, getUA, resolveTmdbKey } from '../utils/helpers.js';
const API_BASE = "https://api.movenerds.space/api"; const BASE_URL = 'https://movenerds.space';
const API_BASE = 'https://api.movenerds.space/api';
function getHeaders() {
return {
"User-Agent": getUA(),
Accept: "application/json",
Referer: "https://movenerds.space/",
Origin: "https://movenerds.space",
};
}
function resolveApiKey(args) {
return (
args?.tmdbApiKey ||
args?.sdk?.tmdbApiKey ||
process.env.TMDB_API_KEY ||
null
);
}
async function getMeta(id, isTv, apiKey) {
if (!apiKey) return null;
const type = isTv ? "tv" : "movie";
try {
const res = await fetch(
`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`,
{ signal: AbortSignal.timeout(5000) }
);
if (!res.ok) return null;
const data = await res.json();
const title = isTv ? data.name : data.title;
const date = isTv ? data.first_air_date : data.release_date;
const year = date ? parseInt(date.slice(0, 4), 10) : null;
return { title, year };
} catch {
return null;
}
}
function mapSource(source) { function mapSource(source) {
if (!source || !source.url) return null; if (!source || !source.url) return null;
if (source.type !== "hls" && source.type !== "mp4") return null; if (source.type !== 'hls' && source.type !== 'mp4') return null;
if (!/^https?:\/\//.test(source.url)) return null; if (!/^https?:\/\//.test(source.url)) return null;
return { return {
url: source.url, url: source.url,
headers: { headers: {
"User-Agent": source.headers?.["User-Agent"] || getUA(), 'User-Agent': source.headers?.['User-Agent'] || getUA(),
Referer: source.headers?.Referer || "https://movenerds.space/", Referer: source.headers?.Referer || `${BASE_URL}/`,
Origin: source.headers?.Origin || "https://movenerds.space", Origin: source.headers?.Origin || BASE_URL,
}, },
server: source.name || source.providerName || "MoverNerds", server: source.name || source.providerName || 'MoverNerds',
quality: source.quality || "1080p", quality: source.quality || '1080p',
type: source.type, type: source.type,
skipProxy: true, skipProxy: true,
}; };
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s = null, e = null } = args; const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const apiKey = resolveTmdbKey(args, sdk);
const apiKey = resolveApiKey(args); const meta = await getTmdbMetadata(id, isTv, apiKey);
const meta = await getMeta(id, isTv, apiKey); if (!meta?.title) return null;
if (!meta?.title) {
if (process.env.DEBUG_CAUSE) {
console.error(
`[movenerds] Could not resolve title for ${isTv ? "tv" : "movie"} ${id} ` +
`(tmdbApiKey ${apiKey ? "present" : "MISSING"})`
);
}
return null;
}
const params = new URLSearchParams({ const params = new URLSearchParams({
tmdbId: String(id), tmdbId: String(id),
type: isTv ? "tv" : "movie", type: isTv ? 'tv' : 'movie',
title: meta.title, title: meta.title,
}); });
if (meta.year) params.set("year", String(meta.year)); if (meta.year) params.set('year', String(meta.year));
if (isTv) { if (isTv) {
params.set("season", String(s)); params.set('season', String(s));
params.set("episode", String(e)); params.set('episode', String(e));
params.set("language", "en"); params.set('language', 'en');
} }
const url = `${API_BASE}/stream?${params.toString()}`; const url = `${API_BASE}/stream?${params.toString()}`;
const headers = {
'User-Agent': getUA(),
Accept: 'application/json',
Referer: `${BASE_URL}/`,
Origin: BASE_URL,
};
try { try {
const res = await fetch(url, { const res = await fetch(url, {
headers: getHeaders(), headers,
signal: AbortSignal.timeout(20000), signal: AbortSignal.timeout(20000),
}); });
if (!res.ok) return null;
if (!res.ok) {
if (process.env.DEBUG_CAUSE) {
console.error(`[movenerds] HTTP ${res.status} for ${url}`);
}
return null;
}
const data = await res.json(); const data = await res.json();
const primary = Array.isArray(data?.primarySources) ? data.primarySources : []; const primary = Array.isArray(data?.primarySources) ? data.primarySources : [];
if (!primary.length) { if (!primary.length) return null;
if (process.env.DEBUG_CAUSE) {
console.error(`[movenerds] No primarySources in response for ${url}`);
}
return null;
}
const allUrls = primary.map(mapSource).filter(Boolean); const allUrls = primary.map(mapSource).filter(Boolean);
if (!allUrls.length) return null; if (!allUrls.length) return null;
return { allUrls }; return {
} catch (err) { url: allUrls[0].url,
if (process.env.DEBUG_CAUSE) { headers: allUrls[0].headers,
console.error(`[movenerds] fetch error for ${url}:`, err.message); allUrls,
if (err.cause) console.error(" cause:", err.cause.code, err.cause.message); };
} } catch {
return null; return null;
} }
} }

View File

@@ -1,10 +1,10 @@
import { fetchJson, fetchText, getTmdbInfo } from '../utils/helpers.js'; import { fetchJson, fetchText, getTmdbMetadata, resolveTmdbKey } from '../utils/helpers.js';
const K = [ const K = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
]; ];
const MAGIC = [109, 118, 109, 49]; const MAGIC = [109, 118, 109, 49];
@@ -62,7 +62,7 @@ function initCipherState(keyStr, seedStr) {
} }
return { return {
S, S,
acc: scramble(0xa5a5a5a5 ^ n) >>> 0 acc: scramble(0xa5a5a5a5 ^ n) >>> 0,
}; };
} }
@@ -82,7 +82,7 @@ function nextKeystreamWord(state, step) {
} }
function decodeBase64Url(str) { function decodeBase64Url(str) {
const padded = str.replace(/-/g, "+").replace(/_/g, "/").padEnd(4 * Math.ceil(str.length / 4), "="); const padded = str.replace(/-/g, '+').replace(/_/g, '/').padEnd(4 * Math.ceil(str.length / 4), '=');
const bin = atob(padded); const bin = atob(padded);
const bytes = new Uint8Array(bin.length); const bytes = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i); for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
@@ -111,45 +111,31 @@ function decryptPayload(ciphertext, seed, mediaId) {
for (let i = 0; i < MAGIC.length; i++) { for (let i = 0; i < MAGIC.length; i++) {
if (rawBytes[i] !== MAGIC[i]) { if (rawBytes[i] !== MAGIC[i]) {
throw new Error("decrypt failed: bad seed or tampered payload"); throw new Error('decrypt failed: bad seed or tampered payload');
} }
} }
const payload = rawBytes.subarray(MAGIC.length); const payload = rawBytes.subarray(MAGIC.length);
return new TextDecoder("utf-8").decode(payload); return new TextDecoder('utf-8').decode(payload);
} }
export async function getStream({ id, s, e, tmdbApiKey, sdk }) { export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
const apiKey = tmdbApiKey || sdk?.tmdbApiKey || process.env.TMDB_API_KEY || '45dbdd5e714da212424bda0336167447'; const apiKey = resolveTmdbKey(args, sdk);
const headers = { const headers = {
'Accept': '*/*', Accept: '*/*',
'Origin': 'https://www.movy.sx', Origin: 'https://www.movy.sx',
'Referer': 'https://www.movy.sx/', Referer: 'https://www.movy.sx/',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1' 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1',
}; };
let title = ''; const meta = await getTmdbMetadata(id, isTv, apiKey);
let year = ''; const title = meta?.title || '';
let imdbId = ''; const year = meta?.year ? String(meta.year) : '';
const imdbId = meta?.imdbId || '';
try {
const info = await getTmdbInfo(apiKey, id, type, s);
title = info?.titles?.[0] || '';
year = info?.year || '';
imdbId = info?.imdbId || '';
} catch { }
if (!title) {
try {
const tmdbRes = await fetchJson(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`);
title = tmdbRes?.title || tmdbRes?.name || '';
year = (tmdbRes?.release_date || tmdbRes?.first_air_date || '').split('-')[0] || '';
imdbId = tmdbRes?.imdb_id || tmdbRes?.external_ids?.imdb_id || '';
} catch { }
}
if (!title) return null; if (!title) return null;
@@ -170,7 +156,7 @@ export async function getStream({ id, s, e, tmdbApiKey, sdk }) {
tmdbId: String(id), tmdbId: String(id),
imdbId: String(imdbId || ''), imdbId: String(imdbId || ''),
enc: '2', enc: '2',
seed seed,
}); });
const url = `https://api.wecollege.net/${srv}/sources?${params.toString()}`; const url = `https://api.wecollege.net/${srv}/sources?${params.toString()}`;
@@ -187,10 +173,12 @@ export async function getStream({ id, s, e, tmdbApiKey, sdk }) {
allUrls.push({ allUrls.push({
url: src.url, url: src.url,
server: `Movy - ${srv.toUpperCase()} (${src.quality || 'Auto'})`, server: `Movy - ${srv.toUpperCase()} (${src.quality || 'Auto'})`,
quality: src.quality || 'Auto',
type: src.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://www.movy.sx/', Referer: 'https://www.movy.sx/',
Origin: 'https://www.movy.sx' Origin: 'https://www.movy.sx',
} },
}); });
} }
} }
@@ -205,6 +193,6 @@ export async function getStream({ id, s, e, tmdbApiKey, sdk }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,16 +1,20 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://net79.cc';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const url = isTv const url = isTv
? `https://net79.cc/api/embed-tmdb/${id}?type=tv&se=${s}&ep=${e}` ? `${BASE_URL}/api/embed-tmdb/${id}?type=tv&se=${s}&ep=${e}`
: `https://net79.cc/api/embed-tmdb/${id}?type=movie`; : `${BASE_URL}/api/embed-tmdb/${id}?type=movie`;
const headers = { const headers = {
'Accept': 'application/json', Accept: 'application/json',
'Referer': 'https://net79.cc/', Referer: `${BASE_URL}/`,
'Origin': 'https://net79.cc', Origin: BASE_URL,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
}; };
const res = await fetchJson(url, { headers }).catch(() => null); const res = await fetchJson(url, { headers }).catch(() => null);
@@ -27,9 +31,9 @@ export async function getStream({ id, s, e }) {
server: `Net79 - ${stream.resolution ? `${stream.resolution}p` : 'MP4'}`, server: `Net79 - ${stream.resolution ? `${stream.resolution}p` : 'MP4'}`,
type: stream.url.includes('.m3u8') ? 'hls' : 'mp4', type: stream.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://net79.cc/', Referer: `${BASE_URL}/`,
Origin: 'https://net79.cc' Origin: BASE_URL,
} },
}); });
} }
} }
@@ -40,9 +44,9 @@ export async function getStream({ id, s, e }) {
server: `Net79 - ${res.resolution ? `${res.resolution}p` : 'MP4'}`, server: `Net79 - ${res.resolution ? `${res.resolution}p` : 'MP4'}`,
type: res.mp4.includes('.m3u8') ? 'hls' : 'mp4', type: res.mp4.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://net79.cc/', Referer: `${BASE_URL}/`,
Origin: 'https://net79.cc' Origin: BASE_URL,
} },
}); });
} }
@@ -51,6 +55,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,4 +1,4 @@
import { USER_AGENT, fetchJson, getTmdbInfo } from '../utils/helpers.js'; import { fetchJson, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
const BASE_URL = 'https://providers.peestream.in'; const BASE_URL = 'https://providers.peestream.in';
@@ -6,58 +6,40 @@ const PROVIDERS = {
purstream: 'Athena', purstream: 'Athena',
vidrock: 'Thor', vidrock: 'Thor',
vaplayer: 'Poseidon', vaplayer: 'Poseidon',
netmirror: 'Ra' netmirror: 'Ra',
}; };
export async function getStream(args) { export async function getStream(args) {
const { id, s, e, server, tmdbApiKey } = args; const { id, s, e, server, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
const apiKey = resolveTmdbKey(args, sdk);
let title = args.title || ''; let title = args?.title || '';
let releaseYear = args.year || ''; let releaseYear = args?.year || '';
let imdbId = args.imdbId || ''; let imdbId = args?.imdbId || '';
let seasonTmdbId = args.seasonTmdbId || ''; let seasonTmdbId = args?.seasonTmdbId || '';
let episodeTmdbId = args.episodeTmdbId || ''; let episodeTmdbId = args?.episodeTmdbId || '';
try { try {
const info = await getTmdbInfo(id, type, s, tmdbApiKey); const meta = await getTmdbMetadata(id, isTv, apiKey);
if (info) { if (meta) {
title = title || info.name || info.title || ''; title = title || meta.title || '';
if (!releaseYear && meta.year) releaseYear = String(meta.year);
if (!releaseYear) { if (!imdbId && meta.imdbId) imdbId = meta.imdbId;
const date = info.release_date || info.first_air_date || '';
releaseYear = date ? date.split('-')[0] : (info.year || '');
}
if (!imdbId && info.external_ids?.imdb_id) {
imdbId = info.external_ids.imdb_id;
} else if (!imdbId && info.imdb_id) {
imdbId = info.imdb_id;
}
if (isTv) { if (isTv) {
if (!seasonTmdbId && Array.isArray(info.seasons)) { if (!seasonTmdbId && Array.isArray(meta.seasons)) {
const matchedSeason = info.seasons.find( const matchedSeason = meta.seasons.find(item => item.season_number === Number(s));
item => item.season_number === Number(s) if (matchedSeason) seasonTmdbId = String(matchedSeason.id);
);
if (matchedSeason) {
seasonTmdbId = String(matchedSeason.id);
}
} }
if (!episodeTmdbId && tmdbApiKey) { if (!episodeTmdbId && apiKey) {
try { try {
const seasonData = await fetchJson( const seasonData = await fetchJson(`https://api.themoviedb.org/3/tv/${id}/season/${s}?api_key=${apiKey}`);
`https://api.themoviedb.org/3/tv/${id}/season/${s}?api_key=${tmdbApiKey}`
);
if (seasonData?.episodes) { if (seasonData?.episodes) {
const matchedEp = seasonData.episodes.find( const matchedEp = seasonData.episodes.find(ep => ep.episode_number === Number(e));
ep => ep.episode_number === Number(e) if (matchedEp) episodeTmdbId = String(matchedEp.id);
);
if (matchedEp) {
episodeTmdbId = String(matchedEp.id);
}
} }
} catch { } } catch { }
} }
@@ -68,7 +50,7 @@ export async function getStream(args) {
const queryParams = new URLSearchParams({ const queryParams = new URLSearchParams({
type, type,
tmdbId: String(id), tmdbId: String(id),
title: title || String(id) title: title || String(id),
}); });
if (releaseYear) queryParams.set('releaseYear', String(releaseYear)); if (releaseYear) queryParams.set('releaseYear', String(releaseYear));
@@ -88,10 +70,10 @@ export async function getStream(args) {
const res = await fetch(scrapeUrl, { const res = await fetch(scrapeUrl, {
headers: { headers: {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Accept': 'text/event-stream', Accept: 'text/event-stream',
'Referer': `${BASE_URL}/` Referer: `${BASE_URL}/`,
}, },
signal: AbortSignal.timeout(20000) signal: AbortSignal.timeout(20000),
}); });
if (res.ok) { if (res.ok) {
@@ -114,8 +96,8 @@ export async function getStream(args) {
quality: 'Auto', quality: 'Auto',
type: stream.type === 'hls' || streamUrl.includes('.m3u8') ? 'hls' : 'mp4', type: stream.type === 'hls' || streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: stream.headers || { headers: stream.headers || {
'User-Agent': USER_AGENT 'User-Agent': USER_AGENT,
} },
}); });
} }
} catch { } } catch { }
@@ -128,10 +110,16 @@ export async function getStream(args) {
if (server && server !== 'all') { if (server && server !== 'all') {
const clean = server.toLowerCase().replace('peestream - ', '').trim(); const clean = server.toLowerCase().replace('peestream - ', '').trim();
const filtered = allUrls.filter(u => u.server.toLowerCase().includes(clean)); const filtered = allUrls.filter(u => u.server.toLowerCase().includes(clean));
if (filtered.length) return { allUrls: filtered }; if (filtered.length) return { url: filtered[0].url, headers: filtered[0].headers, allUrls: filtered };
} }
return allUrls.length ? { allUrls } : null; if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} }
export async function getSources() { export async function getSources() {

View File

@@ -1,50 +1,47 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson, resolveImdbId, resolveTmdbKey } from '../utils/helpers.js';
// const PENGU_CONFIG = '%7B%22source_4khdhub%22%3A%22on%22%2C%22source_moviebox%22%3A%22on%22%2C%22source_moviesdrives%22%3A%22on%22%2C%22source_vaplayer%22%3A%22on%22%2C%22source_hdghartv%22%3A%22on%22%2C%22res_2160%22%3A%22on%22%2C%22res_1080%22%3A%22on%22%2C%22res_720%22%3A%22on%22%2C%22disable_direct%22%3A%22on%22%7D'; export async function getStream(args) {
// const BASE_URL = `https://pengu.uk/${PENGU_CONFIG}`; const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
async function getImdbId(tmdbApiKey, tmdbId, s, e) { const apiKey = resolveTmdbKey(args, sdk);
const key = tmdbApiKey; const manifest = sdk?.penguManifest || null;
if (!key) return null;
try { if (!apiKey || !manifest || !manifest.endsWith('manifest.json')) return null;
const url = s != null && e != null const baseUrl = manifest.split('/manifest.json')[0];
? `https://api.themoviedb.org/3/tv/${tmdbId}/external_ids?api_key=${key}` if (!baseUrl) return null;
: `https://api.themoviedb.org/3/movie/${tmdbId}?api_key=${key}`;
const res = await fetchJson(url); try {
return res?.imdb_id || null; const imdbId = await resolveImdbId(id, isTv, apiKey);
} catch { return null; } if (!imdbId) return null;
}
const path = isTv
export async function getStream({ id, s, e, sdk }) { ? `/stream/series/${imdbId}:${s}:${e}.json`
const tmdbApiKey = sdk?.tmdbApiKey || null; : `/stream/movie/${imdbId}.json`;
const manifest = sdk?.penguManifest || null;
if (!tmdbApiKey || !manifest || (manifest && !manifest.endsWith('manifest.json'))) return null; const res = await fetchJson(`${baseUrl}${path}`);
const BASE_URL = manifest ? manifest.split('/manifest.json')[0] : null; if (!res?.streams?.length) return null;
if (!BASE_URL) return null;
try { const allUrls = res.streams.map(stream => {
const imdbId = await getImdbId(tmdbApiKey, id, s, e); if (!stream.url) return null;
if (!imdbId) return null; const headers = stream.behaviorHints?.proxyHeaders?.request || {};
return {
const path = s != null && e != null url: stream.url,
? `/stream/series/${imdbId}:${s}:${e}.json` server: `Pengu - ${stream.name || 'Server'}`,
: `/stream/movie/${imdbId}.json`; quality: 'Auto',
type: stream.url.includes('.m3u8') ? 'hls' : 'mp4',
const res = await fetchJson(`${BASE_URL}${path}`); headers: Object.keys(headers).length > 0 ? headers : undefined,
if (!res?.streams?.length) return null; skipProxy: stream.behaviorHints?.notWebReady === false,
};
const allUrls = res.streams.map(stream => { }).filter(Boolean);
if (!stream.url) return null;
const headers = stream.behaviorHints?.proxyHeaders?.request || {}; if (!allUrls.length) return null;
return {
url: stream.url, return {
server: `Pengu - ${stream.name || 'Server'}`, url: allUrls[0].url,
headers: Object.keys(headers).length > 0 ? headers : undefined, headers: allUrls[0].headers,
skipProxy: stream.behaviorHints?.notWebReady === false allUrls,
}; };
}).filter(Boolean); } catch {
return null;
return allUrls.length ? { allUrls } : null; }
} catch {
return null;
}
} }

View File

@@ -9,7 +9,7 @@ async function safeImport(moduleName) {
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s, e, clientIP, sdk } = args; const { id, s, e, clientIP, sdk } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
const allUrls = []; const allUrls = [];
@@ -64,5 +64,11 @@ export async function getStream(args) {
}) })
); );
return allUrls.length ? { allUrls } : null; if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} }

View File

@@ -1,104 +1,96 @@
import { fetchJson, USER_AGENT, getTmdbInfo } from '../utils/helpers.js'; import { fetchJson, getTmdbMetadata, resolveTmdbKey, USER_AGENT } from '../utils/helpers.js';
const DOMAIN = 'https://purstream.ad'; const DOMAIN = 'https://purstream.ad';
const API_BASE = 'https://api.purstream.ad/api/v1'; const API_BASE = 'https://api.purstream.ad/api/v1';
const HEADERS = { const HEADERS = {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Accept': 'application/json, text/plain, */*', Accept: 'application/json, text/plain, */*',
'Referer': `${DOMAIN}/`, Referer: `${DOMAIN}/`,
'Origin': DOMAIN, Origin: DOMAIN,
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site' 'Sec-Fetch-Site': 'same-site',
}; };
export async function getStream({ id, s, e }) { export async function getStream(args) {
try { const { id, s, e, sdk } = args || {};
const isTv = s != null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
const info = await getTmdbInfo(id, isTv ? 'tv' : 'movie'); const apiKey = resolveTmdbKey(args, sdk);
try {
if (!info?.titles?.length) { const meta = await getTmdbMetadata(id, isTv, apiKey);
return null; if (!meta?.titles?.length) return null;
}
const title = meta.titles[0];
const title = info.titles[0]; const searchUrl = `${API_BASE}/search-bar/search/${encodeURIComponent(title)}`;
const searchUrl = `${API_BASE}/search-bar/search/${encodeURIComponent(title)}`; const searchData = await fetchJson(searchUrl, {
headers: HEADERS,
const searchData = await fetchJson(searchUrl, { signal: AbortSignal.timeout(10000),
headers: HEADERS, });
signal: AbortSignal.timeout(10000)
}); const items = searchData?.data?.items?.movies?.items || [];
const lowerTitle = title.toLowerCase();
const items = searchData?.data?.items?.movies?.items || [];
let match = items.find(item =>
const type = isTv ? 'tv' : 'movie'; item.type === type &&
const lowerTitle = title.toLowerCase(); item.title?.toLowerCase() === lowerTitle &&
(!meta.year || item.release_date?.startsWith(String(meta.year)))
let match = items.find(item => );
item.type === type &&
item.title?.toLowerCase() === lowerTitle && if (!match) {
(!info.year || item.release_date?.startsWith(String(info.year))) match = items.find(item => item.type === type);
); }
if (!match) { if (!match?.id) return null;
match = items.find(item => item.type === type);
} const streamUrl = isTv
? `${API_BASE}/stream/${match.id}/episode?season=${s}&episode=${e}`
if (!match?.id) { : `${API_BASE}/stream/${match.id}`;
return null;
} const json = await fetchJson(streamUrl, {
headers: HEADERS,
const streamUrl = isTv signal: AbortSignal.timeout(10000),
? `${API_BASE}/stream/${match.id}/episode?season=${s}&episode=${e}` });
: `${API_BASE}/stream/${match.id}`;
const sources = json?.data?.items?.sources;
const json = await fetchJson(streamUrl, { if (json?.type !== 'success' || !Array.isArray(sources) || !sources.length) return null;
headers: HEADERS,
signal: AbortSignal.timeout(10000) const chosen = sources.find(src => src.stream_url);
}); if (!chosen?.stream_url) return null;
const sources = json?.data?.items?.sources; const streamHeaders = {
'User-Agent': USER_AGENT,
if (json?.type !== 'success' || !Array.isArray(sources) || !sources.length) { Referer: `${DOMAIN}/`,
return null; };
}
const allUrls = [{
const chosen = sources.find(src => src.stream_url); url: chosen.stream_url,
headers: streamHeaders,
if (!chosen?.stream_url) { server: 'purstream',
return null; quality: chosen.source_name || 'Auto',
} type: chosen.format || 'hls',
skipProxy: true,
const result = { }];
url: chosen.stream_url,
headers: { return {
'User-Agent': USER_AGENT, url: chosen.stream_url,
'Referer': `${DOMAIN}/` headers: streamHeaders,
}, server: 'purstream',
server: 'purstream', quality: chosen.source_name || 'Auto',
quality: chosen.source_name || 'Auto', type: chosen.format || 'hls',
type: chosen.format || 'hls', skipProxy: true,
skipProxy: true allUrls,
}; };
} catch {
return result; return null;
}
} catch (err) { }
return null;
} export async function getSources(args) {
} const stream = await getStream(args);
return stream?.allUrls ? stream.allUrls.map(u => u.server) : ['purstream'];
export async function getSources(args) { }
const stream = await getStream(args);
return stream ? [stream] : [];
}
export const VERIFY_HEADERS = {
...HEADERS
};

View File

@@ -1,4 +1,4 @@
import { USER_AGENT, fetchJson } from '../utils/helpers.js'; import { fetchJson, USER_AGENT } from '../utils/helpers.js';
const C_ARRAY = [ const C_ARRAY = [
'4Z7lUo', 'gwIVSMD', 'PLmz2elE2v', 'Z4OFV0', 'SZ6RZq6Zc', 'zhJEFYxrz8', 'FOm7b0', 'axHS3q4KDq', 'o9zuXQ', '4Aebt', '4Z7lUo', 'gwIVSMD', 'PLmz2elE2v', 'Z4OFV0', 'SZ6RZq6Zc', 'zhJEFYxrz8', 'FOm7b0', 'axHS3q4KDq', 'o9zuXQ', '4Aebt',
@@ -7,12 +7,12 @@ const C_ARRAY = [
'W81hjts92', 'rJhAT', 'NON7LKoMQ', 'NMdY3nsKzI', 't4En5v', 'Qq5cOQ9H', 'Y9nwrp', 'VX5FYVfsf', 'cE5SJG', 'x1vj1', 'W81hjts92', 'rJhAT', 'NON7LKoMQ', 'NMdY3nsKzI', 't4En5v', 'Qq5cOQ9H', 'Y9nwrp', 'VX5FYVfsf', 'cE5SJG', 'x1vj1',
'HegbLe', 'zJ3nmt4OA', 'gt7rxW57dq', 'clIE9b', 'jyJ9g', 'B5jXjMCSx', 'cOzZBZTV', 'FTXGy', 'Dfh1q1', 'ny9jqZ2POI', 'HegbLe', 'zJ3nmt4OA', 'gt7rxW57dq', 'clIE9b', 'jyJ9g', 'B5jXjMCSx', 'cOzZBZTV', 'FTXGy', 'Dfh1q1', 'ny9jqZ2POI',
'X2NnMn', 'MBtoyD', 'qz4Ilys7wB', '68lbOMye', '3YUJnmxp', '1fv5Imona', 'PlfvvXD7mA', 'ZarKfHCaPR', 'owORnX', 'dQP1YU', 'X2NnMn', 'MBtoyD', 'qz4Ilys7wB', '68lbOMye', '3YUJnmxp', '1fv5Imona', 'PlfvvXD7mA', 'ZarKfHCaPR', 'owORnX', 'dQP1YU',
'dVdkx', 'qgiK0E', 'cx9wQ', '5F9bGa', '7UjkKrp', 'Yvhrj', 'wYXez5Dg3', 'pG4GMU', 'MwMAu', 'rFRD5wlM' 'dVdkx', 'qgiK0E', 'cx9wQ', '5F9bGa', '7UjkKrp', 'Yvhrj', 'wYXez5Dg3', 'pG4GMU', 'MwMAu', 'rFRD5wlM',
]; ];
const DEFAULT_SERVICES = [ const DEFAULT_SERVICES = [
'apex', 'pulse', 'solstice', 'quasar', 'horizon', 'primevids', 'apex', 'pulse', 'solstice', 'quasar', 'horizon', 'primevids',
'flowcast', 'asiacloud', 'citadel', 'hindicast', 'guru' 'flowcast', 'asiacloud', 'citadel', 'hindicast', 'guru',
]; ];
function generateRiveSecretKey(e) { function generateRiveSecretKey(e) {
@@ -80,10 +80,10 @@ async function fetchRiveServices() {
const res = await fetchJson(url, { const res = await fetchJson(url, {
headers: { headers: {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Referer': 'https://www.rivestream.app/', Referer: 'https://www.rivestream.app/',
'Accept': 'application/json, text/plain, */*' Accept: 'application/json, text/plain, */*',
}, },
signal: AbortSignal.timeout(6000) signal: AbortSignal.timeout(6000),
}); });
return Array.isArray(res?.data) && res.data.length ? res.data : DEFAULT_SERVICES; return Array.isArray(res?.data) && res.data.length ? res.data : DEFAULT_SERVICES;
} catch { } catch {
@@ -106,10 +106,10 @@ async function fetchServiceStreams(service, isMovie, id, s, e, secretKey, refere
const res = await fetchJson(url, { const res = await fetchJson(url, {
headers: { headers: {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Referer': referer, Referer: referer,
'Accept': 'application/json, text/plain, */*' Accept: 'application/json, text/plain, */*',
}, },
signal: AbortSignal.timeout(10000) signal: AbortSignal.timeout(10000),
}); });
if (!res?.data?.sources || !Array.isArray(res.data.sources)) return []; if (!res?.data?.sources || !Array.isArray(res.data.sources)) return [];
@@ -129,8 +129,8 @@ async function fetchServiceStreams(service, isMovie, id, s, e, secretKey, refere
type: isM3U8 ? 'hls' : 'mp4', type: isM3U8 ? 'hls' : 'mp4',
headers: { headers: {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Referer': referer Referer: referer,
} },
}); });
} }
return streams; return streams;
@@ -140,7 +140,7 @@ async function fetchServiceStreams(service, isMovie, id, s, e, secretKey, refere
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s, e, server } = args; const { id, s, e, server } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const isMovie = !isTv; const isMovie = !isTv;
@@ -168,7 +168,13 @@ export async function getStream(args) {
} }
} }
return allUrls.length ? { allUrls } : null; if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} }
export async function getSources() { export async function getSources() {

View File

@@ -1,23 +1,26 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://f.rivo.st';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const separator = isTv ? '&' : '?';
const basePath = isTv const basePath = isTv
? `https://f.rivo.st/api/source/tv/${id}?s=${s}&e=${e}` ? `${BASE_URL}/api/source/tv/${id}?s=${s}&e=${e}`
: `https://f.rivo.st/api/source/movie/${id}`; : `${BASE_URL}/api/source/movie/${id}`;
const headers = { const headers = {
'Accept': '*/*', Accept: '*/*',
'Referer': 'https://f.rivo.st/', Referer: `${BASE_URL}/`,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
}; };
const serverIndices = Array.from({ length: 26 }, (_, i) => i + 1); const serverIndices = Array.from({ length: 26 }, (_, i) => i + 1);
const delimiter = basePath.includes('?') ? '&' : '?';
const responses = await Promise.allSettled( const responses = await Promise.allSettled(
serverIndices.map(serverNum => serverIndices.map(serverNum =>
fetchJson(`${basePath}&server=${serverNum}`, { headers }) fetchJson(`${basePath}${delimiter}server=${serverNum}`, { headers })
.catch(() => null) .catch(() => null)
) )
); );
@@ -34,10 +37,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: src.url, url: src.url,
server: `Rivo - ${data.server || src.subProvider || 'Server'}`, server: `Rivo - ${data.server || src.subProvider || 'Server'}`,
quality: src.quality || 'Auto',
type: src.kind || (src.url.includes('.m3u8') ? 'hls' : 'mp4'),
headers: { headers: {
Referer: 'https://f.rivo.st/', Referer: `${BASE_URL}/`,
Origin: 'https://f.rivo.st' Origin: BASE_URL,
} },
}); });
} }
} }
@@ -49,6 +54,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,34 +1,17 @@
import { getUA } from '../utils/helpers.js'; import { getTmdbMetadata, getUA, resolveTmdbKey } from '../utils/helpers.js';
const BASE_URL = 'https://streamaggregator.in'; const BASE_URL = 'https://streamaggregator.in';
async function resolveDetails(sdk, id, isTv) { export async function getStream(args) {
const apiKey = sdk?.tmdbApiKey || process.env.TMDB_API_KEY; const { id, s, e, sdk } = args || {};
if (!apiKey) return null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, {
signal: AbortSignal.timeout(6000),
});
if (!res.ok) return null;
const data = await res.json();
const title = isTv ? data.name : data.title;
const releaseDate = isTv ? data.first_air_date : data.release_date;
const year = releaseDate ? releaseDate.split('-')[0] : null;
return { title, year };
} catch {
return null;
}
}
export async function getStream({ id, s, e, sdk }) {
const isTv = Boolean(s && e);
const mediaType = isTv ? 'tv' : 'movie'; const mediaType = isTv ? 'tv' : 'movie';
const apiKey = resolveTmdbKey(args, sdk);
const ua = getUA(); const ua = getUA();
const details = await resolveDetails(sdk, id, isTv); const meta = await getTmdbMetadata(id, isTv, apiKey);
const title = details?.title || String(id); const title = meta?.title || String(id);
const year = details?.year || ''; const year = meta?.year ? String(meta.year) : '';
const formattedTitle = encodeURIComponent(title).replaceAll('%20', '+'); const formattedTitle = encodeURIComponent(title).replaceAll('%20', '+');
const params = new URLSearchParams({ const params = new URLSearchParams({
@@ -114,6 +97,9 @@ export async function getStream({ id, s, e, sdk }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
label, label,
server: serverName,
quality: item.quality || 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers, headers,
}); });
} catch { } } catch { }
@@ -123,7 +109,7 @@ export async function getStream({ id, s, e, sdk }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls,
}; };
} }

View File

@@ -1,15 +1,19 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://thugtv.online';
const API_BASE = 'https://api.thugtv.online/api';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const path = isTv ? `/stream/tv/${id}/${s}/${e}` : `/stream/movie/${id}`; const path = isTv ? `/stream/tv/${id}/${s}/${e}` : `/stream/movie/${id}`;
const mainUrl = `https://api.thugtv.online/api${path}`; const mainUrl = `${API_BASE}${path}`;
const headers = { const headers = {
'Accept': 'application/json', Accept: 'application/json',
'Referer': 'https://thugtv.online/', Referer: `${BASE_URL}/`,
'Origin': 'https://thugtv.online', Origin: BASE_URL,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
}; };
const res = await fetchJson(mainUrl, { headers }).catch(() => null); const res = await fetchJson(mainUrl, { headers }).catch(() => null);
@@ -24,17 +28,19 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: src.url, url: src.url,
server: `ThugTV - ${src.name || src.label || 'Direct'} (${src.quality || 'Auto'})`, server: `ThugTV - ${src.name || src.label || 'Direct'} (${src.quality || 'Auto'})`,
quality: src.quality || 'Auto',
type: src.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://thugtv.online/', Referer: `${BASE_URL}/`,
Origin: 'https://thugtv.online' Origin: BASE_URL,
} },
}); });
continue; continue;
} }
if (src.resolvePath) { if (src.resolvePath) {
const cleanPath = src.resolvePath.startsWith('/') ? src.resolvePath : `/${src.resolvePath}`; const cleanPath = src.resolvePath.startsWith('/') ? src.resolvePath : `/${src.resolvePath}`;
const resolveUrl = `https://thugtv.online/api${cleanPath}`; const resolveUrl = `${BASE_URL}/api${cleanPath}`;
try { try {
const resolved = await fetchJson(resolveUrl, { headers }); const resolved = await fetchJson(resolveUrl, { headers });
@@ -43,10 +49,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: directUrl, url: directUrl,
server: `ThugTV - ${resolved.source.name || resolved.source.label || src.name || 'Direct'}`, server: `ThugTV - ${resolved.source.name || resolved.source.label || src.name || 'Direct'}`,
quality: resolved.source.quality || src.quality || 'Auto',
type: directUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://thugtv.online/', Referer: `${BASE_URL}/`,
Origin: 'https://thugtv.online' Origin: BASE_URL,
} },
}); });
} }
} catch { } } catch { }
@@ -58,6 +66,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,115 +1,123 @@
import { fetchJson, USER_AGENT } from '../utils/helpers.js'; import { fetchJson, USER_AGENT } from '../utils/helpers.js';
const API_BASE = 'https://streamdata.vaplayer.ru/api.php'; const API_BASE = 'https://streamdata.vaplayer.ru/api.php';
const EMBED_ORIGIN = 'https://nextgencloudfabric.com'; const EMBED_ORIGIN = 'https://nextgencloudfabric.com';
export const VERIFY_HEADERS = { export const VERIFY_HEADERS = {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Referer': `${EMBED_ORIGIN}/`, Referer: `${EMBED_ORIGIN}/`,
'Origin': EMBED_ORIGIN Origin: EMBED_ORIGIN,
}; };
function extractStreamUrls(obj, urls = new Set()) { function extractStreamUrls(obj, urls = new Set()) {
if (!obj) return urls; if (!obj) return urls;
if (typeof obj === 'string') { if (typeof obj === 'string') {
if (obj.startsWith('http') && (obj.includes('.m3u8') || obj.includes('.mp4') || obj.includes('.mpd'))) { if (obj.startsWith('http') && (obj.includes('.m3u8') || obj.includes('.mp4') || obj.includes('.mpd'))) {
urls.add(obj); urls.add(obj);
} }
} else if (Array.isArray(obj)) { } else if (Array.isArray(obj)) {
for (const item of obj) extractStreamUrls(item, urls); for (const item of obj) extractStreamUrls(item, urls);
} else if (typeof obj === 'object') { } else if (typeof obj === 'object') {
for (const val of Object.values(obj)) { for (const val of Object.values(obj)) {
extractStreamUrls(val, urls); extractStreamUrls(val, urls);
} }
} }
return urls; return urls;
} }
export async function getStream({ id, s, e }) { export async function getStream(args) {
try { const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
const url = `${API_BASE}?tmdb=${id}&type=${type}${isTv ? `&season=${s}&episode=${e}` : ''}`; const url = `${API_BASE}?tmdb=${id}&type=${type}${isTv ? `&season=${s}&episode=${e}` : ''}`;
const data = await fetchJson(url, { try {
headers: { const data = await fetchJson(url, {
'Accept': '*/*', headers: {
'Origin': EMBED_ORIGIN, Accept: '*/*',
'Referer': `${EMBED_ORIGIN}/`, Origin: EMBED_ORIGIN,
'User-Agent': USER_AGENT Referer: `${EMBED_ORIGIN}/`,
}, 'User-Agent': USER_AGENT,
signal: AbortSignal.timeout(10000) },
}); signal: AbortSignal.timeout(10000),
});
const streamUrls = Array.from(extractStreamUrls(data));
if (!streamUrls.length) return null; const streamUrls = Array.from(extractStreamUrls(data));
if (!streamUrls.length) return null;
let subs = [];
if (data.subtitles && Array.isArray(data.subtitles)) { let subs = [];
subs = data.subtitles; if (data.subtitles && Array.isArray(data.subtitles)) {
} else if (data.captions && Array.isArray(data.captions)) { subs = data.subtitles;
subs = data.captions; } else if (data.captions && Array.isArray(data.captions)) {
} subs = data.captions;
}
const subtitles = subs.map(sub => ({
url: sub.url || sub.file || sub.src, const subtitles = subs.map(sub => ({
lang: sub.display || sub.label || sub.language || sub.lang || 'Unknown' url: sub.url || sub.file || sub.src,
})).filter(s => s.url); lang: sub.display || sub.label || sub.language || sub.lang || 'Unknown',
})).filter(subItem => subItem.url);
const allUrls = streamUrls.map(streamUrl => {
let type = 'mp4'; const allUrls = streamUrls.map(streamUrl => {
if (streamUrl.includes('.mpd')) type = 'dash'; let type = 'mp4';
else if (streamUrl.includes('.m3u8')) type = 'hls'; if (streamUrl.includes('.mpd')) type = 'dash';
else if (streamUrl.includes('.m3u8')) type = 'hls';
return {
url: streamUrl, return {
server: 'VidAPI', url: streamUrl,
quality: 'Auto', server: 'VidAPI',
type, quality: 'Auto',
headers: VERIFY_HEADERS, type,
subtitles: subtitles.length > 0 ? subtitles : undefined, headers: VERIFY_HEADERS,
skipProxy: false subtitles: subtitles.length > 0 ? subtitles : undefined,
}; skipProxy: false,
}); };
});
return allUrls.length ? { allUrls } : null;
} catch { if (!allUrls.length) return null;
return null;
} return {
} url: allUrls[0].url,
headers: allUrls[0].headers,
export async function getSources() { allUrls,
return ['VidAPI']; ...(subtitles.length > 0 ? { subtitles } : {}),
} };
} catch {
export async function proxyStream({ url, res, proxyUtils: { fetchUpstream, rewriteM3u8 } }) { return null;
try { }
const upstream = await fetchUpstream(url, 0, VERIFY_HEADERS); }
if (!upstream) return res.end();
export async function getSources() {
const ct = (upstream.headers?.['content-type'] || '').toLowerCase(); return ['VidAPI'];
const isM3u8 = ct.includes('mpegurl') || ct.includes('m3u8') || /\.m3u8?(\?|$)/i.test(url); }
if (isM3u8) { export async function proxyStream({ url, res, proxyUtils: { fetchUpstream, rewriteM3u8 } }) {
const chunks = []; try {
for await (const c of upstream) chunks.push(c); const upstream = await fetchUpstream(url, 0, VERIFY_HEADERS);
let body = Buffer.concat(chunks).toString('utf8'); if (!upstream) return res.end();
res.setHeader('Content-Type', 'application/vnd.apple.mpegurl'); const ct = (upstream.headers?.['content-type'] || '').toLowerCase();
res.setHeader('Access-Control-Allow-Origin', '*'); const isM3u8 = ct.includes('mpegurl') || ct.includes('m3u8') || /\.m3u8?(\?|$)/i.test(url);
return res.end(rewriteM3u8(body, url, '&va=1&tt=1')); if (isM3u8) {
} const chunks = [];
for await (const c of upstream) chunks.push(c);
res.setHeader('Content-Type', ct || 'application/octet-stream'); let body = Buffer.concat(chunks).toString('utf8');
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Cache-Control', 'public, max-age=3600'); res.setHeader('Content-Type', 'application/vnd.apple.mpegurl');
upstream.pipe(res); res.setHeader('Access-Control-Allow-Origin', '*');
} catch {
if (!res.headersSent) { return res.end(rewriteM3u8(body, url, '&va=1&tt=1'));
res.statusCode = 502; }
res.end();
} res.setHeader('Content-Type', ct || 'application/octet-stream');
} res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Cache-Control', 'public, max-age=3600');
upstream.pipe(res);
} catch {
if (!res.headersSent) {
res.statusCode = 502;
res.end();
}
}
} }

View File

@@ -1,123 +1,15 @@
import { getUA } from '../utils/helpers.js'; import { scrapeVidcoreFamily } from '../utils/helpers.js';
const BASE_URL = 'https://vidcore.io'; const BASE_URL = 'https://vidcore.io';
const API = 'https://enc-dec.app/api';
export async function getStream({ id, s, e }) { export async function getStream(args) {
const isTv = Boolean(s && e); const { id, s, e } = args || {};
const targetUrl = isTv return await scrapeVidcoreFamily({
? `${BASE_URL}/tv/${id}/${s}/${e}/` id,
: `${BASE_URL}/movie/${id}`; s,
e,
const ua = getUA(); baseUrl: BASE_URL,
const baseHeaders = { apiName: 'vidcore',
'User-Agent': ua, serverLabel: 'VidCore',
'Referer': `${BASE_URL}/`, });
'X-Requested-With': 'XMLHttpRequest',
};
try {
const pageRes = await fetch(targetUrl, {
headers: { 'User-Agent': ua },
signal: AbortSignal.timeout(10000),
});
if (!pageRes.ok) return null;
const html = await pageRes.text();
const match = html.match(/\\"(?:en|token)\\":\\"(.*?)\\"/);
if (!match || !match[1]) return null;
const enToken = match[1];
const s1Res = await fetch(`${API}/enc-vidcore?text=${encodeURIComponent(enToken)}&stage=1`, {
signal: AbortSignal.timeout(8000),
});
const s1Data = await s1Res.json();
if (s1Data?.status !== 200 || !s1Data?.result?.stage1) return null;
const token1 = s1Data.result.token;
const stage1Url = s1Data.result.stage1;
const post1Res = await fetch(stage1Url, {
method: 'POST',
headers: { ...baseHeaders, 'X-CSRF-Token': token1 },
signal: AbortSignal.timeout(10000),
});
if (!post1Res.ok) return null;
const stage1Text = await post1Res.text();
const s2Res = await fetch(`${API}/enc-vidcore?text=${encodeURIComponent(stage1Text)}&stage=2`, {
signal: AbortSignal.timeout(8000),
});
const s2Data = await s2Res.json();
if (s2Data?.status !== 200 || !s2Data?.result?.servers) return null;
const { servers: serversUrl, stream: streamBaseUrl, token: token2 } = s2Data.result;
const currentHeaders = { ...baseHeaders, 'X-CSRF-Token': token2 };
const serversRes = await fetch(serversUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(10000),
});
if (!serversRes.ok) return null;
const serversEncrypted = await serversRes.text();
const decServersRes = await fetch(`${API}/dec-vidcore`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: serversEncrypted }),
signal: AbortSignal.timeout(8000),
});
const decServersData = await decServersRes.json();
if (decServersData?.status !== 200 || !Array.isArray(decServersData.result)) return null;
const allUrls = [];
for (const server of decServersData.result) {
if (!server?.data) continue;
try {
const streamUrl = `${streamBaseUrl}/${server.data}`;
const streamEncRes = await fetch(streamUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(8000),
});
if (!streamEncRes.ok) continue;
const streamEncText = await streamEncRes.text();
const decStreamRes = await fetch(`${API}/dec-vidcore`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: streamEncText }),
signal: AbortSignal.timeout(8000),
});
const decStreamData = await decStreamRes.json();
if (decStreamData?.status !== 200 || !decStreamData.result) continue;
const streamResult = decStreamData.result;
const resultUrl = typeof streamResult === 'string' ? streamResult : streamResult?.url || streamResult?.file;
if (typeof resultUrl === 'string' && resultUrl.startsWith('http')) {
allUrls.push({
url: resultUrl,
label: server.name || server.title || 'VidCore',
headers: {
'User-Agent': ua,
'Referer': `${BASE_URL}/`,
},
});
}
} catch { }
}
if (allUrls.length === 0) return null;
return {
url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers,
};
} catch {
return null;
}
} }

View File

@@ -1,123 +1,15 @@
import { getUA } from '../utils/helpers.js'; import { scrapeVidcoreFamily } from '../utils/helpers.js';
const BASE_URL = 'https://vidfast.vc'; const BASE_URL = 'https://vidfast.vc';
const API = 'https://enc-dec.app/api';
export async function getStream({ id, s, e }) { export async function getStream(args) {
const isTv = Boolean(s && e); const { id, s, e } = args || {};
const targetUrl = isTv return await scrapeVidcoreFamily({
? `${BASE_URL}/tv/${id}/${s}/${e}/` id,
: `${BASE_URL}/movie/${id}`; s,
e,
const ua = getUA(); baseUrl: BASE_URL,
const baseHeaders = { apiName: 'vidfast',
'User-Agent': ua, serverLabel: 'VidFast',
'Referer': `${BASE_URL}/`, });
'X-Requested-With': 'XMLHttpRequest',
};
try {
const pageRes = await fetch(targetUrl, {
headers: { 'User-Agent': ua },
signal: AbortSignal.timeout(10000),
});
if (!pageRes.ok) return null;
const html = await pageRes.text();
const match = html.match(/\\"(?:en|token)\\":\\"(.*?)\\"/);
if (!match || !match[1]) return null;
const enToken = match[1];
const s1Res = await fetch(`${API}/enc-vidfast?text=${encodeURIComponent(enToken)}&stage=1`, {
signal: AbortSignal.timeout(8000),
});
const s1Data = await s1Res.json();
if (s1Data?.status !== 200 || !s1Data?.result?.stage1) return null;
const token1 = s1Data.result.token;
const stage1Url = s1Data.result.stage1;
const post1Res = await fetch(stage1Url, {
method: 'POST',
headers: { ...baseHeaders, 'X-CSRF-Token': token1 },
signal: AbortSignal.timeout(10000),
});
if (!post1Res.ok) return null;
const stage1Text = await post1Res.text();
const s2Res = await fetch(`${API}/enc-vidfast?text=${encodeURIComponent(stage1Text)}&stage=2`, {
signal: AbortSignal.timeout(8000),
});
const s2Data = await s2Res.json();
if (s2Data?.status !== 200 || !s2Data?.result?.servers) return null;
const { servers: serversUrl, stream: streamBaseUrl, token: token2 } = s2Data.result;
const currentHeaders = { ...baseHeaders, 'X-CSRF-Token': token2 };
const serversRes = await fetch(serversUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(10000),
});
if (!serversRes.ok) return null;
const serversEncrypted = await serversRes.text();
const decServersRes = await fetch(`${API}/dec-vidfast`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: serversEncrypted }),
signal: AbortSignal.timeout(8000),
});
const decServersData = await decServersRes.json();
if (decServersData?.status !== 200 || !Array.isArray(decServersData.result)) return null;
const allUrls = [];
for (const server of decServersData.result) {
if (!server?.data) continue;
try {
const streamUrl = `${streamBaseUrl}/${server.data}`;
const streamEncRes = await fetch(streamUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(8000),
});
if (!streamEncRes.ok) continue;
const streamEncText = await streamEncRes.text();
const decStreamRes = await fetch(`${API}/dec-vidfast`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: streamEncText }),
signal: AbortSignal.timeout(8000),
});
const decStreamData = await decStreamRes.json();
if (decStreamData?.status !== 200 || !decStreamData.result) continue;
const streamResult = decStreamData.result;
const resultUrl = typeof streamResult === 'string' ? streamResult : streamResult?.url || streamResult?.file;
if (typeof resultUrl === 'string' && resultUrl.startsWith('http')) {
allUrls.push({
url: resultUrl,
label: server.name || server.title || 'VidFast',
headers: {
'User-Agent': ua,
'Referer': `${BASE_URL}/`,
},
});
}
} catch { }
}
if (allUrls.length === 0) return null;
return {
url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers,
};
} catch {
return null;
}
} }

View File

@@ -1,76 +1,79 @@
import { fetchJson, USER_AGENT } from '../utils/helpers.js'; import { fetchJson, USER_AGENT } from '../utils/helpers.js';
const BASE = "https://vidlink.pro"; const BASE_URL = 'https://vidlink.pro';
const HEADERS = { 'User-Agent': USER_AGENT, Origin: BASE, Referer: `${BASE}/` }; const HEADERS = { 'User-Agent': USER_AGENT, Origin: BASE_URL, Referer: `${BASE_URL}/` };
export async function getStream({ id, s, e }) { export async function getStream(args) {
try { const { id, s, e } = args || {};
const encData = await fetchJson(`https://enc-dec.app/api/enc-vidlink?text=${id}`, { signal: AbortSignal.timeout(6000) });
if (encData?.status !== 200 || !encData?.result) return null; try {
const encData = await fetchJson(`https://enc-dec.app/api/enc-vidlink?text=${id}`, { signal: AbortSignal.timeout(6000) });
const basePath = s ? `${BASE}/api/b/tv/${encData.result}/${s}/${e || 1}` : `${BASE}/api/b/movie/${encData.result}`; if (encData?.status !== 200 || !encData?.result) return null;
const responses = await Promise.allSettled([
fetchJson(basePath, { headers: HEADERS, signal: AbortSignal.timeout(10000) }), const basePath = s ? `${BASE_URL}/api/b/tv/${encData.result}/${s}/${e || 1}` : `${BASE_URL}/api/b/movie/${encData.result}`;
fetchJson(`${basePath}?multiLang=0`, { headers: HEADERS, signal: AbortSignal.timeout(10000) }) const responses = await Promise.allSettled([
]); fetchJson(basePath, { headers: HEADERS, signal: AbortSignal.timeout(10000) }),
fetchJson(`${basePath}?multiLang=0`, { headers: HEADERS, signal: AbortSignal.timeout(10000) }),
const streamList = []; ]);
const seenUrls = new Set();
const seenSubs = new Set(); const streamList = [];
const seenUrls = new Set();
for (const res of responses) {
if (res.status !== 'fulfilled' || !res.value?.stream) continue; for (const res of responses) {
const stream = res.value.stream; if (res.status !== 'fulfilled' || !res.value?.stream) continue;
const stream = res.value.stream;
if (stream.playlist && !seenUrls.has(stream.playlist)) {
seenUrls.add(stream.playlist); if (stream.playlist && !seenUrls.has(stream.playlist)) {
const isDash = stream.type === 'dash' || stream.deliveryType === 'dash' || stream.playlist.includes('.mpd'); seenUrls.add(stream.playlist);
streamList.push({ const isDash = stream.type === 'dash' || stream.deliveryType === 'dash' || stream.playlist.includes('.mpd');
url: stream.playlist, streamList.push({
quality: stream.playbackMetadata?.resolutions?.[0] ? `${stream.playbackMetadata.resolutions[0]}p` : 'Auto', url: stream.playlist,
label: `Vidlink ${isDash ? 'DASH' : 'HLS'}`, quality: stream.playbackMetadata?.resolutions?.[0] ? `${stream.playbackMetadata.resolutions[0]}p` : 'Auto',
name: `Vidlink ${isDash ? 'DASH' : 'HLS'}`, label: `Vidlink ${isDash ? 'DASH' : 'HLS'}`,
type: isDash ? 'dash' : 'hls', name: `Vidlink ${isDash ? 'DASH' : 'HLS'}`,
headers: stream.playlistHeaders || {}, server: 'Vidlink',
server: 'Vidlink', type: isDash ? 'dash' : 'hls',
}); headers: stream.playlistHeaders || {},
} });
}
if (stream.qualities && typeof stream.qualities === 'object') {
const qualityOrder = ['1080', '720', '480', '360', ...Object.keys(stream.qualities)]; if (stream.qualities && typeof stream.qualities === 'object') {
const seenQualities = new Set(); const qualityOrder = ['1080', '720', '480', '360', ...Object.keys(stream.qualities)];
const seenQualities = new Set();
for (const q of qualityOrder) {
if (seenQualities.has(q)) continue; for (const q of qualityOrder) {
seenQualities.add(q); if (seenQualities.has(q)) continue;
const qData = stream.qualities[q]; seenQualities.add(q);
if (!qData?.url || seenUrls.has(qData.url)) continue; const qData = stream.qualities[q];
seenUrls.add(qData.url); if (!qData?.url || seenUrls.has(qData.url)) continue;
streamList.push({ seenUrls.add(qData.url);
url: qData.url, streamList.push({
quality: `${q}p`, url: qData.url,
label: `Vidlink ${q}p`, quality: `${q}p`,
name: `Vidlink ${q}p`, label: `Vidlink ${q}p`,
type: qData.type || 'mp4', name: `Vidlink ${q}p`,
headers: qData.headers || {}, server: 'Vidlink',
server: 'Vidlink', type: qData.type || 'mp4',
}); headers: qData.headers || {},
} });
} }
} }
}
if (!streamList.length) return null;
if (!streamList.length) return null;
return {
allUrls: streamList, return {
streams: streamList, url: streamList[0].url,
}; headers: streamList[0].headers,
} catch { allUrls: streamList,
return null; streams: streamList,
} };
} } catch {
return null;
export async function getSources(args) { }
const stream = await getStream(args); }
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server || 'Vidlink'))] : [];
export async function getSources(args) {
const stream = await getStream(args);
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server || 'Vidlink'))] : [];
} }

View File

@@ -1,145 +0,0 @@
import { webcrypto } from 'node:crypto';
import { fetchJson, USER_AGENT } from '../utils/helpers.js';
const GCM_HEX_KEY = '7f3e9c2a8b5d1f4e6a9c3b7d2e5f8a1c4b6d9e2f5a8c1b4d7e9f2a5c8b1d4e7f';
const BASE_URL = 'https://vidrock.ru/';
const PROXY_PREFIX = 'https://proxy.vidrock.store/';
let cryptoKey = null;
function hexToBytes(hex) {
const bytes = new Uint8Array(hex.length / 2);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
}
return bytes;
}
function base64UrlToBytes(value) {
let base64 = value.replace(/-/g, '+').replace(/_/g, '/');
const padding = base64.length % 4;
if (padding === 2) {
base64 += '==';
} else if (padding === 3) {
base64 += '=';
} else if (padding === 1) {
throw new Error('Invalid base64url');
}
return new Uint8Array(Buffer.from(base64, 'base64'));
}
async function getKey() {
if (cryptoKey) return cryptoKey;
const keyBytes = hexToBytes(GCM_HEX_KEY);
cryptoKey = await webcrypto.subtle.importKey(
'raw',
keyBytes,
'AES-GCM',
false,
['decrypt']
);
return cryptoKey;
}
async function decryptStreamUrl(value) {
try {
const data = base64UrlToBytes(value);
if (data.length < 28) {
throw new Error('Ciphertext too short');
}
const iv = data.slice(0, 12);
const ciphertext = data.slice(12);
const key = await getKey();
const decrypted = await webcrypto.subtle.decrypt(
{
name: 'AES-GCM',
iv
},
key,
ciphertext
);
return new TextDecoder().decode(decrypted);
} catch (error) {
return null;
}
}
export async function getStream({ id, s, e }) {
try {
const path = s
? `tv/${id}/${s}/${e || 1}`
: `movie/${id}`;
const apiData = await fetchJson(`${BASE_URL}api/${path}`, {
headers: {
'User-Agent': USER_AGENT,
Referer: BASE_URL,
Origin: BASE_URL
}
});
if (!apiData || typeof apiData !== 'object') {
return null;
}
const streams = [];
for (const [provider, info] of Object.entries(apiData)) {
if (!info?.url) {
continue;
}
const decryptedUrl = await decryptStreamUrl(info.url);
if (!decryptedUrl) {
continue;
}
let url = decryptedUrl;
if (url.startsWith(PROXY_PREFIX)) {
url = decodeURIComponent(
url.slice(PROXY_PREFIX.length).replace(/^\/+/, '')
);
}
const isXpass = url.includes('xpass.top');
streams.push({
name: provider,
url,
file: url,
stream: url,
src: url,
quality: info.type || 'auto',
type: info.type || 'hls',
headers: {
'User-Agent': USER_AGENT,
Referer: isXpass
? 'https://play.xpass.top/'
: BASE_URL,
Origin: isXpass
? 'https://play.xpass.top'
: 'https://vidrock.ru'
}
});
}
return streams.length ? { streams } : null;
} catch (error) {
return null;
}
}

View File

@@ -1,123 +1,15 @@
import { getUA } from '../utils/helpers.js'; import { scrapeVidcoreFamily } from '../utils/helpers.js';
const BASE_URL = 'https://vidup.to'; const BASE_URL = 'https://vidup.to';
const API = 'https://enc-dec.app/api';
export async function getStream(args) {
export async function getStream({ id, s, e }) { const { id, s, e } = args || {};
const isTv = Boolean(s && e); return await scrapeVidcoreFamily({
const targetUrl = isTv id,
? `${BASE_URL}/tv/${id}/${s}/${e}/` s,
: `${BASE_URL}/movie/${id}`; e,
baseUrl: BASE_URL,
const ua = getUA(); apiName: 'vidup',
const baseHeaders = { serverLabel: 'VidUp',
'User-Agent': ua, });
'Referer': `${BASE_URL}/`,
'X-Requested-With': 'XMLHttpRequest',
};
try {
const pageRes = await fetch(targetUrl, {
headers: { 'User-Agent': ua },
signal: AbortSignal.timeout(10000),
});
if (!pageRes.ok) return null;
const html = await pageRes.text();
const match = html.match(/\\"(?:en|token)\\":\\"(.*?)\\"/);
if (!match || !match[1]) return null;
const enToken = match[1];
const s1Res = await fetch(`${API}/enc-vidup?text=${encodeURIComponent(enToken)}&stage=1`, {
signal: AbortSignal.timeout(8000),
});
const s1Data = await s1Res.json();
if (s1Data?.status !== 200 || !s1Data?.result?.stage1) return null;
const token1 = s1Data.result.token;
const stage1Url = s1Data.result.stage1;
const post1Res = await fetch(stage1Url, {
method: 'POST',
headers: { ...baseHeaders, 'X-CSRF-Token': token1 },
signal: AbortSignal.timeout(10000),
});
if (!post1Res.ok) return null;
const stage1Text = await post1Res.text();
const s2Res = await fetch(`${API}/enc-vidup?text=${encodeURIComponent(stage1Text)}&stage=2`, {
signal: AbortSignal.timeout(8000),
});
const s2Data = await s2Res.json();
if (s2Data?.status !== 200 || !s2Data?.result?.servers) return null;
const { servers: serversUrl, stream: streamBaseUrl, token: token2 } = s2Data.result;
const currentHeaders = { ...baseHeaders, 'X-CSRF-Token': token2 };
const serversRes = await fetch(serversUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(10000),
});
if (!serversRes.ok) return null;
const serversEncrypted = await serversRes.text();
const decServersRes = await fetch(`${API}/dec-vidup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: serversEncrypted }),
signal: AbortSignal.timeout(8000),
});
const decServersData = await decServersRes.json();
if (decServersData?.status !== 200 || !Array.isArray(decServersData.result)) return null;
const allUrls = [];
for (const server of decServersData.result) {
if (!server?.data) continue;
try {
const streamUrl = `${streamBaseUrl}/${server.data}`;
const streamEncRes = await fetch(streamUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(8000),
});
if (!streamEncRes.ok) continue;
const streamEncText = await streamEncRes.text();
const decStreamRes = await fetch(`${API}/dec-vidup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: streamEncText }),
signal: AbortSignal.timeout(8000),
});
const decStreamData = await decStreamRes.json();
if (decStreamData?.status !== 200 || !decStreamData.result) continue;
const streamResult = decStreamData.result;
const resultUrl = typeof streamResult === 'string' ? streamResult : streamResult?.url || streamResult?.file;
if (typeof resultUrl === 'string' && resultUrl.startsWith('http')) {
allUrls.push({
url: resultUrl,
label: server.name || server.title || 'VidUp',
headers: {
'User-Agent': ua,
'Referer': `${BASE_URL}/`,
},
});
}
} catch { }
}
if (allUrls.length === 0) return null;
return {
url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers,
};
} catch {
return null;
}
} }

View File

@@ -1,4 +1,4 @@
import { USER_AGENT } from '../utils/helpers.js'; import { formatBytes, USER_AGENT } from '../utils/helpers.js';
const BASE_URL = 'https://vidvault.to'; const BASE_URL = 'https://vidvault.to';
const API_BASE = `${BASE_URL}/api`; const API_BASE = `${BASE_URL}/api`;
@@ -6,21 +6,13 @@ const DL_PROXY_BASE = 'https://dl.gemlelispe.workers.dev';
const SUB_PROXY_BASE = 'https://sub.k5s7sjozpn.workers.dev'; const SUB_PROXY_BASE = 'https://sub.k5s7sjozpn.workers.dev';
const HEADERS = { const HEADERS = {
'Referer': `${BASE_URL}/`, Referer: `${BASE_URL}/`,
'Origin': BASE_URL, Origin: BASE_URL,
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Accept': 'application/json, text/plain, */*', Accept: 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.9', 'Accept-Language': 'en-US,en;q=0.9',
}; };
function formatBytes(bytes, decimals = 2) {
if (!bytes || bytes <= 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), sizes.length - 1);
return `${(bytes / Math.pow(k, i)).toFixed(decimals)} ${sizes[i]}`;
}
async function getToken() { async function getToken() {
const res = await fetch(`${API_BASE}/get-token`, { const res = await fetch(`${API_BASE}/get-token`, {
method: 'GET', method: 'GET',
@@ -36,26 +28,73 @@ function getCaptionType(url) {
return String(url).toLowerCase().includes('.vtt') ? 'vtt' : 'srt'; return String(url).toLowerCase().includes('.vtt') ? 'vtt' : 'srt';
} }
export async function getStream(args) { async function fetchJson(url, options = {}) {
const { id, s, e } = args;
const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
try { try {
const token = await getToken(); const res = await fetch(url, options);
if (!token) return null; if (!res.ok) return null;
return await res.json();
} catch {
return null;
}
}
const payload = { async function resolveDirect(directPath, headers) {
type, const fullUrl = directPath.startsWith('http') ? directPath : `${BASE_URL}${directPath}`;
tmdbId: String(id), try {
}; const res = await fetch(fullUrl, {
method: 'HEAD',
redirect: 'manual',
headers,
});
const loc = res.headers.get('location');
if (loc) return loc;
} catch { }
return fullUrl;
}
if (isTv) { export async function getStream(args) {
payload.season = Number(s); const { id, s, e } = args || {};
payload.episode = Number(e); const isTv = s != null && e != null;
}
const res = await fetch(`${API_BASE}/download-proxy`, { const mediaPath = isTv
? `${BASE_URL}/media/tv/${id}/${s}/${e}`
: `${BASE_URL}/media/movie/${id}`;
const [mediaData, tokenData] = await Promise.all([
fetchJson(mediaPath, { headers: HEADERS }).catch(() => null),
fetchJson(`${BASE_URL}/api/get-token`, { headers: HEADERS }).catch(() => null),
]);
const allUrls = [];
const seen = new Set();
if (Array.isArray(mediaData?.direct)) {
await Promise.all(
mediaData.direct.map(async (item) => {
if (!item?.path) return;
const streamUrl = await resolveDirect(item.path, HEADERS);
if (streamUrl && !seen.has(streamUrl)) {
seen.add(streamUrl);
const format = item.format || (streamUrl.includes('.mkv') ? 'mkv' : 'mp4');
allUrls.push({
url: streamUrl,
server: `VidVault - Direct ${format.toUpperCase()} (${item.quality || item.size || 'Auto'})`,
quality: item.quality || 'Auto',
type: format,
headers: HEADERS,
});
}
})
);
}
const token = tokenData?.t;
if (token) {
const payload = isTv
? { type: 'tv', tmdbId: String(id), season: String(s), episode: String(e) }
: { type: 'movie', tmdbId: String(id) };
const proxyData = await fetchJson(`${BASE_URL}/api/download-proxy`, {
method: 'POST', method: 'POST',
headers: { headers: {
...HEADERS, ...HEADERS,
@@ -63,126 +102,33 @@ export async function getStream(args) {
'x-request-token': token, 'x-request-token': token,
}, },
body: JSON.stringify(payload), body: JSON.stringify(payload),
signal: AbortSignal.timeout(15000), }).catch(() => null);
});
if (!res.ok) return null; const candidates = [
const data = await res.json(); { data: proxyData?.mp4Data, type: 'mp4', label: 'MP4' },
{ data: proxyData?.mkvData, type: 'mkv', label: 'MKV' },
const allUrls = []; { data: proxyData?.mkvV2Data, type: 'mkv', label: 'MKV V2' },
const subtitles = []; ];
const titleTag = encodeURIComponent(isTv ? `Show_${id}_S${s}E${e}` : `Movie_${id}`);
const mp4 = data?.mp4Data;
const downloadData = mp4?.downloadInfo?.data || mp4?.data?.data || mp4?.data || mp4;
if (downloadData) {
const streams = downloadData.streams || downloadData.downloads || [];
for (const item of streams) {
if (!item?.url) continue;
const res = item.resolutions || item.resolution || 'Auto';
const sizeStr = item.size ? ` (${typeof item.size === 'number' ? formatBytes(item.size) : item.size})` : '';
const proxiedUrl = `${DL_PROXY_BASE}/${encodeURIComponent(item.url)}?n=${titleTag}`;
for (const { data, type, label } of candidates) {
if (data?.url && !seen.has(data.url)) {
seen.add(data.url);
allUrls.push({ allUrls.push({
url: proxiedUrl, url: data.url,
server: `VidVault - MP4 ${res}p${sizeStr}`.trim(), server: `VidVault - ${label} (${data.quality || data.size || 'Auto'})`,
quality: typeof res === 'number' ? `${res}p` : res, quality: data.quality || 'Auto',
type: 'mp4', type,
headers: HEADERS, headers: HEADERS,
}); });
} }
const captions = downloadData.captions || [];
for (const cap of captions) {
if (!cap?.url) continue;
const subUrl = `${SUB_PROXY_BASE}/?url=${encodeURIComponent(cap.url)}&title=${titleTag}`;
subtitles.push({
label: cap.lanName || cap.lan || 'Unknown',
type: getCaptionType(cap.url),
language: cap.lan || '',
url: subUrl,
});
}
} }
const mkvFiles = data?.mkvData?.files || [];
for (const file of mkvFiles) {
if (!file?.url) continue;
const sizeStr = file.size ? ` (${typeof file.size === 'number' ? formatBytes(file.size) : file.size})` : '';
allUrls.push({
url: file.url,
server: `VidVault - MKV 480p${sizeStr}`.trim(),
quality: '480p',
type: 'mp4',
headers: HEADERS,
});
}
const mkvV2 = data?.mkvV2Data;
const mkvV2List = Array.isArray(mkvV2)
? mkvV2
: Array.isArray(mkvV2?.files)
? mkvV2.files
: (mkvV2?.url ? [mkvV2] : []);
for (const file of mkvV2List) {
if (!file?.url) continue;
const quality = file.quality ? String(file.quality).replace(/p$/i, '') : 'Auto';
const sizeStr = file.size ? ` (${typeof file.size === 'number' ? formatBytes(file.size) : file.size})` : '';
const meta = [file.country, file.language].filter(Boolean).join(' • ');
const metaStr = meta ? ` [${meta}]` : '';
allUrls.push({
url: file.url,
server: `VidVault - MKV v2 ${quality}p${sizeStr}${metaStr}`.trim(),
quality: `${quality}p`,
type: 'mp4',
headers: HEADERS,
});
}
const mkvV3 = data?.mkvV3Data;
if (mkvV3?.downloads && Array.isArray(mkvV3.downloads)) {
const country = mkvV3.country || '';
const language = mkvV3.language || '';
for (const down of mkvV3.downloads) {
if (Array.isArray(down?.qualities)) {
for (const qObj of down.qualities) {
for (const ep of qObj?.episodes || []) {
if (!ep?.url) continue;
const quality = qObj.quality ? String(qObj.quality).replace(/p$/i, '') : 'Auto';
const sizeStr = ep.size ? ` (${typeof ep.size === 'number' ? formatBytes(ep.size) : ep.size})` : '';
const meta = [ep.country || country, ep.language || language].filter(Boolean).join(' • ');
const metaStr = meta ? ` [${meta}]` : '';
allUrls.push({
url: ep.url,
server: `VidVault - MKV v3 ${quality}p${sizeStr}${metaStr}`.trim(),
quality: `${quality}p`,
type: 'mp4',
headers: HEADERS,
});
}
}
} else if (down?.url) {
const quality = down.quality ? String(down.quality).replace(/p$/i, '') : 'Auto';
const sizeStr = down.size ? ` (${typeof down.size === 'number' ? formatBytes(down.size) : down.size})` : '';
allUrls.push({
url: down.url,
server: `VidVault - MKV v3 ${quality}p${sizeStr}`.trim(),
quality: `${quality}p`,
type: 'mp4',
headers: HEADERS,
});
}
}
}
return allUrls.length ? { allUrls, subtitles: subtitles.length ? subtitles : undefined } : null;
} catch (err) {
return null;
} }
if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} }

View File

@@ -1,7 +1,7 @@
import { getUA } from "../utils/helpers.js"; import { getUA } from '../utils/helpers.js';
const API_URL = "https://api.wecollege.net"; const API_URL = 'https://api.wecollege.net';
const SERVERS = ["miami", "atlanta", "seattle", "denver", "dallas", "tampa"]; const SERVERS = ['miami', 'atlanta', 'seattle', 'denver', 'dallas', 'tampa'];
const MAGIC = [109, 118, 109, 49]; const MAGIC = [109, 118, 109, 49];
function imul(a, b) { function imul(a, b) {
@@ -26,10 +26,10 @@ function gFn(e, t) {
} }
function decryptVidy(ciphertext, seedStr, mediaId) { function decryptVidy(ciphertext, seedStr, mediaId) {
let padded = ciphertext.replace(/-/g, "+").replace(/_/g, "/"); let padded = ciphertext.replace(/-/g, '+').replace(/_/g, '/');
while (padded.length % 4) padded += "="; while (padded.length % 4) padded += '=';
const raw = new Uint8Array(Buffer.from(padded, "base64")); const raw = new Uint8Array(Buffer.from(padded, 'base64'));
const length = raw.length; const length = raw.length;
let tFnv = 2166136261; let tFnv = 2166136261;
@@ -85,7 +85,7 @@ function decryptVidy(ciphertext, seedStr, mediaId) {
for (let i = 0; i < MAGIC.length; i++) { for (let i = 0; i < MAGIC.length; i++) {
if (raw[i] !== MAGIC[i]) { if (raw[i] !== MAGIC[i]) {
throw new Error("Vidy decrypt failed: magic header mismatch"); throw new Error('Vidy decrypt failed: magic header mismatch');
} }
} }
@@ -93,19 +93,19 @@ function decryptVidy(ciphertext, seedStr, mediaId) {
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s = null, e = null } = args; const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const mediaId = Number(id); const mediaId = Number(id);
const headers = { const headers = {
"User-Agent": getUA(), 'User-Agent': getUA(),
Referer: "https://www.vidy.st/", Referer: 'https://www.vidy.st/',
Origin: "https://www.vidy.st", Origin: 'https://www.vidy.st',
}; };
try { try {
const seedUrl = new URL(`${API_URL}/seed`); const seedUrl = new URL(`${API_URL}/seed`);
seedUrl.searchParams.set("mediaId", String(id)); seedUrl.searchParams.set('mediaId', String(id));
const seedRes = await fetch(seedUrl.toString(), { const seedRes = await fetch(seedUrl.toString(), {
headers, headers,
@@ -120,13 +120,13 @@ export async function getStream(args) {
for (const server of SERVERS) { for (const server of SERVERS) {
try { try {
const srcUrl = new URL(`${API_URL}/${server}/sources`); const srcUrl = new URL(`${API_URL}/${server}/sources`);
srcUrl.searchParams.set("mediaType", isTv ? "tv" : "movie"); srcUrl.searchParams.set('mediaType', isTv ? 'tv' : 'movie');
srcUrl.searchParams.set("tmdbId", String(id)); srcUrl.searchParams.set('tmdbId', String(id));
srcUrl.searchParams.set("enc", "2"); srcUrl.searchParams.set('enc', '2');
srcUrl.searchParams.set("seed", seed); srcUrl.searchParams.set('seed', seed);
if (isTv) { if (isTv) {
srcUrl.searchParams.set("seasonId", String(s)); srcUrl.searchParams.set('seasonId', String(s));
srcUrl.searchParams.set("episodeId", String(e)); srcUrl.searchParams.set('episodeId', String(e));
} }
const res = await fetch(srcUrl.toString(), { const res = await fetch(srcUrl.toString(), {
@@ -145,35 +145,40 @@ export async function getStream(args) {
} }
const sources = data?.sources || []; const sources = data?.sources || [];
const playlist = data?.playlist || ""; const playlist = data?.playlist || '';
if (!sources.length && !playlist) continue; if (!sources.length && !playlist) continue;
let streamUrl = playlist; let streamUrl = playlist;
let quality = "1080p"; let quality = '1080p';
for (const src of sources) { for (const src of sources) {
if (src?.quality === "1080p" && src?.url) { if (src?.quality === '1080p' && src?.url) {
streamUrl = src.url; streamUrl = src.url;
quality = "1080p"; quality = '1080p';
break; break;
} }
} }
if (!streamUrl && sources.length) { if (!streamUrl && sources.length) {
streamUrl = sources[0]?.url || ""; streamUrl = sources[0]?.url || '';
quality = sources[0]?.quality || ""; quality = sources[0]?.quality || '';
} }
if (!streamUrl) continue; if (!streamUrl) continue;
const allUrls = [{
url: streamUrl,
headers,
server: 'Vidy',
quality,
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
}];
return { return {
url: streamUrl, url: streamUrl,
headers: { headers,
"User-Agent": getUA(), server: 'Vidy',
Referer: "https://www.vidy.st/",
Origin: "https://www.vidy.st",
},
server: "Vidy",
quality, quality,
type: streamUrl.includes(".m3u8") ? "hls" : "mp4", type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
allUrls,
}; };
} catch { } catch {
continue; continue;
@@ -184,4 +189,4 @@ export async function getStream(args) {
} catch { } catch {
return null; return null;
} }
} }

View File

@@ -1,184 +1,190 @@
import { USER_AGENT, fetchJson } from '../utils/helpers.js'; import { fetchJson, USER_AGENT } from '../utils/helpers.js';
const BASE_URL = 'https://core.vidzee.wtf'; const BASE_URL = 'https://core.vidzee.wtf';
const PLAYER_URL = 'https://player.vidzee.wtf'; const PLAYER_URL = 'https://player.vidzee.wtf';
const SERVICES = ['dcloud', 'ipcloud', 'tik', 'v6:Hindi', '3AHindi']; const SERVICES = ['dcloud', 'ipcloud', 'tik', 'v6:Hindi', '3AHindi'];
const WASM_B64 = 'AGFzbQEAAAABPgtgAX8Bf2ACf38Bf2ABfwBgAn9/AGADf39/AGAAAGAEf39/fwBgBH9/f38Bf2ADf39/AX9gA39/fgBgAAF/Ag0BA2VudgVhYm9ydAAGAygnAgEAAAQBAAEDBAADBQAAAgMHAAEAAAQIAwEJAgIBBQAAAgEABQoBBQMBAAEGJgd/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AEGA2wALB0gHB2RlY3J5cHQAJwVfX25ldwAGBV9fcGluACQHX191bnBpbgAiCV9fY29sbGVjdAAlC19fcnR0aV9iYXNlAwYGbWVtb3J5AgAIAR8MAqkBCogkJyUAIABFBEAPCyAAQRRrIgAQByMCRgRAIAAQECAAIwUjAkUQCgsLCgAgACABai0AAAsKACAAKAIEQXxxCw0AIABBFGsoAhBBAXYLDAAgACABaiACOgAAC1MBAX8gAEHs////A0sEQEHwDEGwDUH9AEEeEAAACyMARQRAEA0LIwAgAEEQahAaIgIgATYCDCACIAA2AhAgAiMBIwIQCiACEAsjA2okAyACQRRqCwoAIAAoAgRBA3ELKQAgACAAIAFBCHZqLQAAQQV0aiABQf8BcUEDdmotAAAgAUEHcXZBAXELwwEBBH8gASgCAEF8cSIDQYACSQR/IANBBHYFQR9B/P///wMgAyADQfz///8DTxsiA2drIgRBB2shAiADIARBBGt2QRBzCyEEIAEoAgghBSABKAIEIgMEQCADIAU2AggLIAUEQCAFIAM2AgQLIAEgACACQQR0IARqQQJ0aiIBKAJgRgRAIAEgBTYCYCAFRQRAIAAgAkECdGoiASgCBEF+IAR3cSEDIAEgAzYCBCADRQRAIAAgACgCAEF+IAJ3cTYCAAsLCwspAQF/IAEoAgghAyAAIAEgAnI2AgQgACADNgIIIAMgABARIAEgADYCCAsNACAAKAIAQXxxQQRqC7wCAQV/IAEoAgAhAyABQQRqIAEoAgBBfHFqIgQoAgAiAkEBcQRAIAAgBBAJIAEgA0EEaiACQXxxaiIDNgIAIAFBBGogASgCAEF8cWoiBCgCACECCyADQQJxBEAgAUEEaygCACIBKAIAIQYgACABEAkgASAGQQRqIANBfHFqIgM2AgALIAQgAkECcjYCACAEQQRrIAE2AgAgACADQXxxIgJBgAJJBH8gAkEEdgVBH0H8////AyACIAJB/P///wNPGyICZ2siA0EHayEFIAIgA0EEa3ZBEHMLIgIgBUEEdGpBAnRqKAJgIQMgAUEANgIEIAEgAzYCCCADBEAgAyABNgIECyAAIAVBBHQgAmpBAnRqIAE2AmAgACAAKAIAQQEgBXRyNgIAIAAgBUECdGoiACAAKAIEQQEgAnRyNgIEC5cBAQJ/PwAiAEEATAR/QQEgAGtAAEEASAVBAAsEQAALQbDbAEEANgIAQdDnAEEANgIAA0AgAUEXSQRAIAFBAnRBsNsAakEANgIEQQAhAANAIABBEEkEQCABQQR0IABqQQJ0QbDbAGkBADYCYCAAQQFqIQAMAQsLIAFBAWohAQwBCwtBsNsAQdTnAD8ArEIQhhAbQbDbACQACyYBAX8gAEEEayEBIABBD3FBASAAGwR/QQEFIAEoAgBBAXELGiABCxIAIAAgADYCBCAAIAA2AgggAAsnAQF/IAAQAyIBRQRAIAAoAggaDwsgASAAKAIIIgA2AgggACABEBELEgAgACABIAAoAgRBA3FyNgIEC0kBAX8gACABQQF0aiEBA0AgAyIAQQFrIQMgAARAIAEvAQAiACACLwEAIgRHBEAgACAEaw8LIAFBAmohASACQQJqIQIMAQsLQQALbgECf0EMQQYQBiIBRQRAQQxBAxAGIQELIAFBADYCACABQQA2AgQgAUEANgIIIABB/P///wNLBEBB4NcAQZDYAEETQTkQAAALIABBARAGIgJBACAA/AsAIAEgAjYCACABIAI2AgQgASAANgIIIAELjgEBAn8gAUGAAkkEfyABQQR2BUEfIAEQFSIBZ2siA0EHayECIAEgA0EEa3ZBEHMLIgEgACACQQJ0aigCBEF/IAF0cSIBBH8gACABaCACQQR0akECdGooAmAFIAAoAgBBfyACQQFqdHEiAQR/IAAgACABaCIAQQJ0aigCBGggAEEEdGpBAnRqKAJgBUEACwsLHQAgAEEBQRsgAGdrdGpBAWsgACAAQf7///8BSRsLLwAgAEH8////A0sEQEHwDEHwDUHNA0EdEAAAC0EMIABBE2pBcHFBBGsgAEEMTRsLZwECfyABKAIAIgNBfHEgAmsiBEEQTwRAIAEgAiADQQJxcjYCACABQQRqIAJqIgEgBEEEa0EBcjYCACAAIAEQDAUgASADQX5xNgIAIAFBBGogASgCAEF8cWoiACAAKAIAQX1xNgIACwswACAAIAIQGiICQQRqIAFBBGogASgCAEF8cfwKAAAgAUGk2wBPBEAgACABEBkLIAILFQAgASABKAIAQQFyNgIAIAAgARAMC48BAQJ/IAAgARAWIgIQFCIBRQRAQQQgACgCoAw/ACIBQRB0QQRrR3QgAhAVIAIgAkGAAk8bakH//wNqQYCAfHFBEHYhAyABIAMgASADShtAAEEASARAIANAAEEASARAAAsLIAAgAUEQdD8ArEIQhhAbIAAgAhAUIQELIAEoAgAaIAAgARAJIAAgASACEBcgAQuGAQEDfyABQRNqQXBxQQRrIQEgACgCoAwiAwRAIAFBEGsiBSADRgRAIAMoAgAhBCAFIQELCyACp0FwcSABayIDQRRJBEAPCyABIARBAnEgA0EIayIDQQFycjYCACABQQA2AgQgAUEANgIIIAFBBGogA2oiA0ECNgIAIAAgAzYCoAwgACABEAwLhQEBA38CQAJAAkACQAJAAkACQAJAAkAgAEEIaygCAA4IAAECAwQFBgcICw8LDwsPCyAAEB0PCyAAKAIAEAEPCyAAKAIEIgEgACgCDEECdGohAgNAIAEgAkkEQCABKAIAIgMEQCADEAELIAFBBGohAQwBCwsgACgCABABDwsgABAdDwsPCwALCQAgACgCABABC0MAIAEgACgCDE8EQEHw1QBBsNYAQfIAQSoQAAALIAAoAgQgAUECdGooAgAiAEUEQEHg1gBBsNYAQfYAQSgQAAALIAALGQBBoA4QDyQBQYDaABAPJARB4NoAEA8kBQv9AQEGfyAAIgFBCHYiAkHMzgBqLQAAIAJBlDJqLQAAQdYAbEGUMmogAEH/AXEiA0EDbmotAAAgA0EDcEECdEGAxwBqKAIAbEELdkEGcGpBAnRBjbrowserigCACICQf8BcSEAIAJBCHUhAgJAIABBAkkNACACQf8BcSEAIAJBCHYhAgNAIAAEQCAAQQF2IgYgAmpBAXRBzNIAaiIELQAAIgUgA0YEfyAELQABQQJ0QYzHAGooAgAiAkH/AXEhACACQQh1IQIgAEECSQ0DIAFBAWoPBSADIAVJBH8gBgUgAiAGaiECIAAgBmsLCyEADAELCyABDwsgASACQQAgAGtxag=='; const WASM_B64 = 'AGFzbQEAAAABPgtgAX8Bf2ACf38Bf2ABfwBgAn9/AGADf39/AGAAAGAEf39/fwBgBH9/f38Bf2ADf39/AX9gA39/fgBgAAF/Ag0BA2VudgVhYm9ydAAGAygnAgEAAAQBAAEDBAADBQAAAgMHAAEAAAQIAwEJAgIBBQAAAgEABQoBBQMBAAEGJgd/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AEGA2wALB0gHB2RlY3J5cHQAJwVfX25ldwAGBV9fcGluACQHX191bnBpbgAiCV9fY29sbGVjdAAlC19fcnR0aV9iYXNlAwYGbWVtb3J5AgAIAR8MAqkBCogkJyUAIABFBEAPCyAAQRRrIgAQByMCRgRAIAAQECAAIwUjAkUQCgsLCgAgACABai0AAAsKACAAKAIEQXxxCw0AIABBFGsoAhBBAXYLDAAgACABaiACOgAAC1MBAX8gAEHs////A0sEQEHwDEGwDUH9AEEeEAAACyMARQRAEA0LIwAgAEEQahAaIgIgATYCDCACIAA2AhAgAiMBIwIQCiACEAsjA2okAyACQRRqCwoAIAAoAgRBA3ELKQAgACAAIAFBCHZqLQAAQQV0aiABQf8BcUEDdmotAAAgAUEHcXZBAXELwwEBBH8gASgCAEF8cSIDQYACSQR/IANBBHYFQR9B/P///wMgAyADQfz///8DTxsiA2drIgRBB2shAiADIARBBGt2QRBzCyEEIAEoAgghBSABKAIEIgMEQCADIAU2AggLIAUEQCAFIAM2AgQLIAEgACACQQR0IARqQQJ0aiIBKAJgRgRAIAEgBTYCYCAFRQRAIAAgAkECdGoiASgCBEF+IAR3cSEDIAEgAzYCBCADRQRAIAAgACgCAEF+IAJ3cTYCAAsLCwspAQF/IAEoAgghAyAAIAEgAnI2AgQgACADNgIIIAMgABARIAEgADYCCAsNACAAKAIAQXxxQQRqC7wCAQV/IAEoAgAhAyABQQRqIAEoAgBBfHFqIgQoAgAiAkEBcQRAIAAgBBAJIAEgA0EEaiACQXxxaiIDNgIAIAFBBGogASgCAEF8cWoiBCgCACECCyADQQJxBEAgAUEEaygCACIBKAIAIQYgACABEAkgASAGQQRqIANBfHFqIgM2AgALIAQgAkECcjYCACAEQQRrIAE2AgAgACADQXxxIgJBgAJJBH8gAkEEdgVBH0H8////AyACIAJB/P///wNPGyICZ2siA0EHayEFIAIgA0EEa3ZBEHMLIgIgBUEEdGpBAnRqKAJgIQMgAUEANgIEIAEgAzYCCCADBEAgAyABNgIECyAAIAVBBHQgAmpBAnRqIAE2AmAgACAAKAIAQQEgBXRyNgIAIAAgBUECdGoiACAAKAIEQQEgAnRyNgIEC5cBAQJ/PwAiAEEATAR/QQEgAGtAAEEASAVBAAsEQAALQbDbAEEANgIAQdDnAEEANgIAA0AgAUEXSQRAIAFBAnRBsNsAakEANgIEQQAhAANAIABBEEkEQCABQQR0IABqQQJ0QbDbAGkBADYCYCAAQQFqIQAMAQsLIAFBAWohAQwBCwtBsNsAQdTnAD8ArEIQhhAbQbDbACQACyYBAX8gAEEEayEBIABBD3FBASAAGwR/QQEFIAEoAgBBAXELGiABCxIAIAAgADYCBCAAIAA2AgggAAsnAQF/IAAQAyIBRQRAIAAoAggaDwsgASAAKAIIIgA2AgggACABEBELEgAgACABIAAoAgRBA3FyNgIEC0kBAX8gACABQQF0aiEBA0AgAyIAQQFrIQMgAARAIAEvAQAiACACLwEAIgRHBEAgACAEaw8LIAFBAmohASACQQJqIQIMAQsLQQALbgECf0EMQQYQBiIBRQRAQQxBAxAGIQELIAFBADYCACABQQA2AgQgAUEANgIIIABB/P///wNLBEBB4NcAQZDYAEETQTkQAAALIABBARAGIgJBACAA/AsAIAEgAjYCACABIAI2AgQgASAANgIIIAELjgEBAn8gAUGAAkkEfyABQQR2BUEfIAEQFSIBZ2siA0EHayECIAEgA0EEa3ZBEHMLIgEgACACQQJ0aigCBEF/IAF0cSIBBH8gACABaCACQQR0akECdGooAmAFIAAoAgBBfyACQQFqdHEiAQR/IAAgACABaCIAQQJ0aigCBGggAEEEdGpBAnRqKAJgBUEACwsLHQAgAEEBQRsgAGdrdGpBAWsgACAAQf7///8BSRsLLwAgAEH8////A0sEQEHwDEHwDUHNA0EdEAAAC0EMIABBE2pBcHFBBGsgAEEMTRsLZwECfyABKAIAIgNBfHEgAmsiBEEQTwRAIAEgAiADQQJxcjYCACABQQRqIAJqIgEgBEEEa0EBcjYCACAAIAEQDAUgASADQX5xNgIAIAFBBGogASgCAEF8cWoiACAAKAIAQX1xNgIACwswACAAIAIQGiICQQRqIAFBBGogASgCAEF8cfwKAAAgAUGk2wBPBEAgACABEBkLIAILFQAgASABKAIAQQFyNgIAIAAgARAMC48BAQJ/IAAgARAWIgIQFCIBRQRAQQQgACgCoAw/ACIBQRB0QQRrR3QgAhAVIAIgAkGAAk8bakH//wNqQYCAfHFBEHYhAyABIAMgASADShtAAEEASARAIANAAEEASARAAAsLIAAgAUEQdD8ArEIQhhAbIAAgAhAUIQELIAEoAgAaIAAgARAJIAAgASACEBcgAQuGAQEDfyABQRNqQXBxQQRrIQEgACgCoAwiAwRAIAFBEGsiBSADRgRAIAMoAgAhBCAFIQELCyACp0FwcSABayIDQRRJBEAPCyABIARBAnEgA0EIayIDQQFycjYCACABQQA2AgQgAUEANgIIIAFBBGogA2oiA0ECNgIAIAAgAzYCoAwgACABEAwLhQEBA38CQAJAAkACQAJAAkACQAJAAkAgAEEIaygCAA4IAAECAwQFBgcICw8LDwsPCyAAEB0PCyAAKAIAEAEPCyAAKAIEIgEgACgCDEECdGohAgNAIAEgAkkEQCABKAIAIgMEQCADEAELIAFBBGohAQwBCwsgACgCABABDwsgABAdDwsPCwALCQAgACgCABABC0MAIAEgACgCDE8EQEHw1QBBsNYAQfIAQSoQAAALIAAoAgQgAUECdGooAgAiAEUEQEHg1gBBsNYAQfYAQSgQAAALIAALGQBBoA4QDyQBQYDaABAPJARB4NoAEA8kBQv9AQEGfyAAIgFBCHYiAkHMzgBqLQAAIAJBlDJqLQAAQdYAbEGUMmogAEH/AXEiA0EDbmotAAAgA0EDcEECdEGAxwBqKAIAbEELdkEGcGpBAnRBjbrowserigCACICQf8BcSEAIAJBCHUhAgJAIABBAkkNACACQf8BcSEAIAJBCHYhAgNAIAAEQCAAQQF2IgYgAmpBAXRBzNIAaiIELQAAIgUgA0YEfyAELQABQQJ0QYzHAGooAgAiAkH/AXEhACACQQh1IQIgAEECSQ0DIAFBAWoPBSADIAVJBH8gBgUgAiAGaiECIAAgBmsLCyEADAELCyABDwsgASACQQAgAGtxag==';
let wasmInstanceCache = null; let wasmInstanceCache = null;
async function getWasmInstance() { async function getWasmInstance() {
if (wasmInstanceCache) return wasmInstanceCache; if (wasmInstanceCache) return wasmInstanceCache;
try { try {
const wasmBuffer = Buffer.from(WASM_B64, 'base64'); const wasmBuffer = Buffer.from(WASM_B64, 'base64');
const wasmModule = await WebAssembly.compile(wasmBuffer); const wasmModule = await WebAssembly.compile(wasmBuffer);
let memory; let memory;
let exports; let exports;
const env = { const env = {
abort() { abort() {
throw new Error('WASM abort'); throw new Error('WASM abort');
} },
}; };
const res = await WebAssembly.instantiate(wasmModule, { env }); const res = await WebAssembly.instantiate(wasmModule, { env });
exports = res.exports; exports = res.exports;
memory = exports.memory; memory = exports.memory;
const refMap = new Map(); const refMap = new Map();
function pin(ptr) { function pin(ptr) {
if (ptr) { if (ptr) {
const count = refMap.get(ptr); const count = refMap.get(ptr);
if (count) refMap.set(ptr, count + 1); if (count) refMap.set(ptr, count + 1);
else refMap.set(exports.__pin(ptr), 1); else refMap.set(exports.__pin(ptr), 1);
} }
return ptr; return ptr;
} }
function unpin(ptr) { function unpin(ptr) {
if (ptr) { if (ptr) {
const count = refMap.get(ptr); const count = refMap.get(ptr);
if (count === 1) { if (count === 1) {
exports.__unpin(ptr); refMap.delete(ptr);
refMap.delete(ptr); exports.__unpin(ptr);
} else if (count) { } else if (count > 1) {
refMap.set(ptr, count - 1); refMap.set(ptr, count - 1);
} }
} }
} }
wasmInstanceCache = { wasmInstanceCache = {
decrypt(encryptedBytes, keyStr) { decrypt(encryptedBytes, keyStr) {
let dataPtr = 0; let dataPtr = 0;
let keyPtr = 0; let keyPtr = 0;
try { try {
const len = encryptedBytes.length; const len = encryptedBytes.length;
const pinPtr = exports.__pin(exports.__new(len, 1)) >>> 0; const pinPtr = exports.__pin(exports.__new(len, 1)) >>> 0;
dataPtr = exports.__new(12, 6) >>> 0; dataPtr = exports.__new(12, 6) >>> 0;
const view = new DataView(memory.buffer); const view = new DataView(memory.buffer);
view.setUint32(dataPtr, pinPtr, true); view.setUint32(dataPtr, pinPtr, true);
view.setUint32(dataPtr + 4, pinPtr, true); view.setUint32(dataPtr + 4, pinPtr, true);
view.setUint32(dataPtr + 8, len, true); view.setUint32(dataPtr + 8, len, true);
new Uint8Array(memory.buffer, pinPtr, len).set(encryptedBytes); new Uint8Array(memory.buffer, pinPtr, len).set(encryptedBytes);
exports.__unpin(pinPtr); exports.__unpin(pinPtr);
pin(dataPtr); pin(dataPtr);
const kLen = keyStr.length; const kLen = keyStr.length;
keyPtr = exports.__new(kLen << 1, 2) >>> 0; keyPtr = exports.__new(kLen << 1, 2) >>> 0;
const u16View = new Uint16Array(memory.buffer); const u16View = new Uint16Array(memory.buffer);
for (let i = 0; i < kLen; i++) { for (let i = 0; i < kLen; i++) {
u16View[(keyPtr >>> 1) + i] = keyStr.charCodeAt(i); u16View[(keyPtr >>> 1) + i] = keyStr.charCodeAt(i);
} }
const resPtr = exports.decrypt(dataPtr, keyPtr) >>> 0; const resPtr = exports.decrypt(dataPtr, keyPtr) >>> 0;
if (!resPtr) return new Uint8Array(0); if (!resPtr) return new Uint8Array(0);
const resView = new DataView(memory.buffer); const resView = new DataView(memory.buffer);
const outPtr = resView.getUint32(resPtr + 4, true); const outPtr = resView.getUint32(resPtr + 4, true);
const outLen = resView.getUint32(resPtr + 8, true); const outLen = resView.getUint32(resPtr + 8, true);
return new Uint8Array(memory.buffer, outPtr, outLen).slice(); return new Uint8Array(memory.buffer, outPtr, outLen).slice();
} finally { } finally {
unpin(dataPtr); unpin(dataPtr);
} }
} },
}; };
return wasmInstanceCache; return wasmInstanceCache;
} catch { } catch {
return null; return null;
} }
} }
async function requestEndpoint(url, headers) { async function requestEndpoint(url, headers) {
try { try {
return await fetchJson(url, { return await fetchJson(url, {
headers, headers,
signal: AbortSignal.timeout(6000) signal: AbortSignal.timeout(6000),
}); });
} catch { } catch {
return null; return null;
} }
} }
async function resolveServiceStream(service, isMovie, id, s, e, headers) { async function resolveServiceStream(service, isMovie, id, s, e, headers) {
const directEndpoint = isMovie const directEndpoint = isMovie
? `${BASE_URL}/streams/movie/${id}?s=${service}` ? `${BASE_URL}/streams/movie/${id}?s=${service}`
: `${BASE_URL}/streams/tv/${id}/${s || 1}/${e || 1}?s=${service}`; : `${BASE_URL}/streams/tv/${id}/${s || 1}/${e || 1}?s=${service}`;
let res = await requestEndpoint(directEndpoint, headers); let res = await requestEndpoint(directEndpoint, headers);
if (!res || !res.url) { if (!res || !res.url) {
const encEndpoint = `${directEndpoint}&e=1`; const encEndpoint = `${directEndpoint}&e=1`;
const encRes = await requestEndpoint(encEndpoint, headers); const encRes = await requestEndpoint(encEndpoint, headers);
if (encRes && encRes.c) { if (encRes && encRes.c) {
const instance = await getWasmInstance(); const instance = await getWasmInstance();
if (instance) { if (instance) {
const encryptedBytes = new Uint8Array(Buffer.from(encRes.c, 'base64')); const encryptedBytes = new Uint8Array(Buffer.from(encRes.c, 'base64'));
const decryptedBytes = instance.decrypt(encryptedBytes, 'player.vidzee.wtf'); const decryptedBytes = instance.decrypt(encryptedBytes, 'player.vidzee.wtf');
if (decryptedBytes.length > 0) { if (decryptedBytes.length > 0) {
const str = new TextDecoder().decode(decryptedBytes); const str = new TextDecoder().decode(decryptedBytes);
try { try {
res = JSON.parse(str); res = JSON.parse(str);
} catch { } } catch { }
} }
} }
} }
} }
if (res && res.url) { if (res && res.url) {
const format = res.url.includes('.m3u8') ? 'hls' : 'mp4'; const format = res.url.includes('.m3u8') ? 'hls' : 'mp4';
return { return {
url: res.url, url: res.url,
server: `VidZee (${service})`, server: `VidZee (${service})`,
quality: res.language || 'Auto', quality: res.language || 'Auto',
type: format, type: format,
headers: { headers: {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Referer': `${PLAYER_URL}/`, Referer: `${PLAYER_URL}/`,
'Origin': PLAYER_URL, Origin: PLAYER_URL,
...(res.headers || {}) ...(res.headers || {}),
} },
}; };
} }
return null; return null;
} }
export async function getStream(args) { export async function getStream(args) {
const { id, s, e, server, clientIP } = args; const { id, s, e, server, clientIP } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const isMovie = !isTv; const isMovie = !isTv;
const headers = { const headers = {
'User-Agent': USER_AGENT, 'User-Agent': USER_AGENT,
'Accept': 'application/json, text/plain, */*', Accept: 'application/json, text/plain, */*',
'Referer': `${PLAYER_URL}/`, Referer: `${PLAYER_URL}/`,
'Origin': PLAYER_URL, Origin: PLAYER_URL,
...(clientIP && { 'X-Forwarded-For': clientIP }) ...(clientIP && { 'X-Forwarded-For': clientIP }),
}; };
let targets = SERVICES; let targets = SERVICES;
if (server && server !== 'all') { if (server && server !== 'all') {
const clean = server.toLowerCase().replace('vidzee (', '').replace(')', '').replace('vidzee', '').trim(); const clean = server.toLowerCase().replace('vidzee (', '').replace(')', '').replace('vidzee', '').trim();
targets = SERVICES.filter(srv => srv.toLowerCase().includes(clean)); targets = SERVICES.filter(srv => srv.toLowerCase().includes(clean));
if (!targets.length) targets = SERVICES; if (!targets.length) targets = SERVICES;
} }
const settled = await Promise.allSettled( const settled = await Promise.allSettled(
targets.map(service => resolveServiceStream(service, isMovie, id, s, e, headers)) targets.map(service => resolveServiceStream(service, isMovie, id, s, e, headers))
); );
const allUrls = []; const allUrls = [];
for (const r of settled) { for (const r of settled) {
if (r.status === 'fulfilled' && r.value) { if (r.status === 'fulfilled' && r.value) {
allUrls.push(r.value); allUrls.push(r.value);
} }
} }
return allUrls.length ? { allUrls } : null; if (!allUrls.length) return null;
}
return {
export async function getSources() { url: allUrls[0].url,
return SERVICES.map(s => `VidZee (${s})`); headers: allUrls[0].headers,
allUrls,
};
}
export async function getSources() {
return SERVICES.map(s => `VidZee (${s})`);
} }

View File

@@ -1,114 +1,124 @@
import { fetchText, USER_AGENT } from '../utils/helpers.js'; import { fetchText, USER_AGENT } from '../utils/helpers.js';
const BASE_URL = 'https://vixsrc.to'; const BASE_URL = 'https://vixsrc.to';
const HEADERS = {
const HEADERS = { 'User-Agent': USER_AGENT,
'User-Agent': USER_AGENT, Accept: 'application/json, text/javascript, */*; q=0.01',
'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Language': 'en-US,en;q=0.9',
'Accept-Language': 'en-US,en;q=0.9', Referer: `${BASE_URL}/`,
'Referer': `${BASE_URL}/`, Origin: BASE_URL,
'Origin': BASE_URL };
};
function extract(regex, text) {
function extract(regex, text) { const m = text?.match(regex);
const m = text?.match(regex); if (!m) return null;
if (!m) return null; let val = m[1];
let val = m[1]; val = val.replace(/\\u0026/gi, '&');
val = val.replace(/\\u0026/gi, '&'); val = val.replace(/\\\//g, '/');
val = val.replace(/\\\//g, '/'); val = val.replace(/\\/g, '');
val = val.replace(/\\/g, ''); return val;
return val; }
}
export async function getStream(args) {
export async function getStream({ id, s, e, absoluteBase }) { const { id, s, e, absoluteBase } = args || {};
try { const isTv = s != null && e != null;
const apiUrl = s && e
? `${BASE_URL}/api/tv/${id}/${s}/${e}` try {
: `${BASE_URL}/api/movie/${id}`; const apiUrl = isTv
? `${BASE_URL}/api/tv/${id}/${s}/${e}`
const apiProxy = absoluteBase && absoluteBase !== '/' : `${BASE_URL}/api/movie/${id}`;
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(apiUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify(HEADERS))}`
: apiUrl; const apiProxy = absoluteBase && absoluteBase !== '/'
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(apiUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify(HEADERS))}`
const apiText = await fetchText(apiProxy, { headers: HEADERS }).catch(() => null); : apiUrl;
const apiData = JSON.parse(apiText || '{}');
if (!apiData.src) return null; const apiText = await fetchText(apiProxy, { headers: HEADERS }).catch(() => null);
const apiData = JSON.parse(apiText || '{}');
const embedUrl = apiData.src.startsWith('http') ? apiData.src : `${BASE_URL}${apiData.src}`; if (!apiData.src) return null;
const embedProxy = absoluteBase && absoluteBase !== '/'
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(embedUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify(HEADERS))}` const embedUrl = apiData.src.startsWith('http') ? apiData.src : `${BASE_URL}${apiData.src}`;
: embedUrl; const embedProxy = absoluteBase && absoluteBase !== '/'
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(embedUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify(HEADERS))}`
const html = await fetchText(embedProxy, { headers: HEADERS }).catch(() => null); : embedUrl;
if (!html) return null;
const html = await fetchText(embedProxy, { headers: HEADERS }).catch(() => null);
const token = extract(/token["']\s*:\s*["']([^"']+)/, html); if (!html) return null;
const expires = extract(/expires["']\s*:\s*["']([^"']+)/, html);
let playlist = extract(/url["']\s*:\s*["']([^"']+)/, html); const token = extract(/token["']\s*:\s*["']([^"']+)/, html);
const expires = extract(/expires["']\s*:\s*["']([^"']+)/, html);
if (!token || !expires || !playlist) return null; let playlist = extract(/url["']\s*:\s*["']([^"']+)/, html);
if (playlist.startsWith('/')) { if (!token || !expires || !playlist) return null;
playlist = `${BASE_URL}${playlist}`;
} if (playlist.startsWith('/')) {
playlist = `${BASE_URL}${playlist}`;
const defaultLang = extract(/lang(?:uage)?["']\s*:\s*["']([a-z]{2,5})/i, html) || 'en'; }
const rawMasterUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${defaultLang}`;
const defaultLang = extract(/lang(?:uage)?["']\s*:\s*["']([a-z]{2,5})/i, html) || 'en';
const masterProxy = absoluteBase && absoluteBase !== '/' const rawMasterUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${defaultLang}`;
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(rawMasterUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify({ ...HEADERS, Referer: embedUrl }))}`
: rawMasterUrl; const masterProxy = absoluteBase && absoluteBase !== '/'
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(rawMasterUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify({ ...HEADERS, Referer: embedUrl }))}`
const playlistText = await fetchText(masterProxy, { headers: { ...HEADERS, 'Referer': embedUrl } }).catch(() => null); : rawMasterUrl;
if (!playlistText?.includes('#EXTM3U')) return null;
const playlistText = await fetchText(masterProxy, { headers: { ...HEADERS, Referer: embedUrl } }).catch(() => null);
const lines = playlistText.split('\n'); if (!playlistText?.includes('#EXTM3U')) return null;
const audioTracks = [];
const seen = new Set(); const lines = playlistText.split('\n');
const audioTracks = [];
for (const line of lines) { const seen = new Set();
if (line.startsWith('#EXT-X-MEDIA') && line.includes('TYPE=AUDIO')) {
const name = line.match(/NAME=["']([^"']+)["']/)?.[1] || 'Default'; for (const line of lines) {
const rendition = line.match(/rendition=([a-zA-Z0-9_-]+)/)?.[1] if (line.startsWith('#EXT-X-MEDIA') && line.includes('TYPE=AUDIO')) {
|| line.match(/LANGUAGE=["']([^"']+)["']/)?.[1] const name = line.match(/NAME=["']([^"']+)["']/)?.[1] || 'Default';
|| name; const rendition = line.match(/rendition=([a-zA-Z0-9_-]+)/)?.[1]
const key = rendition.toLowerCase(); || line.match(/LANGUAGE=["']([^"']+)["']/)?.[1]
if (!seen.has(key)) { || name;
seen.add(key); const key = rendition.toLowerCase();
audioTracks.push({ name, lang: rendition }); if (!seen.has(key)) {
} seen.add(key);
} audioTracks.push({ name, lang: rendition });
} }
}
const allUrls = []; }
if (audioTracks.length > 0) { const allUrls = [];
for (const track of audioTracks) {
const streamUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${track.lang}`; if (audioTracks.length > 0) {
allUrls.push({ for (const track of audioTracks) {
url: streamUrl, const streamUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${track.lang}`;
server: `VixSrc (${track.name})`, allUrls.push({
skipProxy: true, url: streamUrl,
headers: { server: `VixSrc (${track.name})`,
...HEADERS, quality: 'Auto',
'Referer': `${BASE_URL}/` type: 'hls',
} skipProxy: true,
}); headers: {
} ...HEADERS,
} else { Referer: `${BASE_URL}/`,
allUrls.push({ },
url: rawMasterUrl, });
server: 'VixSrc', }
skipProxy: true, } else {
headers: { allUrls.push({
...HEADERS, url: rawMasterUrl,
'Referer': `${BASE_URL}/` server: 'VixSrc',
} quality: 'Auto',
}); type: 'hls',
} skipProxy: true,
headers: {
return { allUrls }; ...HEADERS,
} catch (err) { Referer: `${BASE_URL}/`,
return null; },
} });
}
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch {
return null;
}
} }

View File

@@ -1,8 +1,13 @@
import { fetchJson, fetchText } from '../utils/helpers.js'; import { fetchJson, fetchText } from '../utils/helpers.js';
const API_URL = "https://raw.githubusercontent.com/Watchout2025/api/refs/heads/main/hls/"; const API_URL = 'https://raw.githubusercontent.com/Watchout2025/api/refs/heads/main/hls/';
const HEADERS = {
Origin: 'https://vidout.pages.dev',
Referer: 'https://vidout.pages.dev',
};
export async function getStream({ id, s, e }) { export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
@@ -10,37 +15,46 @@ export async function getStream({ id, s, e }) {
? `${API_URL}tv/${id}/S${s}.json` ? `${API_URL}tv/${id}/S${s}.json`
: `${API_URL}movie/${id}`; : `${API_URL}movie/${id}`;
const headers = {
'Origin': 'https://vidout.pages.dev',
'Referer': 'https://vidout.pages.dev'
};
if (type === 'movie') { if (type === 'movie') {
const data = await fetchText(targetUrl).catch(() => null); const data = await fetchText(targetUrl).catch(() => null);
if (!data || !data.includes('://')) return null; if (!data || !data.includes('://')) return null;
return { const streamUrl = data.trim();
url: data.trim(), const isHls = streamUrl.includes('.m3u8') || streamUrl.includes('.txt') || streamUrl.includes('master') || !streamUrl.includes('.mp4');
headers, const allUrls = [{
allUrls: [{ url: streamUrl,
url: data.trim(), server: 'Watchout - Direct',
server: 'Watchout - Direct', quality: 'Auto',
headers type: isHls ? 'hls' : 'mp4',
}] headers: HEADERS,
}; }];
} else {
const data = await fetchJson(targetUrl).catch(() => null);
const streamUrl = data?.[String(e)] || null;
if (!streamUrl) return null;
return { return {
url: streamUrl, url: streamUrl,
headers, headers: HEADERS,
allUrls: [{ allUrls,
url: streamUrl, };
server: 'Watchout - Direct', } else {
headers let data = await fetchJson(targetUrl).catch(() => null);
}] if (!data) {
data = await fetchJson(`${API_URL}tv/${id}/s${s}.json`).catch(() => null);
}
const streamUrl = data?.[String(e)] || null;
if (!streamUrl) return null;
const isHls = streamUrl.includes('.m3u8') || streamUrl.includes('.txt') || streamUrl.includes('master') || !streamUrl.includes('.mp4');
const allUrls = [{
url: streamUrl,
server: 'Watchout - Direct',
quality: 'Auto',
type: isHls ? 'hls' : 'mp4',
headers: HEADERS,
}];
return {
url: streamUrl,
headers: HEADERS,
allUrls,
}; };
} }
} }

View File

@@ -1,3 +1,5 @@
import { getTmdbMetadata, resolveTmdbKey } from '../utils/helpers.js';
const BASE_URL = 'https://www.films365.org'; const BASE_URL = 'https://www.films365.org';
const HEADERS = { const HEADERS = {
Authorization: 'Bearer 79a02956be35835728a044b11e2ae793149d45fb2c89cb6d029ec01aac19bfdb', Authorization: 'Bearer 79a02956be35835728a044b11e2ae793149d45fb2c89cb6d029ec01aac19bfdb',
@@ -5,125 +7,122 @@ const HEADERS = {
'User-Agent': 'MovieDownloader/1.0', 'User-Agent': 'MovieDownloader/1.0',
}; };
async function resolveTitle(sdk, id, isTv) { export async function getStream(args) {
const apiKey = sdk?.tmdbApiKey || process.env.TMDB_API_KEY; const { id, s, e, sdk } = args || {};
if (!apiKey) return null; const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, {
signal: AbortSignal.timeout(6000),
});
if (!res.ok) return null;
const data = await res.json();
return isTv ? data.name : data.title;
} catch {
return null;
}
}
export async function getStream({ id, s, e, sdk }) {
const isTv = Boolean(s && e);
const targetType = isTv ? 'tv' : 'movie'; const targetType = isTv ? 'tv' : 'movie';
const apiKey = resolveTmdbKey(args, sdk);
const title = await resolveTitle(sdk, id, isTv); const meta = await getTmdbMetadata(id, isTv, apiKey);
const title = meta?.title;
const query = title || String(id); const query = title || String(id);
const searchRes = await fetch(`${BASE_URL}/api/mobile/search`, { try {
method: 'POST', const searchRes = await fetch(`${BASE_URL}/api/mobile/search`, {
headers: HEADERS, method: 'POST',
body: JSON.stringify({ query }), headers: HEADERS,
signal: AbortSignal.timeout(8000), body: JSON.stringify({ query }),
}); signal: AbortSignal.timeout(8000),
});
if (!searchRes.ok) return null; if (!searchRes.ok) return null;
const searchJson = await searchRes.json(); const searchJson = await searchRes.json();
const resultsObj = searchJson?.results; const resultsObj = searchJson?.results;
if (!resultsObj) return null; if (!resultsObj) return null;
const items = resultsObj.all || (targetType === 'tv' ? resultsObj.tvs : resultsObj.movies) || []; const items = resultsObj.all || (targetType === 'tv' ? resultsObj.tvs : resultsObj.movies) || [];
if (!Array.isArray(items) || items.length === 0) return null; if (!Array.isArray(items) || items.length === 0) return null;
const cleanSearchTitle = query.toLowerCase().replace(/[^a-z0-9]/g, ''); const cleanSearchTitle = query.toLowerCase().replace(/[^a-z0-9]/g, '');
let matchedItem = null; let matchedItem = null;
for (const item of items) { for (const item of items) {
const itemType = String(item?.type || '').toLowerCase(); const itemType = String(item?.type || '').toLowerCase();
if (itemType && itemType !== targetType) continue; if (itemType && itemType !== targetType) continue;
const itemTitle = String(item?.title || ''); const itemTitle = String(item?.title || '');
const cleanItemTitle = itemTitle.toLowerCase().replace(/[^a-z0-9]/g, ''); const cleanItemTitle = itemTitle.toLowerCase().replace(/[^a-z0-9]/g, '');
if (cleanItemTitle === cleanSearchTitle || cleanItemTitle.includes(cleanSearchTitle)) { if (cleanItemTitle === cleanSearchTitle || cleanItemTitle.includes(cleanSearchTitle)) {
matchedItem = item; matchedItem = item;
break; break;
}
} }
}
if (!matchedItem) { if (!matchedItem) {
matchedItem = items.find(i => String(i?.type || '').toLowerCase() === targetType) || items[0]; matchedItem = items.find(i => String(i?.type || '').toLowerCase() === targetType) || items[0];
}
const itemId = matchedItem?.id || matchedItem?.tmdbId;
if (!itemId) return null;
const detailsRes = await fetch(`${BASE_URL}/api/mobile/details?id=${itemId}&type=${targetType}`, {
headers: HEADERS,
signal: AbortSignal.timeout(8000),
});
if (!detailsRes.ok) return null;
const detailsJson = await detailsRes.json();
const data = detailsJson?.data;
if (!data) return null;
const spoken = Array.isArray(data.spokenLanguages)
? data.spokenLanguages.map(l => String(l).trim()).filter(Boolean)
: [];
const langSuffix = spoken.length > 0 ? ` · ${spoken.join(', ')}` : '';
const allUrls = [];
if (!isTv) {
const streamUrl = data.downloadUrl || data.videoUrl;
if (streamUrl && typeof streamUrl === 'string') {
allUrls.push({
url: streamUrl.trim(),
label: `X-Downloader${langSuffix}`,
headers: {
'User-Agent': HEADERS['User-Agent'],
},
});
} }
} else {
const seasonNum = Number(s);
const episodeNum = Number(e);
const seasons = Array.isArray(data.seasons) ? data.seasons : [];
const targetSeason = seasons.find(sn => Number(sn.seasonNumber) === seasonNum);
if (targetSeason) { const itemId = matchedItem?.id || matchedItem?.tmdbId;
const episodes = Array.isArray(targetSeason.episodes) ? targetSeason.episodes : []; if (!itemId) return null;
const targetEp = episodes.find(ep => Number(ep.episodeNumber) === episodeNum);
if (targetEp) { const detailsRes = await fetch(`${BASE_URL}/api/mobile/details?id=${itemId}&type=${targetType}`, {
const streamUrl = targetEp.downloadUrl || targetEp.videoUrl; headers: HEADERS,
if (streamUrl && typeof streamUrl === 'string') { signal: AbortSignal.timeout(8000),
allUrls.push({ });
url: streamUrl.trim(),
label: `X-Downloader (S${seasonNum}E${episodeNum})${langSuffix}`, if (!detailsRes.ok) return null;
headers: { const detailsJson = await detailsRes.json();
'User-Agent': HEADERS['User-Agent'], const data = detailsJson?.data;
}, if (!data) return null;
});
const spoken = Array.isArray(data.spokenLanguages)
? data.spokenLanguages.map(l => String(l).trim()).filter(Boolean)
: [];
const langSuffix = spoken.length > 0 ? ` · ${spoken.join(', ')}` : '';
const allUrls = [];
if (!isTv) {
const streamUrl = data.downloadUrl || data.videoUrl;
if (streamUrl && typeof streamUrl === 'string') {
allUrls.push({
url: streamUrl.trim(),
label: `X-Downloader${langSuffix}`,
server: `X-Downloader${langSuffix}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: {
'User-Agent': HEADERS['User-Agent'],
},
});
}
} else {
const seasonNum = Number(s);
const episodeNum = Number(e);
const seasons = Array.isArray(data.seasons) ? data.seasons : [];
const targetSeason = seasons.find(sn => Number(sn.seasonNumber) === seasonNum);
if (targetSeason) {
const episodes = Array.isArray(targetSeason.episodes) ? targetSeason.episodes : [];
const targetEp = episodes.find(ep => Number(ep.episodeNumber) === episodeNum);
if (targetEp) {
const streamUrl = targetEp.downloadUrl || targetEp.videoUrl;
if (streamUrl && typeof streamUrl === 'string') {
allUrls.push({
url: streamUrl.trim(),
label: `X-Downloader (S${seasonNum}E${episodeNum})${langSuffix}`,
server: `X-Downloader (S${seasonNum}E${episodeNum})${langSuffix}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: {
'User-Agent': HEADERS['User-Agent'],
},
});
}
} }
} }
} }
if (allUrls.length === 0) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch {
return null;
} }
if (allUrls.length === 0) return null;
return {
url: allUrls[0].url,
allUrls,
headers: allUrls[0].headers,
};
} }

View File

@@ -1,17 +1,22 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://yapgrid.com';
const EMBED_BASE = 'https://embedwave.cc';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const targetEmbedUrl = isTv const targetEmbedUrl = isTv
? `https://embedwave.cc/embed/tv/${id}/${s}/${e}` ? `${EMBED_BASE}/embed/tv/${id}/${s}/${e}`
: `https://embedwave.cc/embed/movie/${id}`; : `${EMBED_BASE}/embed/movie/${id}`;
const headers = { const headers = {
'Accept': 'application/json', Accept: 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Origin': 'https://yapgrid.com', Origin: BASE_URL,
'Referer': isTv ? `https://yapgrid.com/embed/tv/${id}/${s}/${e}` : `https://yapgrid.com/embed/movie/${id}`, Referer: isTv ? `${BASE_URL}/embed/tv/${id}/${s}/${e}` : `${BASE_URL}/embed/movie/${id}`,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
}; };
const payload = { const payload = {
@@ -20,13 +25,13 @@ export async function getStream({ id, s, e }) {
strictSource: true, strictSource: true,
waitMs: 5000, waitMs: 5000,
nativeHls: false, nativeHls: false,
cacheOnly: true cacheOnly: true,
}; };
const res = await fetchJson('https://yapgrid.com/player/api/extract', { const res = await fetchJson(`${BASE_URL}/player/api/extract`, {
method: 'POST', method: 'POST',
headers, headers,
body: JSON.stringify(payload) body: JSON.stringify(payload),
}).catch(() => null); }).catch(() => null);
if (!res?.success || !Array.isArray(res.found) || !res.found.length) return null; if (!res?.success || !Array.isArray(res.found) || !res.found.length) return null;
@@ -38,18 +43,19 @@ export async function getStream({ id, s, e }) {
let streamUrl = item.url; let streamUrl = item.url;
if (streamUrl.startsWith('/')) { if (streamUrl.startsWith('/')) {
streamUrl = `https://yapgrid.com${streamUrl}`; streamUrl = `${BASE_URL}${streamUrl}`;
} }
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `YapGrid - ${item.nxshaProvider || item.provider || 'Server'}`, server: `YapGrid - ${item.nxshaProvider || item.provider || 'Server'}`,
quality: 'Auto',
type: item.type === 'master' ? 'hls' : (streamUrl.includes('.m3u8') ? 'hls' : 'mp4'), type: item.type === 'master' ? 'hls' : (streamUrl.includes('.m3u8') ? 'hls' : 'mp4'),
headers: { headers: {
Referer: 'https://yapgrid.com/', Referer: `${BASE_URL}/`,
Origin: 'https://yapgrid.com', Origin: BASE_URL,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
} },
}); });
} }
@@ -58,6 +64,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,13 +1,17 @@
import { fetchJson } from '../utils/helpers.js'; import { fetchJson } from '../utils/helpers.js';
export async function getStream({ id, s, e }) { const BASE_URL = 'https://yastream.tamthai.de';
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const path = isTv const path = isTv
? `/stream/series/tmdb:${id}:${s}:${e}.json` ? `/stream/series/tmdb:${id}:${s}:${e}.json`
: `/stream/movie/tmdb:${id}.json`; : `/stream/movie/tmdb:${id}.json`;
const url = `https://yastream.tamthai.de${path}`; const url = `${BASE_URL}${path}`;
const res = await fetchJson(url); const res = await fetchJson(url).catch(() => null);
if (!res || !Array.isArray(res.streams) || !res.streams.length) return null; if (!res || !Array.isArray(res.streams) || !res.streams.length) return null;
const allUrls = res.streams.map(item => { const allUrls = res.streams.map(item => {
@@ -15,8 +19,10 @@ export async function getStream({ id, s, e }) {
return { return {
url: item.url, url: item.url,
server: `YaStream - ${item.name?.replace(/\n/g, ' ') || 'Server'}`, server: `YaStream - ${item.name?.replace(/\n/g, ' ') || 'Server'}`,
quality: 'Auto',
type: item.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: item.behaviorHints?.proxyHeaders?.request || undefined, headers: item.behaviorHints?.proxyHeaders?.request || undefined,
skipProxy: item.behaviorHints?.notWebReady === false skipProxy: item.behaviorHints?.notWebReady === false,
}; };
}).filter(Boolean); }).filter(Boolean);
@@ -25,6 +31,6 @@ export async function getStream({ id, s, e }) {
return { return {
url: allUrls[0].url, url: allUrls[0].url,
headers: allUrls[0].headers, headers: allUrls[0].headers,
allUrls allUrls,
}; };
} }

View File

@@ -1,122 +1,105 @@
import { getUA } from './utils/helpers.js'; import { getUA, resolveImdbId } from './utils/helpers.js';
const SUBTITLE_BASES = [ const SUBTITLE_BASES = [
'https://sub.vdrk.site/v1', 'https://sub.vdrk.site/v1',
'https://sub.vdrk.site/v2', 'https://sub.vdrk.site/v2',
'https://opensubtitles-v3.strem.io' 'https://opensubtitles-v3.strem.io'
]; ];
async function resolveImdbId(id, isTv) { export async function fetchSubtitles(paths = []) {
if (typeof id === 'string' && id.startsWith('tt')) return id; try {
const apiKey = process.env.TMDB_API_KEY; const results = await Promise.all(
if (!apiKey) return `tt${id}`; paths.map(async ({ base, path }) => {
const type = isTv ? 'tv' : 'movie'; try {
try { const res = await fetch(`${base}${path}`, {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`, { headers: { 'User-Agent': getUA() },
signal: AbortSignal.timeout(5000), signal: AbortSignal.timeout(6000),
}); });
if (!res.ok) return `tt${id}`;
const data = await res.json(); if (!res.ok) {
return data.imdb_id || data.external_ids?.imdb_id || `tt${id}`; res.body?.cancel();
} catch { return [];
return `tt${id}`; }
}
} const data = await res.json();
export async function fetchSubtitles(paths = []) { if (base.includes('/v2')) {
try { return Array.isArray(data)
const results = await Promise.all( ? data.map(x => ({
paths.map(async ({ base, path }) => { label: x.label,
try { file: x.file || x.url,
const res = await fetch(`${base}${path}`, { type: 'vtt',
headers: { 'User-Agent': getUA() }, source: 'v2'
signal: AbortSignal.timeout(6000), }))
}); : [];
}
if (!res.ok) {
res.body?.cancel(); if (base.includes('opensubtitles-v3.strem.io')) {
return []; if (!Array.isArray(data?.subtitles)) return [];
} return data.subtitles.map(sub => {
if (!sub?.url) return null;
const data = await res.json(); const isSrt = sub.url.toLowerCase().endsWith('.srt');
return {
if (base.includes('/v2')) { label: sub.lang ? sub.lang.toUpperCase() : 'OpenSubtitles',
return Array.isArray(data) file: sub.url,
? data.map(x => ({ type: isSrt ? 'srt' : 'vtt',
label: x.label, source: 'opensubtitles'
file: x.file || x.url, };
type: 'vtt', }).filter(Boolean);
source: 'v2' }
}))
: []; if (base.includes('fed-subs.pstream.mov')) {
} if (!data?.subtitles || typeof data.subtitles !== 'object') return [];
if (base.includes('opensubtitles-v3.strem.io')) { return Object.entries(data.subtitles)
if (!Array.isArray(data?.subtitles)) return []; .map(([language, sub]) => {
return data.subtitles.map(sub => { if (!sub?.subtitle_link) return null;
if (!sub?.url) return null; const ext = sub.subtitle_link.split('.').pop()?.toLowerCase();
const isSrt = sub.url.toLowerCase().endsWith('.srt'); return {
return { label: sub.subtitle_name || language,
label: sub.lang ? sub.lang.toUpperCase() : 'OpenSubtitles', file: sub.subtitle_link,
file: sub.url, type: ext === 'vtt' ? 'vtt' : 'srt',
type: isSrt ? 'srt' : 'vtt', source: 'febbox'
source: 'opensubtitles' };
}; })
}).filter(Boolean); .filter(Boolean);
} }
if (base.includes('fed-subs.pstream.mov')) { const v1 = Array.isArray(data) ? data : [];
if (!data?.subtitles || typeof data.subtitles !== 'object') return []; return v1.map(x => ({
label: x.label,
return Object.entries(data.subtitles) file: x.file || x.url,
.map(([language, sub]) => { type: 'vtt',
if (!sub?.subtitle_link) return null; source: 'v1'
const ext = sub.subtitle_link.split('.').pop()?.toLowerCase(); }));
return { } catch {
label: sub.subtitle_name || language, return [];
file: sub.subtitle_link, }
type: ext === 'vtt' ? 'vtt' : 'srt', })
source: 'febbox' );
};
}) return results.flat();
.filter(Boolean); } catch {
} return [];
}
const v1 = Array.isArray(data) ? data : []; }
return v1.map(x => ({
label: x.label, export async function getSubPathsMovie(id) {
file: x.file || x.url, const imdbId = await resolveImdbId(id, false);
type: 'vtt', return [
source: 'v1' { base: SUBTITLE_BASES[0], path: `/movie/${id}` },
})); { base: SUBTITLE_BASES[1], path: `/movie/${id}` },
} catch { { base: SUBTITLE_BASES[2], path: `/subtitles/movie/${imdbId}.json` }
return []; ];
} }
})
); export async function getSubPathsTv(id, season, episode) {
const imdbId = await resolveImdbId(id, true);
return results.flat(); return [
} catch { { base: SUBTITLE_BASES[0], path: `/tv/${id}/${season}/${episode}` },
return []; { base: SUBTITLE_BASES[1], path: `/tv/${id}/${season}/${episode}` },
} { base: SUBTITLE_BASES[2], path: `/subtitles/series/${imdbId}:${season}:${episode}.json` }
} ];
}
export async function getSubPathsMovie(id) {
const imdbId = await resolveImdbId(id, false); export { SUBTITLE_BASES };
return [
{ base: SUBTITLE_BASES[0], path: `/movie/${id}` },
{ base: SUBTITLE_BASES[1], path: `/movie/${id}` },
{ base: SUBTITLE_BASES[2], path: `/subtitles/movie/${imdbId}.json` }
];
}
export async function getSubPathsTv(id, season, episode) {
const imdbId = await resolveImdbId(id, true);
return [
{ base: SUBTITLE_BASES[0], path: `/tv/${id}/${season}/${episode}` },
{ base: SUBTITLE_BASES[1], path: `/tv/${id}/${season}/${episode}` },
{ base: SUBTITLE_BASES[2], path: `/subtitles/series/${imdbId}:${season}:${episode}.json` }
];
}
export { SUBTITLE_BASES };

View File

@@ -1,247 +1,586 @@
import crypto from 'node:crypto'; import crypto from 'node:crypto';
export const UA_LIST = [ export const UA_LIST = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15',
'Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0', 'Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0',
]; ];
export const getUA = () => UA_LIST[Math.floor(Math.random() * UA_LIST.length)]; export const getUA = () => UA_LIST[Math.floor(Math.random() * UA_LIST.length)];
export const USER_AGENT = UA_LIST[0]; export const USER_AGENT = UA_LIST[0];
let sharedDcKey = null; const DEFAULT_TMDB_KEY = '45dbdd5e714da212424bda0336167447';
export function decryptPartner(responseText, keyEnv) { let sharedDcKey = null;
try {
const sep = responseText.indexOf(':'); const tmdbInfoCache = new Map();
if (sep === -1) return null; const anilistCache = new Map();
const iv = Buffer.from(responseText.slice(0, sep), 'base64'); const tmdbValidationCache = new Map();
const encrypted = responseText.slice(sep + 1); const tmdbMetaCache = new Map();
if (!sharedDcKey) sharedDcKey = crypto.createHash('sha256').update(keyEnv || '').digest();
const decipher = crypto.createDecipheriv('aes-256-cbc', sharedDcKey, iv); function pruneCache(cache) {
return JSON.parse(decipher.update(encrypted, 'base64', 'utf8') + decipher.final('utf8')); const now = Date.now();
} catch { for (const [k, v] of cache) {
return null; if (now - v.ts >= v.ttl) cache.delete(k);
} }
} if (cache.size > 3000) {
const overflow = cache.size - 3000;
export async function fetchJson(url, options) { const it = cache.keys();
const res = await fetch(url, options); for (let i = 0; i < overflow; i++) cache.delete(it.next().value);
if (!res.ok) throw new Error(`HTTP ${res.status}`); }
return res.json(); }
}
setInterval(() => {
export async function fetchText(url, options) { pruneCache(tmdbValidationCache);
const res = await fetch(url, options); pruneCache(tmdbInfoCache);
if (!res.ok) throw new Error(`HTTP ${res.status}`); pruneCache(anilistCache);
return res.text(); pruneCache(tmdbMetaCache);
} }, 60000).unref();
const tmdbInfoCache = new Map(); function cacheGet(cache, key) {
const anilistCache = new Map(); const entry = cache.get(key);
const tmdbValidationCache = new Map(); if (!entry) return undefined;
if (Date.now() - entry.ts >= entry.ttl) {
function pruneHelperCache(cache) { cache.delete(key);
const now = Date.now(); return undefined;
for (const [k, v] of cache) if (now - v.ts >= v.ttl) cache.delete(k); }
if (cache.size > 3000) { return entry.val;
const overflow = cache.size - 3000; }
const it = cache.keys();
for (let i = 0; i < overflow; i++) cache.delete(it.next().value); function cacheSet(cache, key, val, ttl) {
} cache.set(key, { val, ts: Date.now(), ttl });
} }
export async function resolveImdbId(id, isTv, tmdbApiKey) { export function resolveTmdbKey(args = {}, sdk = null) {
if (typeof id === 'string' && id.startsWith('tt')) return id; return (
const apiKey = tmdbApiKey || process.env.TMDB_API_KEY; args?.tmdbApiKey ||
if (!apiKey) return `tt${id}`; args?.sdk?.tmdbApiKey ||
const type = isTv ? 'tv' : 'movie'; sdk?.tmdbApiKey ||
try { process.env.TMDB_API_KEY ||
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`, { DEFAULT_TMDB_KEY
signal: AbortSignal.timeout(5000), );
}); }
if (!res.ok) return `tt${id}`;
const data = await res.json(); export function slugify(text) {
return data.imdb_id || data.external_ids?.imdb_id || `tt${id}`; if (!text) return '';
} catch { return String(text)
return `tt${id}`; .toLowerCase()
} .normalize('NFKD')
} .replace(/[\u0300-\u036f]/g, '')
.replace(/[^a-z0-9]+/g, '-')
setInterval(() => { .replace(/^-|-$/g, '');
pruneHelperCache(tmdbValidationCache); }
pruneHelperCache(tmdbInfoCache);
pruneHelperCache(anilistCache); export function cleanTitle(text) {
}, 60000).unref(); if (!text) return '';
return String(text)
function cacheGet(cache, key) { .toLowerCase()
const entry = cache.get(key); .replace(/\(\d{4}\)/g, '')
if (!entry) return undefined; .replace(/[^a-z0-9]/g, '')
if (Date.now() - entry.ts >= entry.ttl) { cache.delete(key); return undefined; } .trim();
return entry.val; }
}
export function formatBytes(bytes, decimals = 2) {
function cacheSet(cache, key, val, ttl) { cache.set(key, { val, ts: Date.now(), ttl }); } if (!bytes || bytes <= 0) return '0 B';
const k = 1024;
export async function createStreamArgs(source, sdk, id, s, e, clientIP = null) { const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const audio = /dub$/.test(source.key) ? 'dub' : 'sub'; const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), sizes.length - 1);
return { return `${(bytes / Math.pow(k, i)).toFixed(decimals)} ${sizes[i]}`;
id: id, }
s: s,
e: e, export function getRandomHex(size = 32) {
clientIP: clientIP, return crypto.randomBytes(size).toString('hex');
absoluteBase: '/', }
audio,
sdk, export async function fetchJson(url, options = {}) {
config: source, const res = await fetch(url, options);
} if (!res.ok) throw new Error(`HTTP ${res.status}`);
} return res.json();
}
export async function validateTmdbId(tmdbApiKey, tmdbId, mediaType = 'movie') {
let apiKey = tmdbApiKey; export async function fetchText(url, options = {}) {
let id = tmdbId; const res = await fetch(url, options);
let type = mediaType; if (!res.ok) throw new Error(`HTTP ${res.status}`);
if (id === 'movie' || id === 'tv' || !id) { return res.text();
if (apiKey && apiKey !== 'movie' && apiKey !== 'tv') { }
type = id || 'movie';
id = apiKey; export function decryptPartner(responseText, keyEnv) {
apiKey = process.env.TMDB_API_KEY; try {
} const sep = responseText.indexOf(':');
} if (sep === -1) return null;
if (!apiKey) { const iv = Buffer.from(responseText.slice(0, sep), 'base64');
apiKey = process.env.TMDB_API_KEY; const encrypted = responseText.slice(sep + 1);
} if (!sharedDcKey) sharedDcKey = crypto.createHash('sha256').update(keyEnv || '').digest();
const key = `${id}-${type}`; const decipher = crypto.createDecipheriv('aes-256-cbc', sharedDcKey, iv);
const cached = cacheGet(tmdbValidationCache, key); return JSON.parse(decipher.update(encrypted, 'base64', 'utf8') + decipher.final('utf8'));
if (cached !== undefined) return cached; } catch {
if (!apiKey) return { valid: false, error: 'TMDB API key not configured' }; return null;
try { }
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) }); }
if (res.ok) {
const data = await res.json(); export async function getTmdbMetadata(id, isTv, apiKey = null) {
const isValid = !!(data?.id && (data?.title || data?.name)); const key = apiKey || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
const result = { valid: isValid, error: isValid ? null : 'Invalid TMDB ID' }; const type = isTv ? 'tv' : 'movie';
cacheSet(tmdbValidationCache, key, result, 300000); const cacheKey = `${id}-${type}-${key}`;
return result; const cached = cacheGet(tmdbMetaCache, cacheKey);
} if (cached !== undefined) return cached;
const result = { valid: false, error: `TMDB API error: ${res.status}` };
cacheSet(tmdbValidationCache, key, result, 60000); const fallback = {
return result; title: '',
} catch (error) { originalTitle: '',
const result = { valid: false, error: `Failed to validate TMDB ID: ${error.message}` }; titles: [],
cacheSet(tmdbValidationCache, key, result, 60000); year: null,
return result; releaseDate: '',
} imdbId: null,
} isAnime: false,
runtime: 0,
export async function getTmdbInfo(tmdbApiKey, tmdbId, mediaType, season) { seasons: [],
let apiKey = tmdbApiKey; };
let id = tmdbId;
let type = mediaType; try {
let s = season; const url = `https://api.themoviedb.org/3/${type}/${id}?api_key=${key}&append_to_response=external_ids,alternative_titles`;
if (apiKey === 'movie' || apiKey === 'tv') { const res = await fetch(url, { signal: AbortSignal.timeout(6000) });
type = apiKey; if (!res.ok) {
id = tmdbId; cacheSet(tmdbMetaCache, cacheKey, fallback, 60000);
apiKey = process.env.TMDB_API_KEY; return fallback;
} else if (id === 'movie' || id === 'tv') { }
type = id;
id = apiKey; const data = await res.json();
apiKey = process.env.TMDB_API_KEY; const title = data.name || data.title || '';
} const originalTitle = data.original_name || data.original_title || '';
if (!apiKey) { const releaseDate = data.first_air_date || data.release_date || '';
apiKey = process.env.TMDB_API_KEY; const year = releaseDate ? parseInt(releaseDate.slice(0, 4), 10) : null;
} const imdbId = data.imdb_id || data.external_ids?.imdb_id || null;
const key = `${id}-${type}-${s || ''}`; const runtime = isTv ? (data.episode_run_time?.[0] || 24) : (data.runtime || 90);
const cached = cacheGet(tmdbInfoCache, key);
if (cached !== undefined) return cached; const titles = [];
if (!apiKey) return { isAnime: false, titles: [], year: null, imdbId: null }; if (title) titles.push(title);
try { if (originalTitle && !titles.includes(originalTitle)) titles.push(originalTitle);
const [mainRes, seasonRes] = await Promise.all([
fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`, { signal: AbortSignal.timeout(5000) }), const alts = data.alternative_titles?.titles || data.alternative_titles?.results || [];
s && type === 'tv' ? fetch(`https://api.themoviedb.org/3/tv/${id}/season/${s}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) }) : Promise.resolve(null), for (const alt of alts) {
]); const altTitle = alt.title || alt.name;
let mainData = null, seasonData = null; if (altTitle && !titles.includes(altTitle)) titles.push(altTitle);
if (mainRes.ok) mainData = await mainRes.json(); else mainRes.body?.cancel(); }
if (seasonRes) { if (seasonRes.ok) seasonData = await seasonRes.json(); else seasonRes.body?.cancel(); }
const genres = mainData?.genres || []; const genres = data.genres || [];
const isAnime = genres.some(g => g.id === 16) && ((mainData?.origin_country || []).includes('JP') || mainData?.original_language === 'ja'); const isAnime = genres.some(g => g.id === 16) && ((data.origin_country || []).includes('JP') || data.original_language === 'ja');
const titles = [];
if (seasonData?.name) titles.push(seasonData.name); const result = {
const titleText = mainData?.title || mainData?.name || ''; title,
const ot = mainData?.original_title || mainData?.original_name || ''; originalTitle,
if (titleText) titles.push(titleText); titles,
if (ot && ot !== titleText) titles.push(ot); year,
const dateStr = seasonData?.air_date || mainData?.release_date || mainData?.first_air_date || ''; releaseDate,
const result = { isAnime, titles: [...new Set(titles.filter(Boolean))], year: dateStr ? parseInt(dateStr.slice(0, 4), 10) : null, imdbId: mainData?.imdb_id || mainData?.external_ids?.imdb_id || null }; imdbId,
cacheSet(tmdbInfoCache, key, result, 600000); isAnime,
return result; runtime,
} catch { return { isAnime: false, titles: [], year: null, imdbId: null }; } seasons: Array.isArray(data.seasons) ? data.seasons : [],
} };
export async function tmdbToAnilist(tmdbId, mediaType, season, titles = [], year = null) { cacheSet(tmdbMetaCache, cacheKey, result, 600000);
const key = `${tmdbId}-${mediaType}-${season || ''}`; return result;
const cached = cacheGet(anilistCache, key); } catch {
if (cached !== undefined) return cached; cacheSet(tmdbMetaCache, cacheKey, fallback, 60000);
try { return fallback;
const res = await fetch(`https://api.ani.zip/mappings?tmdb_id=${tmdbId}&type=${mediaType}&season=${season || 1}`, { signal: AbortSignal.timeout(6000) }); }
if (res.ok) { }
const id = (await res.json())?.mappings?.[0]?.anilist_id;
if (id) { cacheSet(anilistCache, key, id, 600000); return id; } export async function resolveImdbId(id, isTv, tmdbApiKey = null) {
} else res.body?.cancel(); if (typeof id === 'string' && id.startsWith('tt')) return id;
} catch { } const meta = await getTmdbMetadata(id, isTv, tmdbApiKey);
if (!titles.length) return null; return meta?.imdbId || `tt${id}`;
const query = `query ($s: String) { Page(page:1,perPage:10) { media(search:$s,type:ANIME) { id title { romaji english native } startDate { year } format } } }`; }
let bestId = null, bestScore = -1;
for (const searchTitle of titles) { export async function getTmdbInfo(arg1, arg2, arg3, arg4) {
try { let apiKey = null;
const res = await fetch('https://graphql.anilist.co', { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify({ query, variables: { s: searchTitle } }), signal: AbortSignal.timeout(6000) }); let id = null;
if (!res.ok) { res.body?.cancel(); continue; } let type = null;
for (const entry of (await res.json())?.data?.Page?.media || []) { let season = null;
const entryTitles = [entry.title?.romaji, entry.title?.english, entry.title?.native].filter(Boolean).map(t => t.toLowerCase());
const sl = searchTitle.toLowerCase(); if (arg1 === 'movie' || arg1 === 'tv') {
let score = 0; type = arg1;
if (entryTitles.some(t => t === sl)) score += 5; id = arg2;
else if (entryTitles.some(t => t.includes(sl) || sl.includes(t))) score += 3; season = arg3;
else if (entryTitles.some(t => { const w = sl.split(/\s+/).filter(x => x.length > 3); return w.length > 0 && w.every(x => t.includes(x)); })) score += 2; apiKey = arg4 || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
else continue; } else if (arg2 === 'movie' || arg2 === 'tv') {
if (year && entry.startDate?.year) { if (typeof arg1 === 'string' && arg1.length > 20 && !/^\d+$/.test(arg1)) {
const diff = Math.abs(entry.startDate.year - year); apiKey = arg1;
if (diff === 0) score += 3; else if (diff === 1) score += 1; else if (diff > 2) score -= 3; id = arg3;
} type = arg2;
if (mediaType === 'tv' && ['TV', 'TV_SHORT', 'ONA', 'OVA'].includes(entry.format)) score += 1; season = arg4;
if (mediaType === 'movie' && entry.format === 'MOVIE') score += 1; } else {
if (score > bestScore) { bestScore = score; bestId = entry.id; } id = arg1;
} type = arg2;
if (bestScore >= 8) break; season = arg3;
} catch { } apiKey = arg4 || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
} }
if (bestId) cacheSet(anilistCache, key, bestId, 600000); } else if (arg3 === 'movie' || arg3 === 'tv') {
return bestId; apiKey = arg1;
} id = arg2;
type = arg3;
export async function imdbToTmdb(tmdbApiKey, imdbId, mediaType = 'movie') { season = arg4;
let apiKey = tmdbApiKey; } else {
let id = imdbId; id = arg1;
let type = mediaType; type = arg2 || 'movie';
if (id === 'movie' || id === 'tv') { season = arg3;
type = id; apiKey = arg4 || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
id = apiKey; }
apiKey = process.env.TMDB_API_KEY;
} if (!apiKey) apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
if (!apiKey) {
apiKey = process.env.TMDB_API_KEY; const isTv = type === 'tv';
} const key = `${id}-${type}-${season || ''}-${apiKey}`;
const key = `imdb-${id}`; const cached = cacheGet(tmdbInfoCache, key);
const cached = cacheGet(tmdbInfoCache, key); if (cached !== undefined) return cached;
if (cached !== undefined) return cached;
if (!apiKey) return null; try {
try { const meta = await getTmdbMetadata(id, isTv, apiKey);
const data = await fetchJson(`https://api.themoviedb.org/3/find/${id}?api_key=${apiKey}&external_source=imdb_id`, { signal: AbortSignal.timeout(5000) }); let seasonTitle = null;
let result = null;
if (type === 'movie' && data.movie_results?.length) result = data.movie_results[0].id; if (season && isTv) {
else if (type === 'tv' && data.tv_results?.length) result = data.tv_results[0].id; try {
if (result) cacheSet(tmdbInfoCache, key, result, 600000); const seasonRes = await fetch(`https://api.themoviedb.org/3/tv/${id}/season/${season}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) });
return result; if (seasonRes.ok) {
} catch { return null; } const seasonData = await seasonRes.json();
} if (seasonData?.name) seasonTitle = seasonData.name;
}
} catch { }
}
const titles = seasonTitle ? [seasonTitle, ...meta.titles] : meta.titles;
const result = {
name: meta.title,
title: meta.title,
isAnime: meta.isAnime,
titles: [...new Set(titles.filter(Boolean))],
year: meta.year,
release_date: meta.releaseDate,
first_air_date: meta.releaseDate,
imdbId: meta.imdbId,
imdb_id: meta.imdbId,
external_ids: { imdb_id: meta.imdbId },
seasons: meta.seasons,
runtime: meta.runtime,
};
cacheSet(tmdbInfoCache, key, result, 600000);
return result;
} catch {
const fallback = {
name: '',
title: '',
isAnime: false,
titles: [],
year: null,
release_date: '',
first_air_date: '',
imdbId: null,
imdb_id: null,
external_ids: { imdb_id: null },
seasons: [],
runtime: 0,
};
return fallback;
}
}
export async function validateTmdbId(tmdbApiKey, tmdbId, mediaType = 'movie') {
let apiKey = tmdbApiKey;
let id = tmdbId;
let type = mediaType;
if (id === 'movie' || id === 'tv' || !id) {
if (apiKey && apiKey !== 'movie' && apiKey !== 'tv') {
type = id || 'movie';
id = apiKey;
apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
}
}
if (!apiKey) apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
const key = `${id}-${type}`;
const cached = cacheGet(tmdbValidationCache, key);
if (cached !== undefined) return cached;
try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) });
if (res.ok) {
const data = await res.json();
const isValid = Boolean(data?.id && (data?.title || data?.name));
const result = { valid: isValid, error: isValid ? null : 'Invalid TMDB ID' };
cacheSet(tmdbValidationCache, key, result, 300000);
return result;
}
const result = { valid: false, error: `TMDB API error: ${res.status}` };
cacheSet(tmdbValidationCache, key, result, 60000);
return result;
} catch (error) {
const result = { valid: false, error: `Failed to validate TMDB ID: ${error.message}` };
cacheSet(tmdbValidationCache, key, result, 60000);
return result;
}
}
export async function imdbToTmdb(tmdbApiKey, imdbId, mediaType = 'movie') {
let apiKey = tmdbApiKey;
let id = imdbId;
let type = mediaType;
if (id === 'movie' || id === 'tv') {
type = id;
id = apiKey;
apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
}
if (!apiKey) apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
const key = `imdb-${id}`;
const cached = cacheGet(tmdbInfoCache, key);
if (cached !== undefined) return cached;
try {
const data = await fetchJson(`https://api.themoviedb.org/3/find/${id}?api_key=${apiKey}&external_source=imdb_id`, { signal: AbortSignal.timeout(5000) });
let result = null;
if (type === 'movie' && data.movie_results?.length) result = data.movie_results[0].id;
else if (type === 'tv' && data.tv_results?.length) result = data.tv_results[0].id;
if (result) cacheSet(tmdbInfoCache, key, result, 600000);
return result;
} catch {
return null;
}
}
export async function tmdbToAnilist(tmdbId, mediaType, season, titles = [], year = null) {
const key = `${tmdbId}-${mediaType}-${season || ''}`;
const cached = cacheGet(anilistCache, key);
if (cached !== undefined) return cached;
try {
const res = await fetch(`https://api.ani.zip/mappings?tmdb_id=${tmdbId}&type=${mediaType}&season=${season || 1}`, { signal: AbortSignal.timeout(6000) });
if (res.ok) {
const data = await res.json();
const id = data?.mappings?.[0]?.anilist_id;
if (id) {
cacheSet(anilistCache, key, id, 600000);
return id;
}
}
} catch { }
if (!titles.length) return null;
const query = `query ($s: String) { Page(page:1,perPage:10) { media(search:$s,type:ANIME) { id title { romaji english native } startDate { year } format } } }`;
let bestId = null;
let bestScore = -1;
for (const searchTitle of titles) {
try {
const res = await fetch('https://graphql.anilist.co', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ query, variables: { s: searchTitle } }),
signal: AbortSignal.timeout(6000)
});
if (!res.ok) continue;
const resJson = await res.json();
for (const entry of resJson?.data?.Page?.media || []) {
const entryTitles = [entry.title?.romaji, entry.title?.english, entry.title?.native].filter(Boolean).map(t => t.toLowerCase());
const sl = searchTitle.toLowerCase();
let score = 0;
if (entryTitles.some(t => t === sl)) score += 5;
else if (entryTitles.some(t => t.includes(sl) || sl.includes(t))) score += 3;
else if (entryTitles.some(t => {
const w = sl.split(/\s+/).filter(x => x.length > 3);
return w.length > 0 && w.every(x => t.includes(x));
})) score += 2;
else continue;
if (year && entry.startDate?.year) {
const diff = Math.abs(entry.startDate.year - year);
if (diff === 0) score += 3;
else if (diff === 1) score += 1;
else if (diff > 2) score -= 3;
}
if (mediaType === 'tv' && ['TV', 'TV_SHORT', 'ONA', 'OVA'].includes(entry.format)) score += 1;
if (mediaType === 'movie' && entry.format === 'MOVIE') score += 1;
if (score > bestScore) {
bestScore = score;
bestId = entry.id;
}
}
if (bestScore >= 8) break;
} catch { }
}
if (bestId) cacheSet(anilistCache, key, bestId, 600000);
return bestId;
}
export async function createStreamArgs(source, sdk, id, s, e, clientIP = null) {
const audio = /dub$/.test(source.key) ? 'dub' : 'sub';
return {
id,
s,
e,
clientIP,
absoluteBase: '/',
audio,
sdk,
config: source,
tmdbApiKey: resolveTmdbKey(null, sdk),
};
}
export function formatStreamResult(streams, defaultHeaders = {}, extra = {}) {
if (!streams) return null;
const list = Array.isArray(streams) ? streams.filter(Boolean) : [streams];
if (!list.length) return null;
const allUrls = list.map(item => {
const itemUrl = item.url || item.file || item.stream || item.src;
if (!itemUrl) return null;
return {
url: itemUrl,
server: item.server || item.label || item.name || 'Server',
quality: item.quality || 'Auto',
type: item.type || (itemUrl.includes('.m3u8') ? 'hls' : (itemUrl.includes('.mpd') ? 'dash' : 'mp4')),
headers: item.headers || defaultHeaders,
...(item.subtitles ? { subtitles: item.subtitles } : {}),
...(item.skipProxy !== undefined ? { skipProxy: item.skipProxy } : {}),
...(item.audio ? { audio: item.audio } : {}),
...(item.label ? { label: item.label } : {}),
};
}).filter(Boolean);
if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
server: allUrls[0].server,
quality: allUrls[0].quality,
type: allUrls[0].type,
allUrls,
...extra,
};
}
export async function scrapeVidcoreFamily({ id, s, e, baseUrl, apiName, serverLabel }) {
const isTv = Boolean(s && e);
const targetUrl = isTv
? `${baseUrl}/tv/${id}/${s}/${e}/`
: `${baseUrl}/movie/${id}`;
const ua = getUA();
const baseHeaders = {
'User-Agent': ua,
Referer: `${baseUrl}/`,
'X-Requested-With': 'XMLHttpRequest',
};
try {
const pageRes = await fetch(targetUrl, {
headers: { 'User-Agent': ua },
signal: AbortSignal.timeout(10000),
});
if (!pageRes.ok) return null;
const html = await pageRes.text();
const match = html.match(/\\"(?:en|token)\\":\\"(.*?)\\"/);
if (!match || !match[1]) return null;
const enToken = match[1];
const s1Res = await fetch(`https://enc-dec.app/api/enc-${apiName}?text=${encodeURIComponent(enToken)}&stage=1`, {
signal: AbortSignal.timeout(8000),
});
const s1Data = await s1Res.json();
if (s1Data?.status !== 200 || !s1Data?.result?.stage1) return null;
const token1 = s1Data.result.token;
const stage1Url = s1Data.result.stage1;
const post1Res = await fetch(stage1Url, {
method: 'POST',
headers: { ...baseHeaders, 'X-CSRF-Token': token1 },
signal: AbortSignal.timeout(10000),
});
if (!post1Res.ok) return null;
const stage1Text = await post1Res.text();
const s2Res = await fetch(`https://enc-dec.app/api/enc-${apiName}?text=${encodeURIComponent(stage1Text)}&stage=2`, {
signal: AbortSignal.timeout(8000),
});
const s2Data = await s2Res.json();
if (s2Data?.status !== 200 || !s2Data?.result?.servers) return null;
const { servers: serversUrl, stream: streamBaseUrl, token: token2 } = s2Data.result;
const currentHeaders = { ...baseHeaders, 'X-CSRF-Token': token2 };
const serversRes = await fetch(serversUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(10000),
});
if (!serversRes.ok) return null;
const serversEncrypted = await serversRes.text();
const decServersRes = await fetch(`https://enc-dec.app/api/dec-${apiName}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: serversEncrypted }),
signal: AbortSignal.timeout(8000),
});
const decServersData = await decServersRes.json();
if (decServersData?.status !== 200 || !Array.isArray(decServersData.result)) return null;
const allUrls = [];
for (const server of decServersData.result) {
if (!server?.data) continue;
try {
const streamUrl = `${streamBaseUrl}/${server.data}`;
const streamEncRes = await fetch(streamUrl, {
method: 'POST',
headers: currentHeaders,
signal: AbortSignal.timeout(8000),
});
if (!streamEncRes.ok) continue;
const streamEncText = await streamEncRes.text();
const decStreamRes = await fetch(`https://enc-dec.app/api/dec-${apiName}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: streamEncText }),
signal: AbortSignal.timeout(8000),
});
const decStreamData = await decStreamRes.json();
if (decStreamData?.status !== 200 || !decStreamData.result) continue;
const streamResult = decStreamData.result;
const resultUrl = typeof streamResult === 'string' ? streamResult : streamResult?.url || streamResult?.file;
if (typeof resultUrl === 'string' && resultUrl.startsWith('http')) {
allUrls.push({
url: resultUrl,
server: `${serverLabel} - ${server.name || server.title || 'Server'}`,
label: server.name || server.title || serverLabel,
type: resultUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: {
'User-Agent': ua,
Referer: `${baseUrl}/`,
},
});
}
} catch { }
}
return formatStreamResult(allUrls);
} catch {
return null;
}
}

View File

@@ -18,7 +18,7 @@ const CONFIG = {
TEST_SUBTITLE: false, TEST_SUBTITLE: false,
TEST_DOWNLOAD: false, TEST_DOWNLOAD: false,
TEST_MOVIE: true, TEST_MOVIE: true,
TEST_TV: true, TEST_TV: false,
TEST_MANGA: false, TEST_MANGA: false,
MANGA_QUERY: "Steel Ball Run", MANGA_QUERY: "Steel Ball Run",
@@ -32,7 +32,7 @@ dotenv.config({
}); });
// debug // debug
if (CONFIG.DEBUG) { if (CONFIG.DEBUG && !process.argv.includes("all")) {
const originalFetch = globalThis.fetch; const originalFetch = globalThis.fetch;
const debugFile = path.resolve("test/debug-output.json"); const debugFile = path.resolve("test/debug-output.json");
@@ -118,6 +118,45 @@ const sdk = new VylaSDK({
...CONFIG.EXTRA_SDK_PARAMS ...CONFIG.EXTRA_SDK_PARAMS
}); });
if (process.argv.includes("all")) {
const sources = sdk.getSources(true);
console.log(`Testing ${sources.length} sources in parallel...\n`);
const results = {};
const failed = [];
await Promise.all(
sources.map(async (cfg) => {
try {
const res = await sdk.probeSource(cfg.key);
results[cfg.key] = res;
if (res?.ok) {
console.log(`[PASS] ${cfg.key} (${res.ms}ms)`);
} else {
failed.push(cfg.key);
console.log(`[FAIL] ${cfg.key} (${res?.ms ?? 0}ms)`);
}
} catch (err) {
results[cfg.key] = { ok: false, ms: null, error: err.message };
failed.push(cfg.key);
console.log(`[FAIL] ${cfg.key} (${err.message})`);
}
})
);
console.log(`\nFinished testing. Total: ${sources.length}, Passed: ${sources.length - failed.length}, Failed: ${failed.length}`);
console.log("Sources that returned nothing:", failed);
const debugFile = path.resolve("test/debug-output.json");
fs.mkdirSync(path.dirname(debugFile), { recursive: true });
fs.writeFileSync(debugFile, JSON.stringify({
sourcesThatReturnedNothing: failed,
results
}, null, 2));
process.exit(0);
}
console.log("Starting..."); console.log("Starting...");
if (CONFIG.TEST_SUBTITLE && CONFIG.TEST_TV) { if (CONFIG.TEST_SUBTITLE && CONFIG.TEST_TV) {