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) { async function searchResults(query) {
const encodeQuery = keyword => encodeURIComponent(keyword); const encodeQuery = keyword => encodeURIComponent(keyword);
const searchBaseUrl = "https://animekai.to/browser?keyword="; const searchBaseUrl = "https://anikai.to/browser?keyword=";
const baseUrl = "https://animekai.to"; const baseUrl = "https://anikai.to";
const posterHrefRegex = /href="[^"]*" class="poster"/g; const posterHrefRegex = /href="[^"]*" class="poster"/g;
const titleRegex = /class="title"[^>]*title="[^"]*"/g; const titleRegex = /class="title"[^>]*title="[^"]*"/g;
@ -13,7 +13,7 @@ async function searchResults(query) {
try { try {
const encodedQuery = encodeQuery(query); const encodedQuery = encodeQuery(query);
const searchUrl = searchBaseUrl + encodedQuery; 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 htmlText = await response.text();
const results = []; const results = [];
@ -58,7 +58,7 @@ async function searchResults(query) {
async function extractDetails(url) { async function extractDetails(url) {
try { try {
const response = await fetchv2(url); const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(url));
const htmlText = await response.text(); const htmlText = await response.text();
console.log(htmlText); console.log(htmlText);
@ -83,7 +83,7 @@ async function extractDetails(url) {
async function extractEpisodes(url) { async function extractEpisodes(url) {
try { try {
const actualUrl = url.replace("Animekai:", "").trim(); 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]; const animeIdMatch = (htmlText.match(/<div class="rate-box"[^>]*data-id="([^"]+)"/) || [])[1];
if (!animeIdMatch) return JSON.stringify([{ error: "AniID not found" }]); if (!animeIdMatch) return JSON.stringify([{ error: "AniID not found" }]);
@ -91,8 +91,8 @@ async function extractEpisodes(url) {
const tokenData = await tokenResponse.json(); const tokenData = await tokenResponse.json();
const token = tokenData.result; const token = tokenData.result;
const episodeListUrl = `https://animekai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`; const episodeListUrl = `https://anikai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`;
const episodeListData = await (await fetchv2(episodeListUrl)).json(); const episodeListData = await (await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(episodeListUrl))).json();
const cleanedHtml = cleanJsonHtml(episodeListData.result); const cleanedHtml = cleanJsonHtml(episodeListData.result);
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g; const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
@ -100,7 +100,7 @@ async function extractEpisodes(url) {
const episodes = episodeMatches.map(([_, episodeNum, episodeToken]) => ({ const episodes = episodeMatches.map(([_, episodeNum, episodeToken]) => ({
number: parseInt(episodeNum, 10), 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); return JSON.stringify(episodes);
@ -125,7 +125,7 @@ async function extractStreamUrl(url) {
} }
const fetchUrl = `${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 text = await response.text();
const cleanedHtml = cleanJsonHtml(text); const cleanedHtml = cleanJsonHtml(text);
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>/;
@ -164,7 +164,7 @@ async function extractStreamUrl(url) {
}; };
return { return {
type: result.name, 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( const streamResponses = await Promise.all(
streamUrls.map(async ({ type, url }) => { streamUrls.map(async ({ type, url }) => {
try { try {
const res = await fetchv2(url); const res = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(url));
const json = await res.json(); const json = await res.json();
return { return {
type: type, type: type,
@ -227,7 +227,7 @@ async function extractStreamUrl(url) {
console.log(decryptedSub); console.log(decryptedSub);
const headers = { 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" "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"
}; };