async function searchResults(keyword) { const response = await fetchv2(`https://v6.kuramanime.run/anime?search=${keyword}&order_by=oldest`); const html = await response.text(); const results = []; const animeEntryRegex = /
]*>([\s\S]*?)<\/p>/);
const description = descriptionMatch ?
descriptionMatch[1]
.replace(/<\/?[^>]+(>|$)/g, '')
.replace(/\s+/g, ' ')
.trim() :
'N/A';
details.push({
description: description,
aliases: 'N/A',
airdate: 'N/A'
});
console.log(details);
return JSON.stringify(details);
}
async function extractEpisodes(url) {
const response = await fetchv2(url);
const html = await response.text();
const episodes = [];
const oldestMatch = html.match(/]*>\s*Ep\s*\d+\s*\(Terlama\)/i);
const newestMatch = html.match(/]*>\s*Ep\s*\d+\s*\(Terbaru\)/i);
if (oldestMatch && newestMatch) {
const firstEpisode = parseInt(oldestMatch[2], 10);
const lastEpisode = parseInt(newestMatch[2], 10);
for (let i = firstEpisode; i <= lastEpisode; i++) {
episodes.push({
href: `${url}/episode/${i}`,
number: i
});
}
} else {
const episodeLinks = [...html.matchAll(/]*>\s*Ep\s*\d+/gi)];
if (episodeLinks.length > 0) {
for (const match of episodeLinks) {
episodes.push({
href: match[1],
number: parseInt(match[2], 10)
});
}
} else {
episodes.push({
href: `${url}/episode/1`,
number: 1
});
}
}
console.error("Extracted episodes:" + JSON.stringify(episodes));
return JSON.stringify(episodes);
}
async function extractStreamUrl(url) {
const response = await fetchv2(url);
const html = await response.text();
const firstCodeMatch = /data-kk="([^"]+)"/.exec(html);
if (!firstCodeMatch) return null;
const firstCode = firstCodeMatch[1];
const responseTwo = await fetchv2(`https://v6.kuramanime.run/assets/js/${firstCode}.js`);
const htmlTwo = await responseTwo.text();
const authRouteMatch = /MIX_AUTH_ROUTE_PARAM:\s*'([^']+)'/.exec(htmlTwo);
const pageTokenMatch = /MIX_PAGE_TOKEN_KEY:\s*'([^']+)'/.exec(htmlTwo);
const streamServerMatch = /MIX_STREAM_SERVER_KEY:\s*'([^']+)'/.exec(htmlTwo);
const authRouteParam = authRouteMatch ? authRouteMatch[1] : null;
const pageTokenKey = pageTokenMatch ? pageTokenMatch[1] : null;
const streamServerKey = streamServerMatch ? streamServerMatch[1] : null;
const responseThree = await fetchv2(`https://v6.kuramanime.run/assets/${authRouteParam}`);
const thirdRandomAssCode = await responseThree.text();
const fullUrl = `${url}?${pageTokenMatch}=${thirdRandomAssCode}&${streamServerMatch}=kuramadrive&page=1`
const fullUrlClean = cleanUrl(fullUrl);
console.error(fullUrlClean);
const responseFour = await fetchv2(fullUrlClean);
const actualHtml = await responseFour.text();
const mp4SourceMatch = actualHtml.match(/