Update animekai/hardsub/animekai.js
This commit is contained in:
@@ -127,20 +127,44 @@ async function extractStreamUrl(url) {
|
|||||||
const fetchUrl = `${url}`;
|
const fetchUrl = `${url}`;
|
||||||
const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(fetchUrl));
|
const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(fetchUrl));
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
|
||||||
|
let ajaxResultHtml = "";
|
||||||
|
try {
|
||||||
|
const parsedAjax = JSON.parse(text);
|
||||||
|
ajaxResultHtml = parsedAjax?.result || "";
|
||||||
|
} catch {}
|
||||||
|
|
||||||
const cleanedHtml = cleanJsonHtml(text);
|
const cleanedHtml = cleanJsonHtml(text);
|
||||||
|
const cleanedAjaxResultHtml = cleanJsonHtml(ajaxResultHtml);
|
||||||
|
const serverHtmlSource = cleanedAjaxResultHtml || cleanedHtml;
|
||||||
|
|
||||||
const subRegex = /<div class="server-items lang-group" data-id="sub"[^>]*>([\s\S]*?)<\/div>/;
|
const subRegex = /<div class="server-items lang-group" data-id="sub"[^>]*>([\s\S]*?)<\/div>/;
|
||||||
const softsubRegex = /<div class="server-items lang-group" data-id="softsub"[^>]*>([\s\S]*?)<\/div>/;
|
const softsubRegex = /<div class="server-items lang-group" data-id="softsub"[^>]*>([\s\S]*?)<\/div>/;
|
||||||
const dubRegex = /<div class="server-items lang-group" data-id="dub"[^>]*>([\s\S]*?)<\/div>/;
|
const dubRegex = /<div class="server-items lang-group" data-id="dub"[^>]*>([\s\S]*?)<\/div>/;
|
||||||
const subMatch = subRegex.exec(cleanedHtml);
|
const subMatch = subRegex.exec(serverHtmlSource);
|
||||||
const softsubMatch = softsubRegex.exec(cleanedHtml);
|
const softsubMatch = softsubRegex.exec(serverHtmlSource);
|
||||||
const dubMatch = dubRegex.exec(cleanedHtml);
|
const dubMatch = dubRegex.exec(serverHtmlSource);
|
||||||
const subContent = subMatch ? subMatch[1].trim() : "";
|
const subContent = subMatch ? subMatch[1].trim() : "";
|
||||||
const softsubContent = softsubMatch ? softsubMatch[1].trim() : "";
|
const softsubContent = softsubMatch ? softsubMatch[1].trim() : "";
|
||||||
const dubContent = dubMatch ? dubMatch[1].trim() : "";
|
const dubContent = dubMatch ? dubMatch[1].trim() : "";
|
||||||
const serverSpanRegex = /<span class="server"[^>]*data-lid="([^"]+)"[^>]*>Server 1<\/span>/;
|
|
||||||
const serverIdDub = serverSpanRegex.exec(dubContent)?.[1];
|
const extractServerId = (content) => {
|
||||||
const serverIdSoftsub = serverSpanRegex.exec(softsubContent)?.[1];
|
if (!content) {
|
||||||
const serverIdSub = serverSpanRegex.exec(subContent)?.[1];
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const preferred = /<span class="server"[^>]*data-lid="([^"]+)"[^>]*>\s*Server\s*1\s*<\/span>/i.exec(content);
|
||||||
|
if (preferred?.[1]) {
|
||||||
|
return preferred[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
const fallback = /<span class="server"[^>]*data-lid="([^"]+)"/i.exec(content);
|
||||||
|
return fallback?.[1] || null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const serverIdDub = extractServerId(dubContent);
|
||||||
|
const serverIdSoftsub = extractServerId(softsubContent);
|
||||||
|
const serverIdSub = extractServerId(subContent);
|
||||||
|
|
||||||
const tokenRequestData = [
|
const tokenRequestData = [
|
||||||
{ name: "Dub", data: serverIdDub },
|
{ name: "Dub", data: serverIdDub },
|
||||||
|
|||||||
Reference in New Issue
Block a user