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,47 +80,46 @@ 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 {
|
||||
const response = await fetchv2(animeUrl);
|
||||
const htmlText = await response.text();
|
||||
|
||||
const actualUrl = url.replace("Animekai:", "").trim();
|
||||
const htmlText = await (await fetchv2(actualUrl)).text();
|
||||
const animeIdMatch = (htmlText.match(/<div class="rate-box"[^>]*data-id="([^"]+)"/) || [])[1];
|
||||
if (!animeIdMatch) {
|
||||
return [{
|
||||
error: "AniID not found"
|
||||
}];
|
||||
}
|
||||
if (!animeIdMatch) return JSON.stringify([{ error: "AniID not found" }]);
|
||||
|
||||
const tokenResponse = await fetchv2(`https://ilovekai.simplepostrequest.workers.dev/?ilovefeet=${encodeURIComponent(animeIdMatch)}`);
|
||||
const token = await tokenResponse.text();
|
||||
const tokenResponse = await fetchv2(`https://enc-dec.app/api/enc-kai?text=${encodeURIComponent(animeIdMatch)}`);
|
||||
const tokenData = await tokenResponse.json();
|
||||
const token = tokenData.result;
|
||||
|
||||
const episodeListUrl = `https://animekai.to/ajax/episodes/list?ani_id=${animeIdMatch}&_=${token}`;
|
||||
|
||||
const episodeListResponse = await fetchv2(episodeListUrl);
|
||||
const episodeListData = await episodeListResponse.json();
|
||||
const episodeListData = await (await fetchv2(episodeListUrl)).json();
|
||||
const cleanedHtml = cleanJsonHtml(episodeListData.result);
|
||||
|
||||
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
|
||||
const episodeMatches = [...cleanedHtml.matchAll(episodeRegex)];
|
||||
|
||||
const episodeData = episodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
||||
const recentEpisodeMatches = episodeMatches.slice(-50);
|
||||
|
||||
const episodeData = recentEpisodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
||||
name: `Episode ${episodeNum}`,
|
||||
data: episodeToken
|
||||
}));
|
||||
|
||||
const batchResponse = await fetchv2(
|
||||
"https://ilovekai.simplepostrequest.workers.dev/?ilovefeet",
|
||||
{},
|
||||
"POST",
|
||||
JSON.stringify(episodeData)
|
||||
);
|
||||
|
||||
const batchResults = await batchResponse.json();
|
||||
const batchResults = await sendEpisodes("https://enc-dec.app/api/enc-kai?text", episodeData);
|
||||
|
||||
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}`
|
||||
number: parseInt(recentEpisodeMatches[index][1], 10),
|
||||
href: `https://animekai.to/ajax/links/list?token=${recentEpisodeMatches[index][2]}&_=${result.data}`
|
||||
}));
|
||||
|
||||
return JSON.stringify(episodes);
|
||||
|
|
@ -159,13 +158,13 @@ async function extractStreamUrl(url) {
|
|||
{ name: "Sub", data: serverIdSub }
|
||||
].filter(item => item.data);
|
||||
|
||||
const tokenBatchResponse = await fetchv2(
|
||||
"https://ilovekai.simplepostrequest.workers.dev/?ilovefeet",
|
||||
{},
|
||||
"POST",
|
||||
JSON.stringify(tokenRequestData)
|
||||
const tokenPromises = tokenRequestData.map(item =>
|
||||
fetchv2(`https://enc-dec.app/api/enc-kai?text=${encodeURIComponent(item.data)}`)
|
||||
.then(res => res.json())
|
||||
.then(json => ({ name: item.name, data: json.result }))
|
||||
.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 serverIdMap = {
|
||||
|
|
@ -210,13 +209,13 @@ async function extractStreamUrl(url) {
|
|||
return {};
|
||||
}
|
||||
|
||||
const decryptBatchResponse = await fetchv2(
|
||||
"https://ilovekai.simplepostrequest.workers.dev/?ilovearmpits",
|
||||
{},
|
||||
"POST",
|
||||
JSON.stringify(decryptRequestData)
|
||||
const decryptPromises = decryptRequestData.map(item =>
|
||||
fetchv2(`https://enc-dec.app/api/dec-kai?text=${encodeURIComponent(item.data)}`)
|
||||
.then(res => res.json())
|
||||
.then(json => ({ name: item.name, data: JSON.stringify(json.result) }))
|
||||
.catch(err => ({ name: item.name, error: err.toString() }))
|
||||
);
|
||||
const decryptResults = await decryptBatchResponse.json();
|
||||
const decryptResults = await Promise.all(decryptPromises);
|
||||
|
||||
const finalResults = {};
|
||||
decryptResults.forEach(result => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue