mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update mapple/mapple.js
This commit is contained in:
parent
d9a8975e5f
commit
868e6bf1ca
1 changed files with 79 additions and 2 deletions
|
|
@ -229,6 +229,43 @@ async function extractStreamUrl(ID) {
|
|||
}
|
||||
|
||||
if (streamData && streamData.data && streamData.data.stream_url) {
|
||||
const m3u8Response = await soraFetch(streamData.data.stream_url, {
|
||||
headers: {
|
||||
"referer": "https://mapple.uk/",
|
||||
"origin": "https://mapple.uk"
|
||||
}
|
||||
});
|
||||
const m3u8Text = await m3u8Response.text();
|
||||
console.log("M3U8 Playlist: " + m3u8Text);
|
||||
|
||||
const streams = [];
|
||||
const lines = m3u8Text.split('\n');
|
||||
const resolutionNames = {
|
||||
"3840x2160": "4K",
|
||||
"1920x1080": "1080p",
|
||||
"1280x720": "720p",
|
||||
"640x360": "360p"
|
||||
};
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].startsWith('#EXT-X-STREAM-INF')) {
|
||||
const resolutionMatch = lines[i].match(/RESOLUTION=(\d+x\d+)/);
|
||||
const streamUrl = lines[i + 1];
|
||||
if (resolutionMatch && streamUrl && streamUrl.trim()) {
|
||||
const resolution = resolutionMatch[1];
|
||||
const friendlyName = resolutionNames[resolution] || resolution;
|
||||
streams.push({
|
||||
title: friendlyName,
|
||||
streamUrl: streamUrl.trim(),
|
||||
headers: {
|
||||
"referer": "https://mapple.uk/",
|
||||
"origin": "https://mapple.uk"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get English subtitles
|
||||
let englishSubtitleUrl = "";
|
||||
try {
|
||||
const subResponse = await soraFetch(`https://mapple.uk/api/subtitles?id=${tmdbID}&mediaType=movie`);
|
||||
|
|
@ -241,8 +278,10 @@ async function extractStreamUrl(ID) {
|
|||
englishSubtitleUrl = "";
|
||||
}
|
||||
console.log("English Subtitle URL: " + englishSubtitleUrl);
|
||||
console.log("Extracted streams: " + JSON.stringify(streams));
|
||||
|
||||
return JSON.stringify({
|
||||
streams: [
|
||||
streams: streams.length > 0 ? streams : [
|
||||
{
|
||||
title: "Mapple Server",
|
||||
streamUrl: streamData.data.stream_url,
|
||||
|
|
@ -284,6 +323,42 @@ async function extractStreamUrl(ID) {
|
|||
}
|
||||
|
||||
if (streamData && streamData.data && streamData.data.stream_url) {
|
||||
const m3u8Response = await soraFetch(streamData.data.stream_url, {
|
||||
headers: {
|
||||
"referer": "https://mapple.uk/",
|
||||
"origin": "https://mapple.uk"
|
||||
}
|
||||
});
|
||||
const m3u8Text = await m3u8Response.text();
|
||||
console.log("M3U8 Playlist: " + m3u8Text);
|
||||
|
||||
const streams = [];
|
||||
const lines = m3u8Text.split('\n');
|
||||
const resolutionNames = {
|
||||
"3840x2160": "4K",
|
||||
"1920x1080": "1080p",
|
||||
"1280x720": "720p",
|
||||
"640x360": "360p"
|
||||
};
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].startsWith('#EXT-X-STREAM-INF')) {
|
||||
const resolutionMatch = lines[i].match(/RESOLUTION=(\d+x\d+)/);
|
||||
const streamUrl = lines[i + 1];
|
||||
if (resolutionMatch && streamUrl && streamUrl.trim()) {
|
||||
const resolution = resolutionMatch[1];
|
||||
const friendlyName = resolutionNames[resolution] || resolution;
|
||||
streams.push({
|
||||
title: friendlyName,
|
||||
streamUrl: streamUrl.trim(),
|
||||
headers: {
|
||||
"referer": "https://mapple.uk/",
|
||||
"origin": "https://mapple.uk"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let englishSubtitleUrl = "";
|
||||
try {
|
||||
const subResponse = await soraFetch(`https://mapple.uk/api/subtitles?id=${tmdbID}&mediaType=tv&season=${seasonNumber}&episode=${episodeNumber}`);
|
||||
|
|
@ -296,8 +371,10 @@ async function extractStreamUrl(ID) {
|
|||
englishSubtitleUrl = "";
|
||||
}
|
||||
console.log("English Subtitle URL: " + englishSubtitleUrl);
|
||||
console.log("Extracted streams: " + JSON.stringify(streams));
|
||||
|
||||
return JSON.stringify({
|
||||
streams: [
|
||||
streams: streams.length > 0 ? streams : [
|
||||
{
|
||||
title: "Mapple Server",
|
||||
streamUrl: streamData.data.stream_url,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue