mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update animekai/dub/animekai.js
This commit is contained in:
parent
9e3a7a915a
commit
725ef91131
1 changed files with 54 additions and 55 deletions
|
|
@ -80,50 +80,49 @@ async function extractDetails(url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractEpisodes(animeUrl) {
|
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 response = await fetchv2(animeUrl);
|
const actualUrl = url.replace("Animekai:", "").trim();
|
||||||
const htmlText = await response.text();
|
const htmlText = await (await fetchv2(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 [{
|
const tokenResponse = await fetchv2(`https://enc-dec.app/api/enc-kai?text=${encodeURIComponent(animeIdMatch)}`);
|
||||||
error: "AniID not found"
|
const tokenData = await tokenResponse.json();
|
||||||
}];
|
const token = tokenData.result;
|
||||||
}
|
|
||||||
|
const episodeListUrl = `https://animekai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`;
|
||||||
const tokenResponse = await fetchv2(`https://ilovekai.simplepostrequest.workers.dev/?ilovefeet=${encodeURIComponent(animeIdMatch)}`);
|
const episodeListData = await (await fetchv2(episodeListUrl)).json();
|
||||||
const token = await tokenResponse.text();
|
const cleanedHtml = cleanJsonHtml(episodeListData.result);
|
||||||
|
|
||||||
const episodeListUrl = `https://animekai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`;
|
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
|
||||||
|
const episodeMatches = [...cleanedHtml.matchAll(episodeRegex)];
|
||||||
const episodeListResponse = await fetchv2(episodeListUrl);
|
|
||||||
const episodeListData = await episodeListResponse.json();
|
const recentEpisodeMatches = episodeMatches.slice(-50);
|
||||||
const cleanedHtml = cleanJsonHtml(episodeListData.result);
|
|
||||||
|
const episodeData = recentEpisodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
||||||
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
|
name: `Episode ${episodeNum}`,
|
||||||
const episodeMatches = [...cleanedHtml.matchAll(episodeRegex)];
|
data: episodeToken
|
||||||
|
}));
|
||||||
const episodeData = episodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
|
||||||
name: `Episode ${episodeNum}`,
|
const batchResults = await sendEpisodes("https://enc-dec.app/api/enc-kai?text", episodeData);
|
||||||
data: episodeToken
|
|
||||||
}));
|
const episodes = batchResults.map((result, index) => ({
|
||||||
|
number: parseInt(recentEpisodeMatches[index][1], 10),
|
||||||
const batchResponse = await fetchv2(
|
href: `https://animekai.to/ajax/links/list?token=${recentEpisodeMatches[index][2]}&_=${result.data}`
|
||||||
"https://ilovekai.simplepostrequest.workers.dev/?ilovefeet",
|
}));
|
||||||
{},
|
|
||||||
"POST",
|
return JSON.stringify(episodes);
|
||||||
JSON.stringify(episodeData)
|
|
||||||
);
|
|
||||||
|
|
||||||
const batchResults = await batchResponse.json();
|
|
||||||
|
|
||||||
const episodes = batchResults.map((result, index) => ({
|
|
||||||
number: parseInt(episodeMatches[index][1], 10),
|
|
||||||
href: `https://animekai.to/ajax/links/list?token=${episodeMatches[index][2]}&_=${result.data}`
|
|
||||||
}));
|
|
||||||
|
|
||||||
return JSON.stringify(episodes);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error fetching episodes:" + err);
|
console.error("Error fetching episodes:" + err);
|
||||||
return [{
|
return [{
|
||||||
|
|
@ -159,13 +158,13 @@ async function extractStreamUrl(url) {
|
||||||
{ name: "Sub", data: serverIdSub }
|
{ name: "Sub", data: serverIdSub }
|
||||||
].filter(item => item.data);
|
].filter(item => item.data);
|
||||||
|
|
||||||
const tokenBatchResponse = await fetchv2(
|
const tokenPromises = tokenRequestData.map(item =>
|
||||||
"https://ilovekai.simplepostrequest.workers.dev/?ilovefeet",
|
fetchv2(`https://enc-dec.app/api/enc-kai?text=${encodeURIComponent(item.data)}`)
|
||||||
{},
|
.then(res => res.json())
|
||||||
"POST",
|
.then(json => ({ name: item.name, data: json.result }))
|
||||||
JSON.stringify(tokenRequestData)
|
.catch(err => ({ name: item.name, error: err.toString() }))
|
||||||
);
|
);
|
||||||
const tokenResults = await tokenBatchResponse.json();
|
const tokenResults = await Promise.all(tokenPromises);
|
||||||
|
|
||||||
const streamUrls = tokenResults.map(result => {
|
const streamUrls = tokenResults.map(result => {
|
||||||
const serverIdMap = {
|
const serverIdMap = {
|
||||||
|
|
@ -210,13 +209,13 @@ async function extractStreamUrl(url) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const decryptBatchResponse = await fetchv2(
|
const decryptPromises = decryptRequestData.map(item =>
|
||||||
"https://ilovekai.simplepostrequest.workers.dev/?ilovearmpits",
|
fetchv2(`https://enc-dec.app/api/dec-kai?text=${encodeURIComponent(item.data)}`)
|
||||||
{},
|
.then(res => res.json())
|
||||||
"POST",
|
.then(json => ({ name: item.name, data: JSON.stringify(json.result) }))
|
||||||
JSON.stringify(decryptRequestData)
|
.catch(err => ({ name: item.name, error: err.toString() }))
|
||||||
);
|
);
|
||||||
const decryptResults = await decryptBatchResponse.json();
|
const decryptResults = await Promise.all(decryptPromises);
|
||||||
|
|
||||||
const finalResults = {};
|
const finalResults = {};
|
||||||
decryptResults.forEach(result => {
|
decryptResults.forEach(result => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue