function cleanTitle(title) { return title .replace(/’/g, "'") .replace(/–/g, "-") .replace(/&#[0-9]+;/g, ""); } async function searchResults(keyword) { const results = []; const response = await fetchv2(`https://estrenosdoramas.es/?s=${keyword}`); const html = await response.text(); const regex = /]*class="[^"]*bs[^"]*"[^>]*>.*?]*>.*?
\s*(.*?)\s*<\/div>.*?]*src="([^"]+)"[^>]*>/gs; let match; while ((match = regex.exec(html)) !== null) { results.push({ title: cleanTitle(match[2].trim()), image: match[3].trim(), href: match[1].trim() }); } return JSON.stringify(results); } async function extractDetails(url) { const results = []; const response = await fetchv2(url); const html = await response.text(); const match = html.match(/
]*>([\s\S]*?)<\/div>/); let description = "N/A"; if (match) { description = match[1] .replace(/<[^>]+>/g, '') .replace(/&#(\d+);/g, (_, code) => String.fromCharCode(code)) .replace(/"/g, '"') .replace(/'/g, "'") .replace(/&/g, "&") .trim(); } results.push({ description: description, aliases: 'N/A', airdate: 'N/A' }); return JSON.stringify(results); } async function extractEpisodes(url) { const results = []; const response = await fetchv2(url); const html = await response.text(); const regex = /]*id="epcheck"[^>]*>[\s\S]*?/g; let match; while ((match = regex.exec(html)) !== null) { results.push(match[1].trim()); } const total = results.length; const final = results.map((href, index) => ({ href: href, number: total - index })); return JSON.stringify(final.reverse()); } async function extractStreamUrl(url) { try { const response = await fetchv2(url); const html = await response.text(); const embedMatch = html.match(/