Update ashi/ashi.js

This commit is contained in:
aka paul 2025-12-04 18:35:11 +00:00
parent 86cc7e5fc6
commit 0540a0c298

View file

@ -671,9 +671,40 @@ async function extractStreamUrl(url) {
const m3u8Link = finalJson?.result?.sources?.[0]?.file;
const m3u8Response = await fetchv2(m3u8Link);
const m3u8Text = await m3u8Response.text();
const baseUrl = m3u8Link.substring(0, m3u8Link.lastIndexOf('/') + 1);
const streams = [];
const lines = m3u8Text.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line.startsWith('#EXT-X-STREAM-INF:')) {
const resolutionMatch = line.match(/RESOLUTION=(\d+x\d+)/);
let quality = 'Unknown';
if (resolutionMatch) {
const [width, height] = resolutionMatch[1].split('x');
quality = `${height}p`;
}
if (i + 1 < lines.length) {
const streamPath = lines[i + 1].trim();
const streamUrl = baseUrl + streamPath;
streams.push({
title: quality,
streamUrl: streamUrl
});
}
}
}
const returnValue = {
stream: m3u8Link,
subtitles: englishSubUrl
streams: streams,
subtitle: englishSubUrl !== "N/A" ? englishSubUrl : ""
};
console.log("RETURN: " + JSON.stringify(returnValue));
return JSON.stringify(returnValue);