function searchResults(html) { if (typeof html !== 'string') { console.error('Invalid HTML input: expected a string.'); return []; } const results = []; const titleRegex = /
[\s\S]*?<\/p>\s*)+)<\/div>/); let description = ""; if (containerMatch) { const pBlock = containerMatch[1]; const pRegex = /
([\s\S]*?)<\/p>/g; const matches = [...pBlock.matchAll(pRegex)] .map(m => m[1].trim()) .filter(text => text.length > 0); description = decodeHTMLEntities(matches.join("\n\n")); } const airdateMatch = html.match(/
]*>([^<]+)<\\/p>`, 'g' ); let m; while ((m = episodeRegex.exec(html)) !== null) { const num = Number(m[1]); if (num > currentEp) { nextEpNum = num; nextDuration = m[2].trim(); nextSubtitle = m[3].trim(); break; } } } if (nextEpNum != null) { embedUrl += `&next-title=${encodeURIComponent(nextDuration)}`; embedUrl += `&next-sub-title=${encodeURIComponent(nextSubtitle)}`; } const result = { streams: qualities, } console.log(JSON.stringify(result)); return JSON.stringify(result); } catch (err) { console.error(err); return null; } } function extractQualities(html) { const match = html.match(/var\s+videos\s*=\s*(\[[\s\S]*?\]);/); if (!match) return []; const raw = match[1]; const regex = /\{\s*src:\s*'([^']+)'\s*[^}]*label:\s*'([^']*)'/g; const list = []; let m; while ((m = regex.exec(raw)) !== null) { list.push(m[2], m[1]); } return list; } function decodeHTMLEntities(text) { text = text.replace(/(\d+);/g, (match, dec) => String.fromCharCode(dec)); const entities = { '"': '"', '&': '&', ''': "'", '<': '<', '>': '>' }; for (const entity in entities) { text = text.replace(new RegExp(entity, 'g'), entities[entity]); } return text; }