mirror of
https://gitlab.com/vyla-entertainment/sdk.git
synced 2026-11-20 17:15:45 -05:00
added braflix and zenox
This commit is contained in:
108
src/sources/zenox.js
Normal file
108
src/sources/zenox.js
Normal file
@@ -0,0 +1,108 @@
|
||||
const BASE_URL = 'https://zenox.lol';
|
||||
const API_URL = `${BASE_URL}/api/v1/playback/session`;
|
||||
const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36';
|
||||
|
||||
const HEADERS = {
|
||||
'Content-Type': 'application/json',
|
||||
Origin: BASE_URL,
|
||||
Referer: `${BASE_URL}/`,
|
||||
'User-Agent': UA,
|
||||
};
|
||||
|
||||
const PLAYBACK_HEADERS = {
|
||||
Origin: BASE_URL,
|
||||
Referer: `${BASE_URL}/`,
|
||||
};
|
||||
|
||||
async function fetchServerStream(payload, srv) {
|
||||
try {
|
||||
const res = await fetch(API_URL, {
|
||||
method: 'POST',
|
||||
headers: HEADERS,
|
||||
body: JSON.stringify({
|
||||
...payload,
|
||||
serverIndex: srv.index,
|
||||
serverName: srv.name,
|
||||
}),
|
||||
signal: AbortSignal.timeout(6000),
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json();
|
||||
if (
|
||||
!data?.success ||
|
||||
!data?.streamUrl ||
|
||||
data.streamUrl.includes('/primary/') ||
|
||||
data.serverName?.toLowerCase() === 'primary'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const streamUrl = data.streamUrl.startsWith('http')
|
||||
? data.streamUrl
|
||||
: `${BASE_URL}${data.streamUrl}`;
|
||||
|
||||
return {
|
||||
url: streamUrl,
|
||||
server: `Zenox - ${data.serverName || srv.name}`,
|
||||
quality: 'Auto',
|
||||
type: streamUrl.includes('.m3u8') ? 'hls' : (streamUrl.includes('.mpd') ? 'dash' : 'mp4'),
|
||||
headers: PLAYBACK_HEADERS,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getStream(args) {
|
||||
const { id, s, e, title, year, imdbId } = args || {};
|
||||
const idNum = parseInt(id, 10);
|
||||
if (!idNum) return null;
|
||||
|
||||
const isTv = s != null && e != null;
|
||||
const payload = {
|
||||
mediaId: idNum,
|
||||
mediaType: isTv ? 'tv' : 'movie',
|
||||
season: isTv ? (parseInt(s, 10) || 1) : 1,
|
||||
episode: isTv ? (parseInt(e, 10) || 1) : 1,
|
||||
title: title || '',
|
||||
year: String(year || ''),
|
||||
imdbId: imdbId || '',
|
||||
autoUseCommunity: false,
|
||||
isManualSwitch: true,
|
||||
};
|
||||
|
||||
const activeServers = [
|
||||
{ name: 'Vbot', index: 1 },
|
||||
{ name: 'Temporary', index: 1 },
|
||||
];
|
||||
|
||||
const results = await Promise.allSettled(
|
||||
activeServers.map(srv => fetchServerStream(payload, srv))
|
||||
);
|
||||
|
||||
const allUrls = [];
|
||||
const seen = new Set();
|
||||
|
||||
for (const r of results) {
|
||||
if (r.status === 'fulfilled' && r.value?.url && !seen.has(r.value.url)) {
|
||||
seen.add(r.value.url);
|
||||
allUrls.push(r.value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!allUrls.length) {
|
||||
const delta = await fetchServerStream(payload, { name: 'Delta', index: 0 });
|
||||
if (delta?.url && !seen.has(delta.url)) {
|
||||
seen.add(delta.url);
|
||||
allUrls.push(delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (!allUrls.length) return null;
|
||||
|
||||
return {
|
||||
url: allUrls[0].url,
|
||||
headers: allUrls[0].headers,
|
||||
allUrls,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user