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