mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-22 13:46:29 +01:00
Update animekai/hardsub/animekai.js
This commit is contained in:
parent
918c7b0eb0
commit
ce5beb6d5b
1 changed files with 16 additions and 26 deletions
|
|
@ -81,16 +81,6 @@ async function extractDetails(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractEpisodes(url) {
|
async function extractEpisodes(url) {
|
||||||
const sendEpisodes = async (endpoint, episodeData) => {
|
|
||||||
const promises = episodeData.map(item =>
|
|
||||||
fetchv2(`${endpoint}=${encodeURIComponent(item.data)}`)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(json => ({ name: item.name, data: json.result }))
|
|
||||||
.catch(err => ({ name: item.name, error: err.toString() }))
|
|
||||||
);
|
|
||||||
return Promise.all(promises);
|
|
||||||
};
|
|
||||||
|
|
||||||
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(actualUrl)).text();
|
||||||
|
|
@ -108,18 +98,9 @@ async function extractEpisodes(url) {
|
||||||
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
|
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
|
||||||
const episodeMatches = [...cleanedHtml.matchAll(episodeRegex)];
|
const episodeMatches = [...cleanedHtml.matchAll(episodeRegex)];
|
||||||
|
|
||||||
const recentEpisodeMatches = episodeMatches.slice(-50);
|
const episodes = episodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
||||||
|
number: parseInt(episodeNum, 10),
|
||||||
const episodeData = recentEpisodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
href: `https://animekai.to/ajax/links/list?token=${episodeToken}&_=ENCRYPT_ME`
|
||||||
name: `Episode ${episodeNum}`,
|
|
||||||
data: episodeToken
|
|
||||||
}));
|
|
||||||
|
|
||||||
const batchResults = await sendEpisodes("https://enc-dec.app/api/enc-kai?text", episodeData);
|
|
||||||
|
|
||||||
const episodes = batchResults.map((result, index) => ({
|
|
||||||
number: parseInt(recentEpisodeMatches[index][1], 10),
|
|
||||||
href: `https://animekai.to/ajax/links/list?token=${recentEpisodeMatches[index][2]}&_=${result.data}`
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return JSON.stringify(episodes);
|
return JSON.stringify(episodes);
|
||||||
|
|
@ -134,6 +115,15 @@ async function extractEpisodes(url) {
|
||||||
|
|
||||||
async function extractStreamUrl(url) {
|
async function extractStreamUrl(url) {
|
||||||
try {
|
try {
|
||||||
|
const tokenMatch = url.match(/token=([^&]+)/);
|
||||||
|
if (tokenMatch && tokenMatch[1]) {
|
||||||
|
const rawToken = tokenMatch[1];
|
||||||
|
const encryptResponse = await fetchv2(`https://enc-dec.app/api/enc-kai?text=${encodeURIComponent(rawToken)}`);
|
||||||
|
const encryptData = await encryptResponse.json();
|
||||||
|
const encryptedToken = encryptData.result;
|
||||||
|
url = url.replace('&_=ENCRYPT_ME', `&_=${encryptedToken}`);
|
||||||
|
}
|
||||||
|
|
||||||
const fetchUrl = `${url}`;
|
const fetchUrl = `${url}`;
|
||||||
const response = await fetchv2(fetchUrl);
|
const response = await fetchv2(fetchUrl);
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
|
@ -233,16 +223,16 @@ async function extractStreamUrl(url) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const decryptedUrls = await processStreams(streamUrls);
|
const decryptedUrls = await processStreams(streamUrls);
|
||||||
const decryptedDub = decryptedUrls.Sub || decryptedUrls.Dub || decryptedUrls.Softsub;
|
const decryptedSub = decryptedUrls.Sub || decryptedUrls.Dub || decryptedUrls.Softsub;
|
||||||
|
|
||||||
console.log(decryptedDub);
|
console.log(decryptedSub);
|
||||||
const headers = {
|
const headers = {
|
||||||
"Referer": "https://animekai.to/",
|
"Referer": "https://animekai.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"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (decryptedDub) {
|
if (decryptedSub) {
|
||||||
const response = await fetchv2(decryptedDub.replace("/e/", "/media/"), headers);
|
const response = await fetchv2(decryptedSub.replace("/e/", "/media/"), headers);
|
||||||
const responseJson = await response.json();
|
const responseJson = await response.json();
|
||||||
|
|
||||||
const result = responseJson?.result;
|
const result = responseJson?.result;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue