From 6acea93a3c3f897c40db87c4022b7a64e707aed0 Mon Sep 17 00:00:00 2001
From: aka paul <50n50@noreply.localhost>
Date: Wed, 25 Mar 2026 16:56:54 +0000
Subject: [PATCH] Update ashi/ashi.js
---
ashi/ashi.js | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/ashi/ashi.js b/ashi/ashi.js
index 5d93922..20ba88a 100644
--- a/ashi/ashi.js
+++ b/ashi/ashi.js
@@ -559,20 +559,44 @@ async function extractStreamUrl(url) {
const response = await fetchv2(useProxy ? proxyUrl(actualUrl) : actualUrl);
const text = await response.text();
+
+ let ajaxResultHtml = "";
+ try {
+ const parsedAjax = JSON.parse(text);
+ ajaxResultHtml = parsedAjax?.result || "";
+ } catch {}
+
const cleanedHtml = cleanJsonHtml(text);
+ const cleanedAjaxResultHtml = cleanJsonHtml(ajaxResultHtml);
+ const serverHtmlSource = cleanedAjaxResultHtml || cleanedHtml;
+
const subRegex = /
]*>([\s\S]*?)<\/div>/;
const softsubRegex = /
]*>([\s\S]*?)<\/div>/;
const dubRegex = /
]*>([\s\S]*?)<\/div>/;
- const subMatch = subRegex.exec(cleanedHtml);
- const softsubMatch = softsubRegex.exec(cleanedHtml);
- const dubMatch = dubRegex.exec(cleanedHtml);
+ const subMatch = subRegex.exec(serverHtmlSource);
+ const softsubMatch = softsubRegex.exec(serverHtmlSource);
+ const dubMatch = dubRegex.exec(serverHtmlSource);
const subContent = subMatch ? subMatch[1].trim() : "";
const softsubContent = softsubMatch ? softsubMatch[1].trim() : "";
const dubContent = dubMatch ? dubMatch[1].trim() : "";
- const serverSpanRegex = /]*data-lid="([^"]+)"[^>]*>Server 1<\/span>/;
- const serverIdDub = serverSpanRegex.exec(dubContent)?.[1];
- const serverIdSoftsub = serverSpanRegex.exec(softsubContent)?.[1];
- const serverIdSub = serverSpanRegex.exec(subContent)?.[1];
+
+ const extractServerId = (content) => {
+ if (!content) {
+ return null;
+ }
+
+ const preferred = /]*data-lid="([^"]+)"[^>]*>\s*Server\s*1\s*<\/span>/i.exec(content);
+ if (preferred?.[1]) {
+ return preferred[1];
+ }
+
+ const fallback = /]*data-lid="([^"]+)"/i.exec(content);
+ return fallback?.[1] || null;
+ };
+
+ const serverIdDub = extractServerId(dubContent);
+ const serverIdSoftsub = extractServerId(softsubContent);
+ const serverIdSub = extractServerId(subContent);
const tokenRequestData = [
{ name: "Dub", data: serverIdDub },