mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
Update ashi/ashi.js
This commit is contained in:
parent
0657a08f78
commit
8be9d368b1
1 changed files with 31 additions and 33 deletions
64
ashi/ashi.js
64
ashi/ashi.js
|
|
@ -260,8 +260,8 @@ async function searchResults(query) {
|
|||
}));
|
||||
|
||||
const filteredResults = scoredResults
|
||||
.filter(r => r.score > 50) // Increased threshold to filter out weak matches
|
||||
.sort((a, b) => b.score - a.score) // Sort by pre-calculated scores
|
||||
.filter(r => r.score > 50)
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.map(({ score, ...rest }) => rest);
|
||||
|
||||
return JSON.stringify(filteredResults.length > 0 ? filteredResults : [{
|
||||
|
|
@ -330,18 +330,13 @@ async function extractDetails(url) {
|
|||
|
||||
async function extractEpisodes(url) {
|
||||
const sendEpisodes = async (endpoint, episodeData) => {
|
||||
if (episodeData.length > 45) {
|
||||
const promises = episodeData.map(item =>
|
||||
fetchv2(`${endpoint}=${encodeURIComponent(item.data)}`)
|
||||
.then(res => res.text())
|
||||
.then(data => ({ name: item.name, data }))
|
||||
.catch(err => ({ name: item.name, error: err.toString() }))
|
||||
);
|
||||
return Promise.all(promises);
|
||||
} else {
|
||||
const resp = await fetchv2(endpoint, {}, "POST", JSON.stringify(episodeData));
|
||||
return resp.json();
|
||||
}
|
||||
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 {
|
||||
|
|
@ -351,8 +346,9 @@ async function extractEpisodes(url) {
|
|||
const animeIdMatch = (htmlText.match(/<div class="rate-box"[^>]*data-id="([^"]+)"/) || [])[1];
|
||||
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 episodeListData = await (await fetchv2(episodeListUrl)).json();
|
||||
|
|
@ -361,16 +357,18 @@ async function extractEpisodes(url) {
|
|||
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 batchResults = await sendEpisodes("https://ilovekai.simplepostrequest.workers.dev/?ilovefeet", episodeData);
|
||||
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: `Animekai:https://animekai.to/ajax/links/list?token=${episodeMatches[index][2]}&_=${result.data}`
|
||||
number: parseInt(recentEpisodeMatches[index][1], 10),
|
||||
href: `Animekai:https://animekai.to/ajax/links/list?token=${recentEpisodeMatches[index][2]}&_=${result.data}`
|
||||
}));
|
||||
|
||||
return JSON.stringify(episodes);
|
||||
|
|
@ -450,13 +448,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 = {
|
||||
|
|
@ -501,13 +499,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 => {
|
||||
|
|
@ -569,7 +567,7 @@ async function extractStreamUrl(url) {
|
|||
if (dubStream) streams.push("Dubbed English", dubStream);
|
||||
|
||||
const rawStream = decryptedRaw ? await getStream(decryptedRaw) : null;
|
||||
if (rawStream) streams.push("Japanese", rawStream);
|
||||
if (rawStream) streams.push("Original audio", rawStream);
|
||||
|
||||
const final = {
|
||||
streams,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue