mirror of
https://gitlab.com/vyla-entertainment/sdk.git
synced 2026-11-17 07:37:34 -05:00
create SDK
This commit is contained in:
46
src/sources/fsonline.js
Normal file
46
src/sources/fsonline.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import { fetchText, USER_AGENT, getTmdbInfo } from '../utils/helpers.js';
|
||||
|
||||
const ORIGIN = 'https://www3.fsonline.app';
|
||||
const AJAX_URL = `${ORIGIN}/wp-admin/admin-ajax.php`;
|
||||
const HEADERS = { 'User-Agent': USER_AGENT, 'Origin': ORIGIN, 'Referer': `${ORIGIN}/` };
|
||||
|
||||
export async function getStream({ id, s, e }) {
|
||||
try {
|
||||
const isTv = s != null && e != null;
|
||||
const info = await getTmdbInfo(id, isTv ? 'tv' : 'movie');
|
||||
if (!info?.titles?.length) return null;
|
||||
const searchHtml = await fetchText(`${ORIGIN}/?s=${encodeURIComponent(info.titles[0] + (info.year ? ' ' + info.year : ''))}`, { headers: HEADERS });
|
||||
const typeFolder = isTv ? 'seriale' : 'film';
|
||||
const linkMatch = searchHtml.match(new RegExp(`href=["'](https?://www3\\.fsonline\\.app/${typeFolder}/([^"'/]+)/)["']`, 'i'));
|
||||
if (!linkMatch) return null;
|
||||
const targetPageUrl = isTv ? `${ORIGIN}/episoade/${linkMatch[2].replace(/-\d{4}$/, '')}-sezonul-${s}-episodul-${e}/` : linkMatch[1];
|
||||
const pageHtml = await fetchText(targetPageUrl, { headers: HEADERS });
|
||||
const movieId = (pageHtml.match(/movie-id=['"]([^'"]+)['"]/) || pageHtml.match(/movie-id=([^ >]+)/))?.[1];
|
||||
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 = [];
|
||||
let idx = 0;
|
||||
while ((idx = ajaxHtml.indexOf('data-vs="', idx)) !== -1) {
|
||||
const embedStart = idx + 9;
|
||||
const embedEnd = ajaxHtml.indexOf('"', embedStart);
|
||||
const embedUrl = ajaxHtml.slice(embedStart, embedEnd);
|
||||
const spanStart = ajaxHtml.indexOf('<span>', embedEnd);
|
||||
const spanEnd = ajaxHtml.indexOf('</span>', spanStart);
|
||||
const serverLabel = ajaxHtml.slice(spanStart + 6, spanEnd).trim().toLowerCase();
|
||||
if (serverLabel.includes('filesun')) {
|
||||
try {
|
||||
const rHtml = await fetchText(embedUrl, { headers: { 'Referer': ORIGIN, 'User-Agent': USER_AGENT } });
|
||||
const m3u8Match = rHtml.match(/file:\s*["'](https?:\/\/[^"']+\.m3u8[^"']*)["']/) || rHtml.match(/["']?file["']?:\s*["'](https?:\/\/[^"']+)["']/);
|
||||
if (m3u8Match) results.push({ url: m3u8Match[1].replace(/\\\//g, '/'), server: 'FSOnline - FileSuN', headers: { 'Referer': embedUrl, 'Origin': 'https://player.fsonline.app', 'User-Agent': USER_AGENT } });
|
||||
} catch { }
|
||||
}
|
||||
idx = spanEnd;
|
||||
}
|
||||
return results.length ? { allUrls: results } : null;
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
export async function getSources(args) {
|
||||
const res = await getStream(args);
|
||||
return res?.allUrls ? [...new Set(res.allUrls.map(u => u.server))] : [];
|
||||
}
|
||||
Reference in New Issue
Block a user