mirror of
https://gitlab.com/vyla-entertainment/sdk.git
synced 2026-11-21 01:25:42 -05:00
added vidly, and streamrip, removed rivo, added anizone, added anv, added
This commit is contained in:
82
src/sources/moviebox.js
Normal file
82
src/sources/moviebox.js
Normal file
@@ -0,0 +1,82 @@
|
||||
import { USER_AGENT, fetchJson } from '../utils/helpers.js';
|
||||
|
||||
const BASE_URL = 'https://net79.cc';
|
||||
const PLAYBACK_REFERER = 'https://mzfi.me/';
|
||||
|
||||
const HEADERS = {
|
||||
Accept: 'application/json',
|
||||
Referer: `${BASE_URL}/`,
|
||||
Origin: BASE_URL,
|
||||
'User-Agent': USER_AGENT,
|
||||
};
|
||||
|
||||
const PLAYBACK_HEADERS = {
|
||||
Referer: PLAYBACK_REFERER,
|
||||
};
|
||||
|
||||
function formatSize(sizeBytes) {
|
||||
if (!sizeBytes || typeof sizeBytes !== 'number') return '';
|
||||
const gb = sizeBytes / (1024 * 1024 * 1024);
|
||||
return gb >= 1 ? `${gb.toFixed(2)} GB` : `${Math.round(sizeBytes / (1024 * 1024))} MB`;
|
||||
}
|
||||
|
||||
export async function getStream(args) {
|
||||
const { id, s, e } = args || {};
|
||||
if (!id) return null;
|
||||
|
||||
const isTv = s != null && e != null;
|
||||
const season = isTv ? (parseInt(s, 10) || 1) : 1;
|
||||
const episode = isTv ? (parseInt(e, 10) || 1) : 1;
|
||||
|
||||
const apiUrl = isTv
|
||||
? `${BASE_URL}/api/embed-tmdb/${id}?type=tv&se=${season}&ep=${episode}`
|
||||
: `${BASE_URL}/api/embed-tmdb/${id}?type=movie`;
|
||||
|
||||
try {
|
||||
const payload = await fetchJson(apiUrl, {
|
||||
headers: HEADERS,
|
||||
signal: AbortSignal.timeout(8000),
|
||||
});
|
||||
|
||||
if (!payload || !payload.ok || payload.noSource) return null;
|
||||
|
||||
const streamList = Array.isArray(payload.streams) && payload.streams.length > 0
|
||||
? payload.streams
|
||||
: (payload.mp4 ? [{ url: payload.mp4, resolution: payload.resolution || 720 }] : []);
|
||||
|
||||
if (!streamList.length) return null;
|
||||
|
||||
const allUrls = [];
|
||||
const seen = new Set();
|
||||
|
||||
for (const item of streamList) {
|
||||
const streamUrl = item?.url;
|
||||
if (!streamUrl || typeof streamUrl !== 'string' || !streamUrl.startsWith('http') || seen.has(streamUrl)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(streamUrl);
|
||||
|
||||
const resolution = item.resolution ? `${item.resolution}p` : '720p';
|
||||
const sizeStr = item.size ? formatSize(parseInt(item.size, 10)) : '';
|
||||
const sizeLabel = sizeStr ? ` [${sizeStr}]` : '';
|
||||
|
||||
allUrls.push({
|
||||
url: streamUrl,
|
||||
server: `MovieBox ${resolution}${sizeLabel}`,
|
||||
quality: resolution,
|
||||
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
|
||||
headers: PLAYBACK_HEADERS,
|
||||
});
|
||||
}
|
||||
|
||||
if (!allUrls.length) return null;
|
||||
|
||||
return {
|
||||
url: allUrls[0].url,
|
||||
headers: allUrls[0].headers,
|
||||
allUrls,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user