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
3e38da15b7
commit
918c7b0eb0
1 changed files with 12 additions and 22 deletions
|
|
@ -81,16 +81,6 @@ async function extractDetails(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 {
|
||||
const actualUrl = url.replace("Animekai:", "").trim();
|
||||
const htmlText = await (await fetchv2(actualUrl)).text();
|
||||
|
|
@ -108,18 +98,9 @@ async function extractEpisodes(url) {
|
|||
const episodeRegex = /<a[^>]+num="([^"]+)"[^>]+token="([^"]+)"[^>]*>/g;
|
||||
const episodeMatches = [...cleanedHtml.matchAll(episodeRegex)];
|
||||
|
||||
const recentEpisodeMatches = episodeMatches.slice(-50);
|
||||
|
||||
const episodeData = recentEpisodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
||||
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}`
|
||||
const episodes = episodeMatches.map(([_, episodeNum, episodeToken]) => ({
|
||||
number: parseInt(episodeNum, 10),
|
||||
href: `https://animekai.to/ajax/links/list?token=${episodeToken}&_=ENCRYPT_ME`
|
||||
}));
|
||||
|
||||
return JSON.stringify(episodes);
|
||||
|
|
@ -134,6 +115,15 @@ async function extractEpisodes(url) {
|
|||
|
||||
async function extractStreamUrl(url) {
|
||||
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 response = await fetchv2(fetchUrl);
|
||||
const text = await response.text();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue