added mynimeku, subsl, tattooin, and todaytvseries

This commit is contained in:
2026-11-18 19:32:05 -08:00
parent dd5b384193
commit 4cbcf8a9ad
6 changed files with 689 additions and 0 deletions

View File

@@ -577,6 +577,18 @@ export const SOURCES = [
}], }],
}, },
{
key: 'mynimeku',
label: 'Mynimeku',
sourceFile: 'mynimeku',
proxyParam: 'mnk',
timeout: 25000,
jitter: 500,
retries: 2,
multiUrl: true,
dedicated: true,
},
{ {
key: 'net79', key: 'net79',
label: 'Net79', label: 'Net79',
@@ -659,6 +671,18 @@ export const SOURCES = [
}], }],
}, },
{
key: 'subsl',
label: 'SubSL',
sourceFile: 'subsl',
proxyParam: 'sbl',
timeout: 25000,
jitter: 500,
retries: 2,
multiUrl: true,
},
{ {
key: 'taroflix', key: 'taroflix',
label: 'TaroFlix', label: 'TaroFlix',
@@ -677,6 +701,18 @@ export const SOURCES = [
}], }],
}, },
{
key: 'tattooin',
label: 'Tattooin',
sourceFile: 'tattooin',
proxyParam: 'tt',
timeout: 25000,
jitter: 500,
retries: 2,
multiUrl: true,
dedicated: true,
},
{ {
key: 'streamaggregator', key: 'streamaggregator',
label: 'StreamAggregator', label: 'StreamAggregator',
@@ -713,6 +749,17 @@ export const SOURCES = [
}], }],
}, },
{
key: 'todaytvseries',
label: 'TodayTVSeries',
sourceFile: 'todaytvseries',
proxyParam: 'tts',
timeout: 25000,
jitter: 500,
retries: 2,
multiUrl: true,
},
{ {
key: 'torrentio', key: 'torrentio',
label: 'Torrentio', label: 'Torrentio',

107
src/sources/mynimeku.js Normal file
View File

@@ -0,0 +1,107 @@
import {
extractAnchors,
extractTags,
fetchPage,
normText,
resolveContentMeta,
stripTags,
toStreamResult,
} from '../utils/helpers.js';
const BASE = 'https://www.mynimeku.com';
const FILE_RE = /file\.mydriveku\.my\.id\/api\/v1\/(public|private)\/([^/?&]+)/i;
const INDO_RE = /\bsubtitle\s+indonesia\b|\bsub(?:title)?\s*indo(?:nesia)?\b/i;
const headTitle = title => (title || '').trim().split(/\s+-/)[0].replace(/^[\s-:]+|[\s-:]+$/g, '') || (title || '').trim();
function titleOk(post, title, year) {
const nt = normText(post);
const short = normText(headTitle(title));
const words = short.split(/\s+/).filter(w => w.length >= 2);
if (!words.length) return false;
let hit = words.every(w => new RegExp(`\\b${w}\\b`).test(nt));
if (!hit) {
const compact = short.replace(/[^a-z0-9]+/g, '');
hit = compact.length >= 8 && nt.replace(/[^a-z0-9]+/g, '').includes(compact);
}
if (!hit) return false;
return words.length === 1 ? (year != null && new RegExp(`\\b${year}\\b`).test(nt)) : true;
}
function seasonOk(post, season) {
const nth = post.match(/(\d+)(?:st|nd|rd|th)\s+season/i);
const m = post.match(/season\s*(\d+)/i);
const n = nth ? Number(nth[1]) : (m ? Number(m[1]) : null);
return n == null ? season === 1 : n === season;
}
async function searchSeries(title, season, year) {
const q = headTitle(title);
const run = async query => {
const r = await fetchPage(`${BASE}/?s=${encodeURIComponent(query)}`);
if (!r || !r.ok) return [];
const seen = new Set();
const out = [];
for (const a of extractAnchors(r.text, BASE)) {
const href = a.href.split('?')[0];
if (!href.includes('/series/') || seen.has(href) || !a.text) continue;
seen.add(href);
if (titleOk(a.text, title, year) && seasonOk(a.text, season)) out.push(href);
}
return out;
};
const res = await run(q);
return res.length || q === title ? res : run(title);
}
function extractFiles(html) {
const h1 = html.match(/<h1[^>]*class="[^"]*(?:entry-title|mynimeku-episode-head__title)[^"]*"[^>]*>([\s\S]*?)<\/h1>/i);
const title = (h1 ? stripTags(h1[1]) : '').replace(INDO_RE, '').replace(/\s+/g, ' ').trim();
const out = [];
const seen = new Set();
for (const a of extractAnchors(html)) {
const m = a.href.match(FILE_RE);
if (!m) continue;
const u = `https://file.mydriveku.my.id/${m[1].toLowerCase()}/${m[2]}`;
if (seen.has(u)) continue;
seen.add(u);
const name = title || a.text || 'download';
out.push({ url: u, name, tags: ['Indonesian', ...extractTags(name, a.text)] });
}
return out;
}
function findEpisodeUrl(html, ep) {
for (const a of extractAnchors(html, `${BASE}/`)) {
if (!a.href.includes('/episode/')) continue;
if (new RegExp(`episode-0*${ep}(?:\\D|$)`, 'i').test(a.href) || new RegExp(`episode\\s*0*${ep}\\b`, 'i').test(a.text)) {
return a.href;
}
}
return null;
}
export async function getStream(args) {
const meta = await resolveContentMeta(args);
if (!meta) return null;
const { title, year, isTv, s, e } = meta;
if (isTv && e == null) return null;
const posts = await searchSeries(title, isTv ? s : 1, year);
if (!posts.length) return null;
const r = await fetchPage(posts[0]);
if (!r || !r.ok) return null;
if (!isTv) {
const epUrl = findEpisodeUrl(r.text, 1);
if (!epUrl) return toStreamResult(extractFiles(r.text), 'Mynimeku');
const r2 = await fetchPage(epUrl);
return r2 && r2.ok ? toStreamResult(extractFiles(r2.text), 'Mynimeku') : null;
}
const epUrl = findEpisodeUrl(r.text, e);
if (!epUrl) return null;
const r2 = await fetchPage(epUrl);
return r2 && r2.ok ? toStreamResult(extractFiles(r2.text), 'Mynimeku') : null;
}

113
src/sources/subsl.js Normal file
View File

@@ -0,0 +1,113 @@
import {
extractTags,
fetchPage,
formatBytes,
normText,
resolveContentMeta,
toStreamResult,
} from '../utils/helpers.js';
const SITE = 'https://subsl.top';
let cachedApi = null;
async function getApiBase() {
if (cachedApi) return cachedApi;
const r = await fetchPage(SITE);
if (!r || !r.ok) return null;
const chunks = [...new Set(r.text.match(/\/_next\/static\/chunks\/[^"']+\.js/g) || [])];
for (const ch of chunks) {
const js = await fetchPage(`${SITE}${ch}`);
if (!js || !js.ok) continue;
const m1 = js.text.match(/let r="(https:\/\/[^"]+)",a=\{getTrendingMovies/);
if (m1) {
cachedApi = m1[1].replace(/\/$/, '');
return cachedApi;
}
const m2 = js.text.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/);
if (m2) {
cachedApi = m2[0].replace(/\/$/, '');
return cachedApi;
}
}
return null;
}
async function headSize(url) {
try {
const h = await fetch(url, { method: 'HEAD', signal: AbortSignal.timeout(10000) });
const cl = h.headers.get('content-length');
return cl && /^\d+$/.test(cl) ? formatBytes(Number(cl)) : '';
} catch {
return '';
}
}
export async function getStream(args) {
const meta = await resolveContentMeta(args);
if (!meta) return null;
const { title, year, tmdbId, imdbId, isTv, s, e } = meta;
if (isTv && e == null) return null;
const api = await getApiBase();
if (!api) return null;
const wt = normText(title);
if (!isTv) {
const r = await fetchPage(`${api}/movies/search/?title=${encodeURIComponent(title)}`);
if (!r || !r.ok) return null;
let movies = [];
try {
movies = JSON.parse(r.text)?.movies || [];
} catch {
return null;
}
const movie =
movies.find(m => imdbId && (m.imdb_code || '').toLowerCase() === imdbId.toLowerCase()) ||
movies.find(m => normText(m.title) === wt && (!year || String(m.year) === String(year))) ||
movies.find(m => normText(m.title).includes(wt) && (!year || String(m.year) === String(year)));
if (!movie) return null;
const out = [];
for (const link of movie.movie_links || []) {
if (!link?.url) continue;
const name = `${title} ${link.quality || ''}`.trim();
const sz = await headSize(link.url);
out.push({ url: link.url, name, tags: extractTags(name, sz) });
}
return toStreamResult(out, 'SubSL');
}
const r = await fetchPage(`${api}/tvshows/search/?title=${encodeURIComponent(title)}`);
if (!r || !r.ok) return null;
let shows = [];
try {
shows = JSON.parse(r.text)?.tv_shows || [];
} catch {
return null;
}
const show =
shows.find(sh => {
const code = (sh.imdb_code || '').toLowerCase();
return (imdbId && code === imdbId.toLowerCase()) || (tmdbId && (code === `tv${tmdbId}` || code === String(tmdbId)));
}) || shows.find(sh => normText(sh.title) === wt && (!year || String(sh.year) === String(year)));
if (!show) return null;
let seasons = show.seasons || [];
if (!seasons.length && show.id) {
const r2 = await fetchPage(`${api}/tvshows/${show.id}`);
if (r2 && r2.ok) {
try {
seasons = JSON.parse(r2.text)?.seasons || [];
} catch { }
}
}
for (const sea of seasons) {
if (Number(sea.season_number || 0) !== s) continue;
const ep = (sea.episodes || []).find(epItem => Number(epItem.episode_number || 0) === e);
if (ep?.video_link) {
const name = `${title} S${String(s).padStart(2, '0')}E${String(e).padStart(2, '0')}`;
const sz = await headSize(ep.video_link);
return toStreamResult([{ url: ep.video_link, name, tags: extractTags(name, sz) }], 'SubSL');
}
}
return null;
}

87
src/sources/tattooin.js Normal file
View File

@@ -0,0 +1,87 @@
import {
extractAnchors,
extractTags,
fetchPage,
resolveContentMeta,
toStreamResult,
} from '../utils/helpers.js';
const BASE = 'https://tattooin.ru';
const ROOT = `${BASE}/ftp/upload/`;
const VIDEO_EXT = /\.(mkv|mp4|avi|m4v|ts|iso|m2ts)$/i;
const SKIP_FILE = /(^|[._-])sample([._-]|$)/i;
const NEXT_RE = /^(?:(?:19|20)\d{2}|s\d{1,2}(?:e\d{1,3})?|\d{1,2}x\d{2,3}|\d{3,4}p|4k|uhd|hdr\d*|sdr|hlg|dv|dovi?|web|webdl|webrip|bluray|blu|bdrip|brrip|bdremux|remux|hdtv|hdrip|x265|x264|h265|h264|hevc|avc|av1|season|complete|extended|uncut|hybrid|proper|repack|truehd|atmos|dts)$/;
const tok = s => decodeURIComponent(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim().split(/\s+/).filter(Boolean);
function titleHit(name, title, year, needYear) {
const want = tok(title);
const have = tok(name);
if (!want.length || have.length < want.length) return false;
if (needYear && year && !have.includes(String(year))) return false;
const yearOk = !year || have.includes(String(year));
for (let i = 0; i <= have.length - want.length; i++) {
if (!want.every((w, j) => have[i + j] === w)) continue;
if (i && !NEXT_RE.test(have[i - 1])) continue;
if (i + want.length >= have.length || NEXT_RE.test(have[i + want.length]) || (year != null && yearOk)) return true;
}
return false;
}
function getSeasons(name) {
const set = new Set();
for (const m of name.matchAll(/(?:^|[^a-z0-9])s(\d{1,2})(?!\d)/gi)) set.add(Number(m[1]));
for (const m of name.matchAll(/season\s*(\d{1,2})\b/gi)) set.add(Number(m[1]));
return set;
}
function isSingleEp(name) {
if (/s\d{1,2}[\s._-]*e\d{1,3}[\s._-]*(?:-|–|to)[\s._-]*e?\d/i.test(name)) return false;
return /s\d{1,2}[\s._-]*e\d{1,3}/i.test(name) || /(?<![a-z0-9])\d{1,2}x\d{2,3}(?![a-z0-9])/i.test(name);
}
async function fetchDir(url) {
const r = await fetchPage(url);
if (!r || r.status !== 200) return [];
const base = url.endsWith('/') ? url : `${url}/`;
const seen = new Set();
const out = [];
for (const a of extractAnchors(r.text, base)) {
if (a.text === '..' || a.text === 'Parent Directory' || a.href.includes('?') || a.href.includes('/_h5ai/')) continue;
if (a.href.length <= base.length || seen.has(a.href)) continue;
seen.add(a.href);
const name = a.text || decodeURIComponent(a.href.replace(/\/$/, '').split('/').pop() || '');
out.push({ name, url: a.href, isDir: a.href.endsWith('/') });
}
return out;
}
export async function getStream(args) {
const meta = await resolveContentMeta(args);
if (!meta) return null;
const { title, year, isTv, s, e } = meta;
const rootEntries = await fetchDir(ROOT);
const hits = rootEntries.filter(it => {
if (!titleHit(it.name, title, year, !isTv && year != null)) return false;
const seas = getSeasons(it.name);
if (!isTv) return seas.size === 0;
if (seas.size && !seas.has(s)) return false;
return seas.size > 0 || it.isDir;
});
const out = [];
const isVideo = n => VIDEO_EXT.test(n) && !SKIP_FILE.test(n);
const epHit = n => new RegExp(`(?:^|[^a-z0-9])(?:s0*${s}[\\s._-]*e0*${e}|0*${s}x0*${e})(?:[^a-z0-9]|$)`, 'i').test(n);
for (const h of hits) {
const files = h.isDir ? (await fetchDir(h.url)).filter(x => !x.isDir && isVideo(x.name)) : (isVideo(h.name) ? [h] : []);
for (const f of files) {
if (isTv && e == null && isSingleEp(f.name)) continue;
if (isTv && e != null && !epHit(f.name)) continue;
out.push({ url: f.url, name: f.name, tags: extractTags(f.name) });
}
}
return toStreamResult(out, 'Tattooin');
}

View File

@@ -0,0 +1,82 @@
import {
extractAnchors,
extractTags,
fetchPage,
normText,
resolveContentMeta,
toStreamResult,
} from '../utils/helpers.js';
const BASE = 'https://www.todaytvseries1.com';
async function searchSeries(title) {
const r = await fetchPage(`${BASE}/search-series?tmpl=raw&type=json&searchphrase=all&searchword=${encodeURIComponent(title)}`, {
headers: { 'X-Requested-With': 'XMLHttpRequest', Accept: 'application/json' },
}, 25000);
if (r && r.status === 200) {
try {
const results = JSON.parse(r.text)?.results || [];
const items = results
.filter(row => row.url && row.title)
.map(row => ({ title: row.title.trim(), url: new URL(row.url, `${BASE}/`).href }));
if (items.length) return items;
} catch { }
}
for (const q of [title, `"${title}"`]) {
const r2 = await fetchPage(`${BASE}/search-series?searchword=${encodeURIComponent(q)}&searchphrase=all`, {}, 25000);
if (!r2 || r2.status !== 200) continue;
const seen = new Set();
const out = [];
for (const a of extractAnchors(r2.text, `${BASE}/`)) {
if (!a.href.includes('/tv-series/') || !a.text || seen.has(a.href)) continue;
seen.add(a.href);
out.push({ title: a.text, url: a.href });
}
if (out.length) return out;
}
return [];
}
export async function getStream(args) {
const meta = await resolveContentMeta(args);
if (!meta || !meta.isTv || meta.e == null) return null;
const { title, s, e } = meta;
const items = await searchSeries(title);
if (!items.length) return null;
const wt = normText(title);
const url =
items.find(it => normText(it.title) === wt)?.url ||
items.find(it => {
const nt = normText(it.title);
return nt.includes(wt) || wt.includes(nt) || wt.split(/\s+/).some(w => w.length > 2 && nt.includes(w));
})?.url;
if (!url) return null;
const r = await fetchPage(url, {}, 25000);
if (!r || r.status !== 200 || r.text.includes('Just a moment')) return null;
const secMatch = r.text.match(new RegExp(`Download\\s+Season\\s*0*${s}\\s*</h[0-9]>([\\s\\S]*?)(?=Download\\s+Season\\s*\\d+\\s*</h[0-9]>|$)`, 'i'));
const chunk = secMatch ? secMatch[1] : r.text;
const out = [];
const seen = new Set();
for (const row of chunk.matchAll(/cell2">\s*(S\d+E\d+)\s*<\/div>[\s\S]*?href="(https?:\/\/[^"]+)"/gi)) {
if (!new RegExp(`S0*${s}E0*${e}\\b`, 'i').test(row[1]) || seen.has(row[2])) continue;
seen.add(row[2]);
const fname = decodeURIComponent(row[2].replace(/\/$/, '').split('/').pop() || '');
const name = fname && fname.includes('.') ? fname : row[1];
out.push({ url: row[2], name, tags: extractTags(name, row[2], row[0]) });
}
if (!out.length) {
for (const a of extractAnchors(chunk)) {
if (!a.href.startsWith('http') || !new RegExp(`S0*${s}E0*${e}\\b`, 'i').test(a.href) || seen.has(a.href)) continue;
seen.add(a.href);
const fname = decodeURIComponent(a.href.replace(/\/$/, '').split('/').pop() || '');
out.push({ url: a.href, name: fname, tags: extractTags(fname, a.href) });
}
}
return toStreamResult(out, 'TodayTVSeries');
}

View File

@@ -583,3 +583,256 @@ export async function scrapeVidcoreFamily({ id, s, e, baseUrl, apiName, serverLa
return null; return null;
} }
} }
export function normText(s) {
return String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
}
export function decodeHtml(s) {
return String(s || '')
.replace(/&amp;/gi, '&')
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
.replace(/&quot;/gi, '"')
.replace(/&#39;|&apos;/gi, "'")
.replace(/&#8211;|&ndash;/gi, '–')
.replace(/&#8212;|&mdash;/gi, '—')
.replace(/&#x([0-9a-f]+);/gi, (_, h) => String.fromCodePoint(parseInt(h, 16)))
.replace(/&#(\d+);/g, (_, d) => String.fromCodePoint(parseInt(d, 10)));
}
export function stripTags(s) {
return decodeHtml(String(s || '').replace(/<[^>]+>/g, ' '));
}
export async function fetchPage(url, options = {}, timeout = 20000) {
try {
const res = await fetch(url, {
...options,
headers: { 'User-Agent': getUA(), ...(options.headers || {}) },
signal: options.signal || AbortSignal.timeout(timeout),
});
const text = await res.text();
return { ok: res.ok, status: res.status, url: res.url || url, headers: res.headers, text };
} catch {
return null;
}
}
export function extractAnchors(html, baseUrl = '') {
if (!html) return [];
const out = [];
const re = /<a\b([^>]*?)\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))([^>]*)>([\s\S]*?)<\/a>/gi;
let m;
while ((m = re.exec(html)) !== null) {
let href = decodeHtml((m[2] ?? m[3] ?? m[4] ?? '').trim());
if (!href) continue;
if (baseUrl) {
try {
href = new URL(href, baseUrl).href;
} catch {
continue;
}
}
const attrs = `${m[1] || ''} ${m[5] || ''}`;
const text = stripTags(m[6] || '').replace(/\s+/g, ' ').trim();
const titleMatch = attrs.match(/\btitle\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
const classMatch = attrs.match(/\bclass\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
out.push({
href,
text,
title: titleMatch ? decodeHtml(titleMatch[1] ?? titleMatch[2] ?? '') : '',
className: classMatch ? (classMatch[1] ?? classMatch[2] ?? '') : '',
attrs,
index: m.index,
});
}
return out;
}
const TAG_PATTERNS = [
[/\b(2160p+|4k|uhd)\b|\b\d{3,4}\s*[x×]\s*2160\b/i, '2160p'],
[/\b1080p+\b|\b\d{3,4}\s*[x×]\s*1080\b/i, '1080p'],
[/\b720p+\b|\b720\s*hc\b|\b720hc\b|\b\d{3,4}\s*[x×]\s*720\b/i, '720p'],
[/\b540p+\b|\b\d{3,4}\s*[x×]\s*540\b/i, '540p'],
[/\b480p+\b|\b480\s*hc\b|\b\d{3,4}\s*[x×]\s*480\b/i, '480p'],
[/\b400p+\b|\b\d{3,4}\s*[x×]\s*400\b/i, '400p'],
[/\b360p+\b|\b\d{3,4}\s*[x×]\s*360\b/i, '360p'],
[/\bremux\b/i, 'REMUX'],
[/\bbluray|blu[-\s]?ray|bdrip|brrip\b/i, 'BluRay'],
[/\bweb[-\s]?dl\b/i, 'WEB-DL'],
[/\bwebrip\b/i, 'WEBRip'],
[/\bhdtv\b/i, 'HDTV'],
[/\bhdrip\b/i, 'HDRip'],
[/\b(x265|h\.?265|hevc)\b/i, 'x265'],
[/\b(x264|h\.?264|avc)\b/i, 'x264'],
[/\b10\s*-?\s*bit\b/i, '10bit'],
[/\bhdr10?\+?\b/i, 'HDR'],
[/\bdolby\.?\s*vision|\bdv\b/i, 'DV'],
[/\batmos\b/i, 'Atmos'],
[/\bddp?5\.?1|truehd|dts\b/i, '5.1'],
[/\bdual(?:[_\s-]*audio)?\b/i, 'Dual'],
[/\bmulti(?:[_\s-]*audio)?\b/i, 'Multi'],
[/\bhindi\b/i, 'Hindi'],
[/\benglish\b/i, 'English'],
[/\bindonesian\b|\bsubtitle\s+indonesia\b|\bsub(?:title)?\s*indo(?:nesia)?\b/i, 'Indonesian'],
];
export function extractTags(...parts) {
const blob = parts.filter(Boolean).join(' ');
if (!blob.trim()) return [];
const tags = [];
const seen = new Set();
const quals = [];
for (const [pat, tag] of TAG_PATTERNS) {
if (seen.has(tag) || !pat.test(blob)) continue;
seen.add(tag);
if (/^(2160p|1080p|720p|540p|480p|400p|360p)$/.test(tag)) quals.push(tag);
else tags.push(tag);
}
const sizeMatches = blob.matchAll(/\b(\d+(?:[.,]\d+)?)\s*(KB|MB|GB|TB|KiB|MiB|GiB|TiB)\b/gi);
for (const m of sizeMatches) {
let num = m[1].replace(',', '.');
if (num.includes('.')) num = num.replace(/0+$/, '').replace(/\.$/, '');
const t = `${num}${m[2].toUpperCase().replace('IB', 'B')}`;
if (!seen.has(t)) {
seen.add(t);
tags.push(t);
}
}
if (quals.length === 1) tags.unshift(quals[0]);
return tags;
}
export async function resolveContentMeta(args = {}) {
const { id, s, e, sdk, tmdbApiKey } = args;
if (id == null) return null;
const isTv = s != null;
const key = resolveTmdbKey(args, sdk);
const meta = await getTmdbMetadata(id, isTv, key);
if (!meta?.title) return null;
return {
title: meta.title,
titles: meta.titles || [meta.title],
year: meta.year || null,
imdbId: meta.imdbId || null,
tmdbId: id,
isTv,
s: s != null ? Number(s) : null,
e: e != null ? Number(e) : null,
};
}
export async function resolveIntermediateLinks(items, limit = 12) {
const GOOGLE = /https:\/\/video-downloads\.googleusercontent\.com\/[^\s"'<>]+/;
const GOFILE = /https:\/\/gofile\.io\/d\/[A-Za-z0-9]+/g;
const PIXEL = /https?:\/\/pixeldrain\.(?:net|com|dev)\/u\/[A-Za-z0-9]+/g;
const GAMER = /https?:\/\/gamerxyt\.com\/hubcloud\.php\?[^\s"'<>]+/;
const FASTD = /https?:\/\/fastdl\.zip\/embed\?download=[A-Za-z0-9]+/;
const GOFLIX = /https?:\/\/goflix\.[a-z]+\/[^\s"'<>]+/g;
const VIKING_F = /https?:\/\/(?:[\w-]+\.)?vikingfile\.com\/f\/[A-Za-z0-9]+/g;
const KMHD_HOST = /(acefile\.|anidrive|topddl|drive\.google|gdflix|filepress|gofile|hubdrive|hubcloud|pixeldrain|katdrive)/i;
const UNWRAP = /nexdrive|gdflix|gdlink|hubcloud|vikingfile\.com\/f\/|kmhd\.eu|fastdl\.zip\/embed/i;
const closer = async url => {
const low = (url || '').toLowerCase();
if (low.includes('fastdl.zip/embed')) {
const r = await fetchPage(url, {}, 12000);
const g = r ? r.text.match(GOOGLE) : null;
return g ? [g[0]] : [];
}
if (low.includes('nexdrive')) {
const r = await fetchPage(url, {}, 12000);
if (!r || !r.ok) return [];
const m = r.text.match(FASTD);
if (!m) return [];
const r2 = await fetchPage(m[0], {}, 12000);
const g = r2 ? r2.text.match(GOOGLE) : null;
return g ? [g[0]] : [];
}
if (low.includes('gdflix') || low.includes('gdlink')) {
const r = await fetchPage(url, {}, 12000);
if (!r || !r.ok) return [url];
const found = [...(r.text.match(GOFILE) || [])];
for (const m of r.text.match(GOFLIX) || []) {
const r2 = await fetchPage(m, {}, 12000);
if (!r2) continue;
found.push(...(r2.text.match(GOFILE) || []));
found.push(...(r2.text.match(VIKING_F) || []));
}
return found.length ? [...new Set(found)] : [url];
}
if (low.includes('hubcloud')) {
const r = await fetchPage(url, {}, 12000);
if (!r || !r.ok) return [url];
const m = r.text.match(GAMER);
if (!m) return [url];
const r2 = await fetchPage(m[0], {}, 12000);
if (!r2) return [url];
const cands = [...new Set([...(r2.text.match(PIXEL) || []), ...(r2.text.match(GOFILE) || [])])];
return cands.length ? [...cands, url] : [url];
}
if (low.includes('vikingfile.com') && low.includes('/f/')) {
const r = await fetchPage(url, { headers: { Range: 'bytes=0-0' } }, 12000);
if (!r) return [url];
return r.url.includes('/download/') ? [r.url] : [url];
}
if (low.includes('kmhd.eu')) {
const r = await fetchPage(url, {}, 12000);
if (!r || !r.ok) return [url];
const found = extractAnchors(r.text, url)
.map(a => a.href)
.filter(h => h.startsWith('http') && KMHD_HOST.test(h));
return found.length ? [...new Set(found)] : [url];
}
return [url];
};
const out = [];
const seen = new Set();
let hops = 0;
for (const it of items || []) {
const url = typeof it === 'string' ? it : it?.url;
if (!url) continue;
let nextUrls;
if (UNWRAP.test(url)) {
if (hops < limit) {
hops++;
nextUrls = await closer(url);
} else if (url.toLowerCase().includes('nexdrive') || url.toLowerCase().includes('fastdl.zip')) {
nextUrls = [];
} else {
nextUrls = [url];
}
} else {
nextUrls = [url];
}
for (const u of nextUrls) {
if (!u || seen.has(u)) continue;
seen.add(u);
out.push(typeof it === 'object' ? { ...it, url: u } : { url: u });
}
}
return out;
}
export function toStreamResult(items, serverLabel, defaultHeaders = {}) {
if (!Array.isArray(items) || !items.length) return null;
const mapped = items
.filter(it => it && typeof it.url === 'string' && it.url.startsWith('http'))
.map(it => {
const tags = Array.isArray(it.tags) ? it.tags : extractTags(it.name || '', it.url);
const quality = tags.find(t => /^(2160p|1080p|720p|540p|480p|400p|360p)$/i.test(t)) || 'Auto';
const lower = it.url.toLowerCase();
const type = lower.includes('.m3u8') ? 'hls' : (lower.includes('.mpd') ? 'dash' : 'mp4');
return {
url: it.url,
server: it.name ? `${serverLabel} - ${it.name}` : serverLabel,
label: it.name || serverLabel,
quality,
type,
headers: it.headers || defaultHeaders,
};
});
return formatStreamResult(mapped, defaultHeaders);
}