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
a9036545f3
commit
b6dbc53873
1 changed files with 53 additions and 8 deletions
|
|
@ -120,8 +120,8 @@ async function extractDetails(url) {
|
||||||
|
|
||||||
const transformedResults = [{
|
const transformedResults = [{
|
||||||
description: data.overview || 'No description available',
|
description: data.overview || 'No description available',
|
||||||
aliases: `Duration: ${data.episode_run_time && data.episode_run_time.length ? data.episode_run_time.join(', ') + " minutes" : 'Unknown'}`,
|
aliases: `If stream fails try again!`,
|
||||||
airdate: `Aired: ${data.first_air_date ? data.first_air_date : 'Unknown'}`
|
airdate: `If stream fails try again!`
|
||||||
}];
|
}];
|
||||||
|
|
||||||
console.log(JSON.stringify(transformedResults));
|
console.log(JSON.stringify(transformedResults));
|
||||||
|
|
@ -190,14 +190,60 @@ async function extractEpisodes(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractStreamUrl(ID) {
|
async function extractStreamUrl(ID) {
|
||||||
const chunkResponse = await soraFetch(atob("aHR0cHM6Ly9tYXBwbGUudWsvX25leHQvc3RhdGljL2NodW5rcy8yODk3LWE0ZTFmMDFkYmE5ZDRkMzcuanM="));
|
const htmlResponse = await soraFetch("https://mapple.uk/watch/" + ID);
|
||||||
const chunkText = await chunkResponse.text();
|
const htmlText = await htmlResponse.text();
|
||||||
|
|
||||||
const actionMatch = chunkText.match(/createServerReference\)\("([a-f0-9]{40,})"[^"]*"getStreamUrl/);
|
const jsUrlRegex = /(?:src|href)="([^"]*\.js(?:\?[^"]*)?)"/g;
|
||||||
const actionIdentifier = actionMatch ? actionMatch[1] : null;
|
const jsUrls = [];
|
||||||
|
let match;
|
||||||
|
|
||||||
|
while ((match = jsUrlRegex.exec(htmlText)) !== null) {
|
||||||
|
let jsUrl = match[1];
|
||||||
|
if (jsUrl.startsWith('/_next/') || jsUrl.startsWith('/static/')) {
|
||||||
|
jsUrl = 'https://mapple.uk' + jsUrl;
|
||||||
|
} else if (!jsUrl.startsWith('http')) {
|
||||||
|
jsUrl = 'https://mapple.uk/' + jsUrl;
|
||||||
|
}
|
||||||
|
jsUrls.push(jsUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uniqueJsUrls = [...new Set(jsUrls)];
|
||||||
|
console.log("Found " + uniqueJsUrls.length + " unique JS files");
|
||||||
|
|
||||||
|
let actionIdentifier = null;
|
||||||
|
let foundPromiseResolver = null;
|
||||||
|
const foundPromise = new Promise((resolve) => {
|
||||||
|
foundPromiseResolver = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
|
const searchPromises = uniqueJsUrls.map(async (url) => {
|
||||||
|
try {
|
||||||
|
if (actionIdentifier) return null;
|
||||||
|
const response = await soraFetch(url);
|
||||||
|
if (actionIdentifier) return null;
|
||||||
|
const text = await response.text();
|
||||||
|
if (actionIdentifier) return null;
|
||||||
|
const actionMatch = text.match(/createServerReference\)\("([a-f0-9]{40,})"[^"]*"getStreamUrl/);
|
||||||
|
if (actionMatch && actionMatch[1] && !actionIdentifier) {
|
||||||
|
actionIdentifier = actionMatch[1];
|
||||||
|
console.log("Found actionIdentifier in: " + url);
|
||||||
|
foundPromiseResolver(actionIdentifier);
|
||||||
|
return actionIdentifier;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error fetching " + url + ": " + e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
foundPromise,
|
||||||
|
Promise.all(searchPromises)
|
||||||
|
]);
|
||||||
|
|
||||||
if (!actionIdentifier) {
|
if (!actionIdentifier) {
|
||||||
throw new Error("Failed to extract action identifier from chunk file");
|
throw new Error("Failed to extract action identifier from any chunk file");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Action Identifier: " + actionIdentifier);
|
console.log("Action Identifier: " + actionIdentifier);
|
||||||
|
|
@ -265,7 +311,6 @@ async function extractStreamUrl(ID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get English subtitles
|
|
||||||
let englishSubtitleUrl = "";
|
let englishSubtitleUrl = "";
|
||||||
try {
|
try {
|
||||||
const subResponse = await soraFetch(`https://mapple.uk/api/subtitles?id=${tmdbID}&mediaType=movie`);
|
const subResponse = await soraFetch(`https://mapple.uk/api/subtitles?id=${tmdbID}&mediaType=movie`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue