From 0540a0c298c502ec17b7270001379ca0c59a01df Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Thu, 4 Dec 2025 18:35:11 +0000 Subject: [PATCH] Update ashi/ashi.js --- ashi/ashi.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ashi/ashi.js b/ashi/ashi.js index c2ecbe2..69436d5 100644 --- a/ashi/ashi.js +++ b/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);