Update animekai/hardsub/animekai.js

This commit is contained in:
aka paul 2025-12-28 13:57:54 +00:00
parent a68dd1d709
commit b20283d1bc

View file

@ -1,7 +1,7 @@
async function searchResults(query) {
const encodeQuery = keyword => encodeURIComponent(keyword);
const searchBaseUrl = "https://animekai.to/browser?keyword=";
const baseUrl = "https://animekai.to";
const searchBaseUrl = "https://anikai.to/browser?keyword=";
const baseUrl = "https://anikai.to";
const posterHrefRegex = /href="[^"]*" class="poster"/g;
const titleRegex = /class="title"[^>]*title="[^"]*"/g;
@ -13,7 +13,7 @@ async function searchResults(query) {
try {
const encodedQuery = encodeQuery(query);
const searchUrl = searchBaseUrl + encodedQuery;
const response = await fetchv2(searchUrl);
const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(searchUrl));
const htmlText = await response.text();
const results = [];
@ -58,7 +58,7 @@ async function searchResults(query) {
async function extractDetails(url) {
try {
const response = await fetchv2(url);
const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(url));
const htmlText = await response.text();
console.log(htmlText);
@ -83,7 +83,7 @@ async function extractDetails(url) {
async function extractEpisodes(url) {
try {
const actualUrl = url.replace("Animekai:", "").trim();
const htmlText = await (await fetchv2(actualUrl)).text();
const htmlText = await (await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(actualUrl))).text();
const animeIdMatch = (htmlText.match(/<div class="rate-box"[^>]*data-id="([^"]+)"/) || [])[1];
if (!animeIdMatch) return JSON.stringify([{ error: "AniID not found" }]);
@ -91,8 +91,8 @@ async function extractEpisodes(url) {
const tokenData = await tokenResponse.json();
const token = tokenData.result;
const episodeListUrl = `https://animekai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`;
const episodeListData = await (await fetchv2(episodeListUrl)).json();
const episodeListUrl = `https://anikai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`;
const episodeListData = await (await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(episodeListUrl))).json();
const cleanedHtml = cleanJsonHtml(episodeListData.result);
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
@ -100,7 +100,7 @@ async function extractEpisodes(url) {
const episodes = episodeMatches.map(([_, episodeNum, episodeToken]) => ({
number: parseInt(episodeNum, 10),
href: `https://animekai.to/ajax/links/list?token=${episodeToken}&_=ENCRYPT_ME`
href: `https://anikai.to/ajax/links/list?token=${episodeToken}&_=ENCRYPT_ME`
}));
return JSON.stringify(episodes);
@ -125,7 +125,7 @@ async function extractStreamUrl(url) {
}
const fetchUrl = `${url}`;
const response = await fetchv2(fetchUrl);
const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(fetchUrl));
const text = await response.text();
const cleanedHtml = cleanJsonHtml(text);
const subRegex = /<div class="server-items lang-group" data-id="sub"[^>]*>([\s\S]*?)<\/div>/;
@ -164,7 +164,7 @@ async function extractStreamUrl(url) {
};
return {
type: result.name,
url: `https://animekai.to/ajax/links/view?id=${serverIdMap[result.name]}&_=${result.data}`
url: `https://anikai.to/ajax/links/view?id=${serverIdMap[result.name]}&_=${result.data}`
};
});
@ -172,7 +172,7 @@ async function extractStreamUrl(url) {
const streamResponses = await Promise.all(
streamUrls.map(async ({ type, url }) => {
try {
const res = await fetchv2(url);
const res = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(url));
const json = await res.json();
return {
type: type,
@ -227,7 +227,7 @@ async function extractStreamUrl(url) {
console.log(decryptedSub);
const headers = {
"Referer": "https://animekai.to/",
"Referer": "https://anikai.to/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"
};