mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update ashi/ashi.js
This commit is contained in:
parent
86cc7e5fc6
commit
0540a0c298
1 changed files with 33 additions and 2 deletions
35
ashi/ashi.js
35
ashi/ashi.js
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue