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

@@ -30,7 +30,7 @@ export default class VylaSDK {
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(
@@ -55,7 +55,11 @@ export default class VylaSDK {
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') {
delete result.subtitles;
}
return result;
} }
async getSubtitles(id, s = null, e = null) { async getSubtitles(id, s = null, e = null) {
const paths = s != null && e != null const paths = s != null && e != null

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,7 +1,9 @@
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';
async function resolveSlug(id, s, e, titles) {
const keywords = []; const keywords = [];
for (const title of titles) { for (const title of titles) {
const t = title.toLowerCase().replace(/[^a-z0-9\s]/g, ' ').replace(/\s+/g, ' ').trim(); const t = title.toLowerCase().replace(/[^a-z0-9\s]/g, ' ').replace(/\s+/g, ' ').trim();
@@ -12,11 +14,21 @@ async function resolveSlug(id, s, e, info) {
if (!keywords.includes(short)) keywords.push(short); if (!keywords.includes(short)) keywords.push(short);
} }
} }
const slugCandidates = []; const slugCandidates = [];
for (const keyword of keywords) { for (const keyword of keywords) {
try { 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 data = await fetchJson(`${BASE_URL}/ajax/film/search?keyword=${encodeURIComponent(keyword)}&_=${Date.now()}`, {
let html = data.html || '', idx = 0; headers: {
'X-Requested-With': 'XMLHttpRequest',
Referer: `${BASE_URL}/`,
Accept: 'application/json',
'User-Agent': USER_AGENT,
},
signal: AbortSignal.timeout(8000),
});
let html = data.html || '';
let idx = 0;
while ((idx = html.indexOf('href="/anime/', idx)) !== -1) { while ((idx = html.indexOf('href="/anime/', idx)) !== -1) {
const start = idx + 13; const start = idx + 13;
const end = html.indexOf('"', start); const end = html.indexOf('"', start);
@@ -27,31 +39,83 @@ async function resolveSlug(id, s, e, info) {
} catch { } } catch { }
if (slugCandidates.length) break; if (slugCandidates.length) break;
} }
for (const slug of slugCandidates) { for (const slug of slugCandidates) {
try { try {
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) }); const data = await fetchJson(`${BASE_URL}/ajax/episode/info?epr=${encodeURIComponent(s ? `${slug}/${s}/${e}` : `${slug}/1`)}&ts=1&_=${Date.now()}`, {
headers: {
Referer: `${BASE_URL}/anime/${slug}`,
'X-Requested-With': 'XMLHttpRequest',
Accept: 'application/json, text/javascript, */*; q=0.01',
'User-Agent': USER_AGENT,
},
signal: AbortSignal.timeout(10000),
});
if (data?.target) return data.target; if (data?.target) return data.target;
} catch { } } catch { }
} }
return null; return null;
} }
export async function getStream({ id, s, e }) { export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
if (!s) return null; if (!s) return null;
const info = await getTmdbInfo(id, 'tv', s);
if (!info.isAnime) return null; const apiKey = resolveTmdbKey(args, sdk);
const target = await resolveSlug(id, s, e, info); 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; if (!target) return null;
const embedMatch = target.match(/\/embed-[^/]+\/([A-Za-z0-9+/=]+)$/); const embedMatch = target.match(/\/embed-[^/]+\/([A-Za-z0-9+/=]+)$/);
if (!embedMatch) return null; if (!embedMatch) return null;
const origin = new URL(target).origin; const origin = new URL(target).origin;
try { try {
const embedRes = await fetch(target, { headers: { 'User-Agent': USER_AGENT }, signal: AbortSignal.timeout(10000) }); const embedRes = await fetch(target, {
headers: { 'User-Agent': USER_AGENT },
signal: AbortSignal.timeout(10000),
});
if (!embedRes.ok) return null; if (!embedRes.ok) return null;
const setCookie = embedRes.headers.get('set-cookie'); 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 data = await fetchJson(`${origin}/hs/getSources?id=${embedMatch[1]}`, {
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); headers: {
if (src) return { url: src, headers: { 'Referer': 'https://play2.echovideo.ru/', 'Origin': 'https://play2.echovideo.ru' } }; Referer: target,
} catch { } Accept: '*/*',
return null; '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,6 +1,7 @@
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 { id, s, e } = args || {};
const isTv = s != null && e != null; const isTv = s != null && e != null;
const allUrls = []; const allUrls = [];
@@ -17,10 +18,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `TheMovieBox - ${item.server || item.provider || 'Server'}`, server: `TheMovieBox - ${item.server || item.provider || 'Server'}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://themoviebox.uk/', Referer: 'https://themoviebox.uk/',
Origin: 'https://themoviebox.uk' Origin: 'https://themoviebox.uk',
} },
}); });
} }
} }
@@ -39,10 +42,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `CineBros - ${item.name || item.quality || 'Server'}`, server: `CineBros - ${item.name || item.quality || 'Server'}`,
quality: item.quality || 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: item.headers || { headers: item.headers || {
Referer: 'https://pro2.nabilekson.workers.dev/', Referer: 'https://pro2.nabilekson.workers.dev/',
Origin: 'https://pro2.nabilekson.workers.dev' Origin: 'https://pro2.nabilekson.workers.dev',
} },
}); });
} }
} }
@@ -61,10 +66,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `Praxi - ${item.name || item.providerName || 'Server'}`, server: `Praxi - ${item.name || item.providerName || 'Server'}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: item.headers || { headers: item.headers || {
Referer: 'https://praxi.nabilekson.workers.dev/', Referer: 'https://praxi.nabilekson.workers.dev/',
Origin: 'https://praxi.nabilekson.workers.dev' Origin: 'https://praxi.nabilekson.workers.dev',
} },
}); });
} }
} }
@@ -83,15 +90,17 @@ export async function getStream({ id, s, e }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `FreakyNiki - ${item.server || item.provider || 'Server'}`, server: `FreakyNiki - ${item.server || item.provider || 'Server'}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: { headers: {
Referer: 'https://freakyniki.elaxo.lol/', Referer: 'https://freakyniki.elaxo.lol/',
Origin: 'https://freakyniki.elaxo.lol' Origin: 'https://freakyniki.elaxo.lol',
} },
}); });
} }
} }
} }
} },
]; ];
await Promise.allSettled(endpoints.map(fn => fn().catch(() => { }))); await Promise.allSettled(endpoints.map(fn => fn().catch(() => { })));
@@ -101,6 +110,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,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,26 +1,49 @@
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,
Origin: ORIGIN,
Referer: `${ORIGIN}/`,
};
export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
const apiKey = resolveTmdbKey(args, sdk);
if (!apiKey) return null;
export async function getStream({ id, s, e, sdk }) {
const tmdbApiKey = sdk?.tmdbApiKey || null;
if (!tmdbApiKey) return null;
try { try {
const isTv = s != null && e != null; const meta = await getTmdbMetadata(id, isTv, apiKey);
const info = await getTmdbInfo(tmdbApiKey, id, isTv ? 'tv' : 'movie'); if (!meta?.titles?.length) return null;
if (!info?.titles?.length) return null;
const searchHtml = await fetchText(`${ORIGIN}/?s=${encodeURIComponent(info.titles[0] + (info.year ? ' ' + info.year : ''))}`, { headers: HEADERS }); const query = meta.titles[0] + (meta.year ? ` ${meta.year}` : '');
const searchHtml = await fetchText(`${ORIGIN}/?s=${encodeURIComponent(query)}`, { headers: HEADERS });
const typeFolder = isTv ? 'seriale' : 'film'; const typeFolder = isTv ? 'seriale' : 'film';
const linkMatch = searchHtml.match(new RegExp(`href=["'](https?://www3\\.fsonline\\.app/${typeFolder}/([^"'/]+)/)["']`, 'i')); const linkMatch = searchHtml.match(new RegExp(`href=["'](https?://www3\\.fsonline\\.app/${typeFolder}/([^"'/]+)/)["']`, 'i'));
if (!linkMatch) return null; if (!linkMatch) return null;
const targetPageUrl = isTv ? `${ORIGIN}/episoade/${linkMatch[2].replace(/-\d{4}$/, '')}-sezonul-${s}-episodul-${e}/` : linkMatch[1];
const targetPageUrl = isTv
? `${ORIGIN}/episoade/${linkMatch[2].replace(/-\d{4}$/, '')}-sezonul-${s}-episodul-${e}/`
: linkMatch[1];
const pageHtml = await fetchText(targetPageUrl, { headers: HEADERS }); const pageHtml = await fetchText(targetPageUrl, { headers: HEADERS });
const movieId = (pageHtml.match(/movie-id=['"]([^'"]+)['"]/) || pageHtml.match(/movie-id=([^ >]+)/))?.[1]; const movieId = (pageHtml.match(/movie-id=['"]([^'"]+)['"]/) || pageHtml.match(/movie-id=([^ >]+)/))?.[1];
if (!movieId) return null; if (!movieId) return null;
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 results = []; 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 allUrls = [];
let idx = 0; let idx = 0;
while ((idx = ajaxHtml.indexOf('data-vs="', idx)) !== -1) { while ((idx = ajaxHtml.indexOf('data-vs="', idx)) !== -1) {
const embedStart = idx + 9; const embedStart = idx + 9;
@@ -29,20 +52,45 @@ export async function getStream({ id, s, e, sdk }) {
const spanStart = ajaxHtml.indexOf('<span>', embedEnd); const spanStart = ajaxHtml.indexOf('<span>', embedEnd);
const spanEnd = ajaxHtml.indexOf('</span>', spanStart); const spanEnd = ajaxHtml.indexOf('</span>', spanStart);
const serverLabel = ajaxHtml.slice(spanStart + 6, spanEnd).trim().toLowerCase(); const serverLabel = ajaxHtml.slice(spanStart + 6, spanEnd).trim().toLowerCase();
if (serverLabel.includes('filesun')) { if (serverLabel.includes('filesun')) {
try { try {
const rHtml = await fetchText(embedUrl, { headers: { 'Referer': ORIGIN, 'User-Agent': USER_AGENT } }); 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 m3u8Match = rHtml.match(/file:\s*["'](https?:\/\/[^"']+\.m3u8[^"']*)["']/) || rHtml.match(/["']?file["']?:\s*["'](https?:\/\/[^"']+)["']/);
if (m3u8Match) results.push({ url: m3u8Match[1].replace(/\\\//g, '/'), server: 'FSOnline - FileSuN', headers: { 'Referer': embedUrl, 'Origin': 'https://player.fsonline.app', 'User-Agent': USER_AGENT } }); 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 { } } catch { }
} }
idx = spanEnd; idx = spanEnd;
} }
return results.length ? { allUrls: results } : null;
} catch { return null; } if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch {
return null;
}
} }
export async function getSources(args) { export async function getSources(args) {
const res = await getStream(args); const stream = await getStream(args);
return res?.allUrls ? [...new Set(res.allUrls.map(u => u.server))] : []; 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,28 +1,38 @@
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 BASE = "https://kisskh.do";
const HEADERS = { 'User-Agent': USER_AGENT, Accept: 'application/json' }; const HEADERS = { 'User-Agent': USER_AGENT, Accept: 'application/json' };
function cleanTitle(t) { return t ? t.toLowerCase().replace(/\(\d{4}\)/g, '').replace(/[^a-z0-9]/g, '') : ''; }
async function encKey(episodeId, type) { async function encKey(episodeId, type) {
try { try {
const data = await fetchJson(`${ENC_API}/enc-kisskh?text=${episodeId}&type=${type}`, { signal: AbortSignal.timeout(6000) }); const data = await fetchJson(`${ENC_API}/enc-kisskh?text=${episodeId}&type=${type}`, { signal: AbortSignal.timeout(6000) });
return data?.status === 200 ? data.result : null; return data?.status === 200 ? data.result : null;
} catch { return null; } } catch {
return null;
}
} }
export async function getStream({ id, s, e }) { export async function getStream(args) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
const apiKey = resolveTmdbKey(args, sdk);
try { try {
const info = await getTmdbInfo(id, s ? 'tv' : 'movie', s); const meta = await getTmdbMetadata(id, isTv, apiKey);
if (!info) return null; if (!meta?.titles?.length) return null;
let drama = null, bestScore = -1;
for (const title of (info.titles.length > 1 ? [...info.titles].reverse() : info.titles)) { let drama = null;
const results = await fetchJson(`${BASE}/api/DramaList/Search?q=${encodeURIComponent(title)}`, { headers: HEADERS, signal: AbortSignal.timeout(6000) }).catch(() => []); let bestScore = -1;
const searchTitles = meta.titles.length > 1 ? [...meta.titles].reverse() : meta.titles;
for (const title of searchTitles) {
const results = await fetchJson(`${BASE_URL}/api/DramaList/Search?q=${encodeURIComponent(title)}`, {
headers: HEADERS,
signal: AbortSignal.timeout(6000),
}).catch(() => []);
const targetClean = cleanTitle(title); const targetClean = cleanTitle(title);
for (const item of results) { for (const item of results) {
const parts = (item.title || '').split(/\s*-\s*/).map(cleanTitle); const parts = (item.title || '').split(/\s*-\s*/).map(cleanTitle);
@@ -30,31 +40,76 @@ export async function getStream({ id, s, e }) {
if (parts.some(p => p === targetClean)) score += 5; if (parts.some(p => p === targetClean)) score += 5;
else if (parts.some(p => p.includes(targetClean) || targetClean.includes(p))) score += 3; else if (parts.some(p => p.includes(targetClean) || targetClean.includes(p))) score += 3;
else continue; else continue;
if (score > bestScore) { bestScore = score; drama = item; } if (score > bestScore) {
bestScore = score;
drama = item;
}
} }
if (drama && bestScore >= 5) break; if (drama && bestScore >= 5) break;
} }
if (!drama) return null; if (!drama) return null;
const detail = await fetchJson(`${BASE}/api/DramaList/Drama/${drama.id}`, { headers: HEADERS, signal: AbortSignal.timeout(8000) });
const detail = await fetchJson(`${BASE_URL}/api/DramaList/Drama/${drama.id}`, {
headers: HEADERS,
signal: AbortSignal.timeout(8000),
});
const episodeId = detail?.episodes?.find(ep => Math.floor(ep.number) === Number(e || 1))?.id; const episodeId = detail?.episodes?.find(ep => Math.floor(ep.number) === Number(e || 1))?.id;
if (!episodeId) return null; if (!episodeId) return null;
const vidKey = await encKey(episodeId, 'vid'); const vidKey = await encKey(episodeId, 'vid');
if (!vidKey) return null; if (!vidKey) return null;
const videoData = await fetchJson(`${BASE}/api/DramaList/Episode/${episodeId}.png?err=false&ts=&time=&kkey=${vidKey}`, { headers: HEADERS, signal: AbortSignal.timeout(10000) });
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; if (!videoData?.Video) return null;
let subtitles = []; let subtitles = [];
const subKey = await encKey(episodeId, 'sub'); const subKey = await encKey(episodeId, 'sub');
if (subKey) { if (subKey) {
try { try {
const subList = await fetchJson(`${BASE}/api/Sub/${episodeId}?kkey=${subKey}`, { headers: HEADERS, signal: AbortSignal.timeout(8000) }); const subList = await fetchJson(`${BASE_URL}/api/Sub/${episodeId}?kkey=${subKey}`, {
if (Array.isArray(subList)) subtitles = subList.map(sub => ({ url: sub.src, label: sub.label, lang: sub.land, default: !!sub.default })); 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 { } } catch { }
} }
return { allUrls: [{ url: videoData.Video, type: videoData.Video.includes('.m3u8') ? 'hls' : 'mp4', audio: 'sub', server: 'KissKH', skipProxy: false, subtitles }] };
} catch { return null; } 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) { export async function getSources(args) {
const stream = await getStream(args); const stream = await getStream(args);
return stream?.allUrls ? [...new Set(stream.allUrls.map(u => u.server))] : []; 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

@@ -2,6 +2,7 @@ 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) { async function searchLookMovie(type, title, year, clientIP) {

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,35 +1,24 @@
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;
if (!key) return null;
try {
const url = s != null && e != null
? `https://api.themoviedb.org/3/tv/${tmdbId}/external_ids?api_key=${key}`
: `https://api.themoviedb.org/3/movie/${tmdbId}?api_key=${key}`;
const res = await fetchJson(url);
return res?.imdb_id || null;
} catch { return null; }
}
export async function getStream({ id, s, e, sdk }) {
const tmdbApiKey = sdk?.tmdbApiKey || null;
const manifest = sdk?.penguManifest || null; const manifest = sdk?.penguManifest || null;
if (!tmdbApiKey || !manifest || (manifest && !manifest.endsWith('manifest.json'))) return null;
const BASE_URL = manifest ? manifest.split('/manifest.json')[0] : null; if (!apiKey || !manifest || !manifest.endsWith('manifest.json')) return null;
if (!BASE_URL) return null; const baseUrl = manifest.split('/manifest.json')[0];
if (!baseUrl) return null;
try { try {
const imdbId = await getImdbId(tmdbApiKey, id, s, e); const imdbId = await resolveImdbId(id, isTv, apiKey);
if (!imdbId) return null; if (!imdbId) return null;
const path = s != null && e != null const path = isTv
? `/stream/series/${imdbId}:${s}:${e}.json` ? `/stream/series/${imdbId}:${s}:${e}.json`
: `/stream/movie/${imdbId}.json`; : `/stream/movie/${imdbId}.json`;
const res = await fetchJson(`${BASE_URL}${path}`); const res = await fetchJson(`${baseUrl}${path}`);
if (!res?.streams?.length) return null; if (!res?.streams?.length) return null;
const allUrls = res.streams.map(stream => { const allUrls = res.streams.map(stream => {
@@ -38,12 +27,20 @@ export async function getStream({ id, s, e, sdk }) {
return { return {
url: stream.url, url: stream.url,
server: `Pengu - ${stream.name || 'Server'}`, server: `Pengu - ${stream.name || 'Server'}`,
quality: 'Auto',
type: stream.url.includes('.m3u8') ? 'hls' : 'mp4',
headers: Object.keys(headers).length > 0 ? headers : undefined, headers: Object.keys(headers).length > 0 ? headers : undefined,
skipProxy: stream.behaviorHints?.notWebReady === false skipProxy: stream.behaviorHints?.notWebReady === false,
}; };
}).filter(Boolean); }).filter(Boolean);
return allUrls.length ? { allUrls } : null; if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch { } catch {
return null; 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,57 +1,51 @@
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) {
const { id, s, e, sdk } = args || {};
const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
const apiKey = resolveTmdbKey(args, sdk);
try { try {
const isTv = s != null; const meta = await getTmdbMetadata(id, isTv, apiKey);
if (!meta?.titles?.length) return null;
const info = await getTmdbInfo(id, isTv ? 'tv' : 'movie');
if (!info?.titles?.length) {
return null;
}
const title = info.titles[0];
const title = meta.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, { const searchData = await fetchJson(searchUrl, {
headers: HEADERS, headers: HEADERS,
signal: AbortSignal.timeout(10000) signal: AbortSignal.timeout(10000),
}); });
const items = searchData?.data?.items?.movies?.items || []; const items = searchData?.data?.items?.movies?.items || [];
const type = isTv ? 'tv' : 'movie';
const lowerTitle = title.toLowerCase(); const lowerTitle = title.toLowerCase();
let match = items.find(item => let match = items.find(item =>
item.type === type && item.type === type &&
item.title?.toLowerCase() === lowerTitle && item.title?.toLowerCase() === lowerTitle &&
(!info.year || item.release_date?.startsWith(String(info.year))) (!meta.year || item.release_date?.startsWith(String(meta.year)))
); );
if (!match) { if (!match) {
match = items.find(item => item.type === type); match = items.find(item => item.type === type);
} }
if (!match?.id) { if (!match?.id) return null;
return null;
}
const streamUrl = isTv const streamUrl = isTv
? `${API_BASE}/stream/${match.id}/episode?season=${s}&episode=${e}` ? `${API_BASE}/stream/${match.id}/episode?season=${s}&episode=${e}`
@@ -59,46 +53,44 @@ export async function getStream({ id, s, e }) {
const json = await fetchJson(streamUrl, { const json = await fetchJson(streamUrl, {
headers: HEADERS, headers: HEADERS,
signal: AbortSignal.timeout(10000) signal: AbortSignal.timeout(10000),
}); });
const sources = json?.data?.items?.sources; const sources = json?.data?.items?.sources;
if (json?.type !== 'success' || !Array.isArray(sources) || !sources.length) return null;
if (json?.type !== 'success' || !Array.isArray(sources) || !sources.length) {
return null;
}
const chosen = sources.find(src => src.stream_url); const chosen = sources.find(src => src.stream_url);
if (!chosen?.stream_url) return null;
if (!chosen?.stream_url) { const streamHeaders = {
return null; 'User-Agent': USER_AGENT,
} Referer: `${DOMAIN}/`,
};
const result = { const allUrls = [{
url: chosen.stream_url, url: chosen.stream_url,
headers: { headers: streamHeaders,
'User-Agent': USER_AGENT,
'Referer': `${DOMAIN}/`
},
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,
}];
return {
url: chosen.stream_url,
headers: streamHeaders,
server: 'purstream',
quality: chosen.source_name || 'Auto',
type: chosen.format || 'hls',
skipProxy: true,
allUrls,
}; };
} catch {
return result;
} catch (err) {
return null; return null;
} }
} }
export async function getSources(args) { export async function getSources(args) {
const stream = await getStream(args); const stream = await getStream(args);
return stream?.allUrls ? stream.allUrls.map(u => u.server) : ['purstream'];
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

@@ -5,8 +5,8 @@ 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()) {
@@ -25,21 +25,22 @@ function extractStreamUrls(obj, urls = new Set()) {
return urls; return urls;
} }
export async function getStream({ id, s, e }) { export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
const url = `${API_BASE}?tmdb=${id}&type=${type}${isTv ? `&season=${s}&episode=${e}` : ''}`;
try { try {
const isTv = s != null && e != null;
const type = isTv ? 'tv' : 'movie';
const url = `${API_BASE}?tmdb=${id}&type=${type}${isTv ? `&season=${s}&episode=${e}` : ''}`;
const data = await fetchJson(url, { const data = await fetchJson(url, {
headers: { headers: {
'Accept': '*/*', Accept: '*/*',
'Origin': EMBED_ORIGIN, Origin: EMBED_ORIGIN,
'Referer': `${EMBED_ORIGIN}/`, Referer: `${EMBED_ORIGIN}/`,
'User-Agent': USER_AGENT 'User-Agent': USER_AGENT,
}, },
signal: AbortSignal.timeout(10000) signal: AbortSignal.timeout(10000),
}); });
const streamUrls = Array.from(extractStreamUrls(data)); const streamUrls = Array.from(extractStreamUrls(data));
@@ -54,8 +55,8 @@ export async function getStream({ id, s, e }) {
const subtitles = subs.map(sub => ({ const subtitles = subs.map(sub => ({
url: sub.url || sub.file || sub.src, url: sub.url || sub.file || sub.src,
lang: sub.display || sub.label || sub.language || sub.lang || 'Unknown' lang: sub.display || sub.label || sub.language || sub.lang || 'Unknown',
})).filter(s => s.url); })).filter(subItem => subItem.url);
const allUrls = streamUrls.map(streamUrl => { const allUrls = streamUrls.map(streamUrl => {
let type = 'mp4'; let type = 'mp4';
@@ -69,11 +70,18 @@ export async function getStream({ id, s, e }) {
type, type,
headers: VERIFY_HEADERS, headers: VERIFY_HEADERS,
subtitles: subtitles.length > 0 ? subtitles : undefined, subtitles: subtitles.length > 0 ? subtitles : undefined,
skipProxy: false skipProxy: false,
}; };
}); });
return allUrls.length ? { allUrls } : null; if (!allUrls.length) return null;
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
...(subtitles.length > 0 ? { subtitles } : {}),
};
} catch { } catch {
return null; return null;
} }

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,22 +1,23 @@
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(args) {
const { id, s, e } = args || {};
export async function getStream({ id, s, e }) {
try { try {
const encData = await fetchJson(`https://enc-dec.app/api/enc-vidlink?text=${id}`, { signal: AbortSignal.timeout(6000) }); 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; if (encData?.status !== 200 || !encData?.result) return null;
const basePath = s ? `${BASE}/api/b/tv/${encData.result}/${s}/${e || 1}` : `${BASE}/api/b/movie/${encData.result}`; const basePath = s ? `${BASE_URL}/api/b/tv/${encData.result}/${s}/${e || 1}` : `${BASE_URL}/api/b/movie/${encData.result}`;
const responses = await Promise.allSettled([ const responses = await Promise.allSettled([
fetchJson(basePath, { headers: HEADERS, signal: AbortSignal.timeout(10000) }), fetchJson(basePath, { headers: HEADERS, signal: AbortSignal.timeout(10000) }),
fetchJson(`${basePath}?multiLang=0`, { headers: HEADERS, signal: AbortSignal.timeout(10000) }) fetchJson(`${basePath}?multiLang=0`, { headers: HEADERS, signal: AbortSignal.timeout(10000) }),
]); ]);
const streamList = []; const streamList = [];
const seenUrls = new Set(); const seenUrls = new Set();
const seenSubs = new Set();
for (const res of responses) { for (const res of responses) {
if (res.status !== 'fulfilled' || !res.value?.stream) continue; if (res.status !== 'fulfilled' || !res.value?.stream) continue;
@@ -30,9 +31,9 @@ export async function getStream({ id, s, e }) {
quality: stream.playbackMetadata?.resolutions?.[0] ? `${stream.playbackMetadata.resolutions[0]}p` : 'Auto', quality: stream.playbackMetadata?.resolutions?.[0] ? `${stream.playbackMetadata.resolutions[0]}p` : 'Auto',
label: `Vidlink ${isDash ? 'DASH' : 'HLS'}`, label: `Vidlink ${isDash ? 'DASH' : 'HLS'}`,
name: `Vidlink ${isDash ? 'DASH' : 'HLS'}`, name: `Vidlink ${isDash ? 'DASH' : 'HLS'}`,
server: 'Vidlink',
type: isDash ? 'dash' : 'hls', type: isDash ? 'dash' : 'hls',
headers: stream.playlistHeaders || {}, headers: stream.playlistHeaders || {},
server: 'Vidlink',
}); });
} }
@@ -51,9 +52,9 @@ export async function getStream({ id, s, e }) {
quality: `${q}p`, quality: `${q}p`,
label: `Vidlink ${q}p`, label: `Vidlink ${q}p`,
name: `Vidlink ${q}p`, name: `Vidlink ${q}p`,
server: 'Vidlink',
type: qData.type || 'mp4', type: qData.type || 'mp4',
headers: qData.headers || {}, headers: qData.headers || {},
server: 'Vidlink',
}); });
} }
} }
@@ -62,6 +63,8 @@ export async function getStream({ id, s, e }) {
if (!streamList.length) return null; if (!streamList.length) return null;
return { return {
url: streamList[0].url,
headers: streamList[0].headers,
allUrls: streamList, allUrls: streamList,
streams: streamList, streams: streamList,
}; };

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({ 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: 'vidup',
'User-Agent': ua, serverLabel: 'VidUp',
'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;

View File

@@ -1,4 +1,4 @@
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';
@@ -19,7 +19,7 @@ async function getWasmInstance() {
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 });
@@ -39,9 +39,9 @@ async function getWasmInstance() {
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);
} else if (count) { exports.__unpin(ptr);
} else if (count > 1) {
refMap.set(ptr, count - 1); refMap.set(ptr, count - 1);
} }
} }
@@ -82,7 +82,7 @@ async function getWasmInstance() {
} finally { } finally {
unpin(dataPtr); unpin(dataPtr);
} }
} },
}; };
return wasmInstanceCache; return wasmInstanceCache;
} catch { } catch {
@@ -94,7 +94,7 @@ 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;
@@ -136,26 +136,26 @@ async function resolveServiceStream(service, isMovie, id, s, e, headers) {
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;
@@ -176,7 +176,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,13 +1,12 @@
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) {
@@ -20,9 +19,12 @@ function extract(regex, text) {
return val; return val;
} }
export async function getStream({ id, s, e, absoluteBase }) { export async function getStream(args) {
const { id, s, e, absoluteBase } = args || {};
const isTv = s != null && e != null;
try { try {
const apiUrl = s && e const apiUrl = isTv
? `${BASE_URL}/api/tv/${id}/${s}/${e}` ? `${BASE_URL}/api/tv/${id}/${s}/${e}`
: `${BASE_URL}/api/movie/${id}`; : `${BASE_URL}/api/movie/${id}`;
@@ -59,7 +61,7 @@ export async function getStream({ id, s, e, absoluteBase }) {
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(rawMasterUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify({ ...HEADERS, Referer: embedUrl }))}` ? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(rawMasterUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify({ ...HEADERS, Referer: embedUrl }))}`
: rawMasterUrl; : rawMasterUrl;
const playlistText = await fetchText(masterProxy, { headers: { ...HEADERS, 'Referer': embedUrl } }).catch(() => null); const playlistText = await fetchText(masterProxy, { headers: { ...HEADERS, Referer: embedUrl } }).catch(() => null);
if (!playlistText?.includes('#EXTM3U')) return null; if (!playlistText?.includes('#EXTM3U')) return null;
const lines = playlistText.split('\n'); const lines = playlistText.split('\n');
@@ -88,27 +90,35 @@ export async function getStream({ id, s, e, absoluteBase }) {
allUrls.push({ allUrls.push({
url: streamUrl, url: streamUrl,
server: `VixSrc (${track.name})`, server: `VixSrc (${track.name})`,
quality: 'Auto',
type: 'hls',
skipProxy: true, skipProxy: true,
headers: { headers: {
...HEADERS, ...HEADERS,
'Referer': `${BASE_URL}/` Referer: `${BASE_URL}/`,
} },
}); });
} }
} else { } else {
allUrls.push({ allUrls.push({
url: rawMasterUrl, url: rawMasterUrl,
server: 'VixSrc', server: 'VixSrc',
quality: 'Auto',
type: 'hls',
skipProxy: true, skipProxy: true,
headers: { headers: {
...HEADERS, ...HEADERS,
'Referer': `${BASE_URL}/` Referer: `${BASE_URL}/`,
} },
}); });
} }
return { allUrls }; return {
} catch (err) { url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls,
};
} catch {
return null; 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'; const targetType = isTv ? 'tv' : 'movie';
const apiKey = resolveTmdbKey(args, sdk);
const meta = await getTmdbMetadata(id, isTv, apiKey);
const title = meta?.title;
const query = title || String(id);
try { try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, { const searchRes = await fetch(`${BASE_URL}/api/mobile/search`, {
signal: AbortSignal.timeout(6000), method: 'POST',
headers: HEADERS,
body: JSON.stringify({ query }),
signal: AbortSignal.timeout(8000),
}); });
if (!res.ok) return null;
const data = await res.json(); if (!searchRes.ok) return null;
return isTv ? data.name : data.title; const searchJson = await searchRes.json();
const resultsObj = searchJson?.results;
if (!resultsObj) return null;
const items = resultsObj.all || (targetType === 'tv' ? resultsObj.tvs : resultsObj.movies) || [];
if (!Array.isArray(items) || items.length === 0) return null;
const cleanSearchTitle = query.toLowerCase().replace(/[^a-z0-9]/g, '');
let matchedItem = null;
for (const item of items) {
const itemType = String(item?.type || '').toLowerCase();
if (itemType && itemType !== targetType) continue;
const itemTitle = String(item?.title || '');
const cleanItemTitle = itemTitle.toLowerCase().replace(/[^a-z0-9]/g, '');
if (cleanItemTitle === cleanSearchTitle || cleanItemTitle.includes(cleanSearchTitle)) {
matchedItem = item;
break;
}
}
if (!matchedItem) {
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}`,
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 { } catch {
return null; return null;
} }
} }
export async function getStream({ id, s, e, sdk }) {
const isTv = Boolean(s && e);
const targetType = isTv ? 'tv' : 'movie';
const title = await resolveTitle(sdk, id, isTv);
const query = title || String(id);
const searchRes = await fetch(`${BASE_URL}/api/mobile/search`, {
method: 'POST',
headers: HEADERS,
body: JSON.stringify({ query }),
signal: AbortSignal.timeout(8000),
});
if (!searchRes.ok) return null;
const searchJson = await searchRes.json();
const resultsObj = searchJson?.results;
if (!resultsObj) return null;
const items = resultsObj.all || (targetType === 'tv' ? resultsObj.tvs : resultsObj.movies) || [];
if (!Array.isArray(items) || items.length === 0) return null;
const cleanSearchTitle = query.toLowerCase().replace(/[^a-z0-9]/g, '');
let matchedItem = null;
for (const item of items) {
const itemType = String(item?.type || '').toLowerCase();
if (itemType && itemType !== targetType) continue;
const itemTitle = String(item?.title || '');
const cleanItemTitle = itemTitle.toLowerCase().replace(/[^a-z0-9]/g, '');
if (cleanItemTitle === cleanSearchTitle || cleanItemTitle.includes(cleanSearchTitle)) {
matchedItem = item;
break;
}
}
if (!matchedItem) {
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 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}`,
headers: {
'User-Agent': HEADERS['User-Agent'],
},
});
}
}
}
}
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,4 +1,4 @@
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',
@@ -6,23 +6,6 @@ const SUBTITLE_BASES = [
'https://opensubtitles-v3.strem.io' 'https://opensubtitles-v3.strem.io'
]; ];
async function resolveImdbId(id, isTv) {
if (typeof id === 'string' && id.startsWith('tt')) return id;
const apiKey = process.env.TMDB_API_KEY;
if (!apiKey) return `tt${id}`;
const type = isTv ? 'tv' : 'movie';
try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`, {
signal: AbortSignal.timeout(5000),
});
if (!res.ok) return `tt${id}`;
const data = await res.json();
return data.imdb_id || data.external_ids?.imdb_id || `tt${id}`;
} catch {
return `tt${id}`;
}
}
export async function fetchSubtitles(paths = []) { export async function fetchSubtitles(paths = []) {
try { try {
const results = await Promise.all( const results = await Promise.all(

View File

@@ -10,8 +10,101 @@ export const UA_LIST = [
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];
const DEFAULT_TMDB_KEY = '45dbdd5e714da212424bda0336167447';
let sharedDcKey = null; let sharedDcKey = null;
const tmdbInfoCache = new Map();
const anilistCache = new Map();
const tmdbValidationCache = new Map();
const tmdbMetaCache = new Map();
function pruneCache(cache) {
const now = Date.now();
for (const [k, v] of cache) {
if (now - v.ts >= v.ttl) cache.delete(k);
}
if (cache.size > 3000) {
const overflow = cache.size - 3000;
const it = cache.keys();
for (let i = 0; i < overflow; i++) cache.delete(it.next().value);
}
}
setInterval(() => {
pruneCache(tmdbValidationCache);
pruneCache(tmdbInfoCache);
pruneCache(anilistCache);
pruneCache(tmdbMetaCache);
}, 60000).unref();
function cacheGet(cache, key) {
const entry = cache.get(key);
if (!entry) return undefined;
if (Date.now() - entry.ts >= entry.ttl) {
cache.delete(key);
return undefined;
}
return entry.val;
}
function cacheSet(cache, key, val, ttl) {
cache.set(key, { val, ts: Date.now(), ttl });
}
export function resolveTmdbKey(args = {}, sdk = null) {
return (
args?.tmdbApiKey ||
args?.sdk?.tmdbApiKey ||
sdk?.tmdbApiKey ||
process.env.TMDB_API_KEY ||
DEFAULT_TMDB_KEY
);
}
export function slugify(text) {
if (!text) return '';
return String(text)
.toLowerCase()
.normalize('NFKD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '');
}
export function cleanTitle(text) {
if (!text) return '';
return String(text)
.toLowerCase()
.replace(/\(\d{4}\)/g, '')
.replace(/[^a-z0-9]/g, '')
.trim();
}
export 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]}`;
}
export function getRandomHex(size = 32) {
return crypto.randomBytes(size).toString('hex');
}
export async function fetchJson(url, options = {}) {
const res = await fetch(url, options);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
export async function fetchText(url, options = {}) {
const res = await fetch(url, options);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.text();
}
export function decryptPartner(responseText, keyEnv) { export function decryptPartner(responseText, keyEnv) {
try { try {
const sep = responseText.indexOf(':'); const sep = responseText.indexOf(':');
@@ -26,75 +119,170 @@ export function decryptPartner(responseText, keyEnv) {
} }
} }
export async function fetchJson(url, options) { export async function getTmdbMetadata(id, isTv, apiKey = null) {
const res = await fetch(url, options); const key = apiKey || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
export async function fetchText(url, options) {
const res = await fetch(url, options);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.text();
}
const tmdbInfoCache = new Map();
const anilistCache = new Map();
const tmdbValidationCache = new Map();
function pruneHelperCache(cache) {
const now = Date.now();
for (const [k, v] of cache) if (now - v.ts >= v.ttl) cache.delete(k);
if (cache.size > 3000) {
const overflow = cache.size - 3000;
const it = cache.keys();
for (let i = 0; i < overflow; i++) cache.delete(it.next().value);
}
}
export async function resolveImdbId(id, isTv, tmdbApiKey) {
if (typeof id === 'string' && id.startsWith('tt')) return id;
const apiKey = tmdbApiKey || process.env.TMDB_API_KEY;
if (!apiKey) return `tt${id}`;
const type = isTv ? 'tv' : 'movie'; const type = isTv ? 'tv' : 'movie';
const cacheKey = `${id}-${type}-${key}`;
const cached = cacheGet(tmdbMetaCache, cacheKey);
if (cached !== undefined) return cached;
const fallback = {
title: '',
originalTitle: '',
titles: [],
year: null,
releaseDate: '',
imdbId: null,
isAnime: false,
runtime: 0,
seasons: [],
};
try { try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}&append_to_response=external_ids`, { const url = `https://api.themoviedb.org/3/${type}/${id}?api_key=${key}&append_to_response=external_ids,alternative_titles`;
signal: AbortSignal.timeout(5000), const res = await fetch(url, { signal: AbortSignal.timeout(6000) });
}); if (!res.ok) {
if (!res.ok) return `tt${id}`; cacheSet(tmdbMetaCache, cacheKey, fallback, 60000);
return fallback;
}
const data = await res.json(); const data = await res.json();
return data.imdb_id || data.external_ids?.imdb_id || `tt${id}`; const title = data.name || data.title || '';
const originalTitle = data.original_name || data.original_title || '';
const releaseDate = data.first_air_date || data.release_date || '';
const year = releaseDate ? parseInt(releaseDate.slice(0, 4), 10) : null;
const imdbId = data.imdb_id || data.external_ids?.imdb_id || null;
const runtime = isTv ? (data.episode_run_time?.[0] || 24) : (data.runtime || 90);
const titles = [];
if (title) titles.push(title);
if (originalTitle && !titles.includes(originalTitle)) titles.push(originalTitle);
const alts = data.alternative_titles?.titles || data.alternative_titles?.results || [];
for (const alt of alts) {
const altTitle = alt.title || alt.name;
if (altTitle && !titles.includes(altTitle)) titles.push(altTitle);
}
const genres = data.genres || [];
const isAnime = genres.some(g => g.id === 16) && ((data.origin_country || []).includes('JP') || data.original_language === 'ja');
const result = {
title,
originalTitle,
titles,
year,
releaseDate,
imdbId,
isAnime,
runtime,
seasons: Array.isArray(data.seasons) ? data.seasons : [],
};
cacheSet(tmdbMetaCache, cacheKey, result, 600000);
return result;
} catch { } catch {
return `tt${id}`; cacheSet(tmdbMetaCache, cacheKey, fallback, 60000);
return fallback;
} }
} }
setInterval(() => { export async function resolveImdbId(id, isTv, tmdbApiKey = null) {
pruneHelperCache(tmdbValidationCache); if (typeof id === 'string' && id.startsWith('tt')) return id;
pruneHelperCache(tmdbInfoCache); const meta = await getTmdbMetadata(id, isTv, tmdbApiKey);
pruneHelperCache(anilistCache); return meta?.imdbId || `tt${id}`;
}, 60000).unref();
function cacheGet(cache, key) {
const entry = cache.get(key);
if (!entry) return undefined;
if (Date.now() - entry.ts >= entry.ttl) { cache.delete(key); return undefined; }
return entry.val;
} }
function cacheSet(cache, key, val, ttl) { cache.set(key, { val, ts: Date.now(), ttl }); } export async function getTmdbInfo(arg1, arg2, arg3, arg4) {
let apiKey = null;
let id = null;
let type = null;
let season = null;
export async function createStreamArgs(source, sdk, id, s, e, clientIP = null) { if (arg1 === 'movie' || arg1 === 'tv') {
const audio = /dub$/.test(source.key) ? 'dub' : 'sub'; type = arg1;
return { id = arg2;
id: id, season = arg3;
s: s, apiKey = arg4 || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
e: e, } else if (arg2 === 'movie' || arg2 === 'tv') {
clientIP: clientIP, if (typeof arg1 === 'string' && arg1.length > 20 && !/^\d+$/.test(arg1)) {
absoluteBase: '/', apiKey = arg1;
audio, id = arg3;
sdk, type = arg2;
config: source, season = arg4;
} else {
id = arg1;
type = arg2;
season = arg3;
apiKey = arg4 || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
}
} else if (arg3 === 'movie' || arg3 === 'tv') {
apiKey = arg1;
id = arg2;
type = arg3;
season = arg4;
} else {
id = arg1;
type = arg2 || 'movie';
season = arg3;
apiKey = arg4 || process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
}
if (!apiKey) apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
const isTv = type === 'tv';
const key = `${id}-${type}-${season || ''}-${apiKey}`;
const cached = cacheGet(tmdbInfoCache, key);
if (cached !== undefined) return cached;
try {
const meta = await getTmdbMetadata(id, isTv, apiKey);
let seasonTitle = null;
if (season && isTv) {
try {
const seasonRes = await fetch(`https://api.themoviedb.org/3/tv/${id}/season/${season}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) });
if (seasonRes.ok) {
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;
} }
} }
@@ -102,25 +290,25 @@ export async function validateTmdbId(tmdbApiKey, tmdbId, mediaType = 'movie') {
let apiKey = tmdbApiKey; let apiKey = tmdbApiKey;
let id = tmdbId; let id = tmdbId;
let type = mediaType; let type = mediaType;
if (id === 'movie' || id === 'tv' || !id) { if (id === 'movie' || id === 'tv' || !id) {
if (apiKey && apiKey !== 'movie' && apiKey !== 'tv') { if (apiKey && apiKey !== 'movie' && apiKey !== 'tv') {
type = id || 'movie'; type = id || 'movie';
id = apiKey; id = apiKey;
apiKey = process.env.TMDB_API_KEY; apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
} }
} }
if (!apiKey) { if (!apiKey) apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
apiKey = process.env.TMDB_API_KEY;
}
const key = `${id}-${type}`; const key = `${id}-${type}`;
const cached = cacheGet(tmdbValidationCache, key); const cached = cacheGet(tmdbValidationCache, key);
if (cached !== undefined) return cached; if (cached !== undefined) return cached;
if (!apiKey) return { valid: false, error: 'TMDB API key not configured' };
try { try {
const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) }); const res = await fetch(`https://api.themoviedb.org/3/${type}/${id}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) });
if (res.ok) { if (res.ok) {
const data = await res.json(); const data = await res.json();
const isValid = !!(data?.id && (data?.title || data?.name)); const isValid = Boolean(data?.id && (data?.title || data?.name));
const result = { valid: isValid, error: isValid ? null : 'Invalid TMDB ID' }; const result = { valid: isValid, error: isValid ? null : 'Invalid TMDB ID' };
cacheSet(tmdbValidationCache, key, result, 300000); cacheSet(tmdbValidationCache, key, result, 300000);
return result; return result;
@@ -135,107 +323,22 @@ export async function validateTmdbId(tmdbApiKey, tmdbId, mediaType = 'movie') {
} }
} }
export async function getTmdbInfo(tmdbApiKey, tmdbId, mediaType, season) {
let apiKey = tmdbApiKey;
let id = tmdbId;
let type = mediaType;
let s = season;
if (apiKey === 'movie' || apiKey === 'tv') {
type = apiKey;
id = tmdbId;
apiKey = process.env.TMDB_API_KEY;
} else if (id === 'movie' || id === 'tv') {
type = id;
id = apiKey;
apiKey = process.env.TMDB_API_KEY;
}
if (!apiKey) {
apiKey = process.env.TMDB_API_KEY;
}
const key = `${id}-${type}-${s || ''}`;
const cached = cacheGet(tmdbInfoCache, key);
if (cached !== undefined) return cached;
if (!apiKey) return { isAnime: false, titles: [], year: null, imdbId: null };
try {
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) }),
s && type === 'tv' ? fetch(`https://api.themoviedb.org/3/tv/${id}/season/${s}?api_key=${apiKey}`, { signal: AbortSignal.timeout(5000) }) : Promise.resolve(null),
]);
let mainData = null, seasonData = null;
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 isAnime = genres.some(g => g.id === 16) && ((mainData?.origin_country || []).includes('JP') || mainData?.original_language === 'ja');
const titles = [];
if (seasonData?.name) titles.push(seasonData.name);
const titleText = mainData?.title || mainData?.name || '';
const ot = mainData?.original_title || mainData?.original_name || '';
if (titleText) titles.push(titleText);
if (ot && ot !== titleText) titles.push(ot);
const dateStr = seasonData?.air_date || mainData?.release_date || mainData?.first_air_date || '';
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 };
cacheSet(tmdbInfoCache, key, result, 600000);
return result;
} catch { return { isAnime: false, titles: [], year: null, imdbId: 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 id = (await res.json())?.mappings?.[0]?.anilist_id;
if (id) { cacheSet(anilistCache, key, id, 600000); return id; }
} else res.body?.cancel();
} 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, 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) { res.body?.cancel(); continue; }
for (const entry of (await res.json())?.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 imdbToTmdb(tmdbApiKey, imdbId, mediaType = 'movie') { export async function imdbToTmdb(tmdbApiKey, imdbId, mediaType = 'movie') {
let apiKey = tmdbApiKey; let apiKey = tmdbApiKey;
let id = imdbId; let id = imdbId;
let type = mediaType; let type = mediaType;
if (id === 'movie' || id === 'tv') { if (id === 'movie' || id === 'tv') {
type = id; type = id;
id = apiKey; id = apiKey;
apiKey = process.env.TMDB_API_KEY; apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
}
if (!apiKey) {
apiKey = process.env.TMDB_API_KEY;
} }
if (!apiKey) apiKey = process.env.TMDB_API_KEY || DEFAULT_TMDB_KEY;
const key = `imdb-${id}`; 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 data = await fetchJson(`https://api.themoviedb.org/3/find/${id}?api_key=${apiKey}&external_source=imdb_id`, { signal: AbortSignal.timeout(5000) }); 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; let result = null;
@@ -243,5 +346,241 @@ export async function imdbToTmdb(tmdbApiKey, imdbId, mediaType = 'movie') {
else if (type === 'tv' && data.tv_results?.length) result = data.tv_results[0].id; else if (type === 'tv' && data.tv_results?.length) result = data.tv_results[0].id;
if (result) cacheSet(tmdbInfoCache, key, result, 600000); if (result) cacheSet(tmdbInfoCache, key, result, 600000);
return result; return result;
} catch { return null; } } 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) {