async function searchResults(keyword) { const results = []; try { const response = await fetchv2("https://animenana.com/search/?key=" + keyword); const html = await response.text(); const cardMatches = html.match(/
Description:\s*<\/b><\/p>([\s\S]*?)
/i;
const match = regex.exec(html);
let description = match ? match[1].trim() : "N/A";
description = description.replace(/<[^>]+>/g, "").trim();
return JSON.stringify([{
description: description,
aliases: "N/A",
airdate: "N/A"
}]);
} catch (err) {
return JSON.stringify([{
description: "Error",
aliases: "Error",
airdate: "Error"
}]);
}
}
async function extractEpisodes(url) {
const results = [];
try {
const response = await fetchv2(url);
const html = await response.text();
// More flexible regex to handle the actual HTML structure
const epRegex = /]*title="[^"]*Episode\s*(\d+)">/g;
let match;
while ((match = epRegex.exec(html)) !== null) {
results.push({
href: "https://animenana.com" + match[1].trim(),
number: parseInt(match[2], 10)
});
}
const specialRegex = /]*>([^<]+)<\/span>[\s\S]*?]*>[\s\S]*?([^<]+)<\/h5>/g;
while ((match = specialRegex.exec(html)) !== null) {
results.push({
href: "https://animenana.com" + match[2].trim(),
number: 1
});
}
if (results.length >= 2 && results[0].number > results[1].number) {
results.reverse();
results.forEach((item, index) => {
item.number = index + 1;
});
}
if (results.length === 0) {
results.push({
href: url,
number: 1
});
}
return JSON.stringify(results);
} catch (err) {
return JSON.stringify([{
href: "Error",
number: "Error",
type: "Error"
}]);
}
}
async function extractStreamUrl(url) {
try {
const response = await fetchv2(url);
const html = await response.text();
const fmRegex = /function\s+fm\(\)\s*\{[^}]*document\.getElementById\("videowrapper"\)\.innerHTML\s*=\s*['"]