/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////// Main Functions ////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// async function searchResults(keyword) { try { const encodedKeyword = encodeURIComponent(keyword); const searchApiUrl = `https://s.to/suche?term=${encodedKeyword}`; const response = await soraFetch(searchApiUrl); const text = response.text ? await response.text() : await response; // parse html /*
... */ const searchRegex = /]*>([\s\S]*?)<\//g; const results = []; let match; while ((match = searchRegex.exec(text)) !== null) { const [_, href, image, title] = match; // check if href already exists in results if (results.some(result => result.href === href.trim())) { continue; } results.push({ title: title.trim(), image: image.trim(), href: href.trim() }); } console.log("Search Results: " + JSON.stringify(results)); return JSON.stringify(results); } catch (error) { sendLog('Fetch error:' + error); return JSON.stringify([{ title: 'Error', image: '', href: '' }]); } } async function extractDetails(url) { try { const fetchUrl = `${url}`; const response = await soraFetch(fetchUrl); const text = response.text ? await response.text() : await response; // get description const descriptionRegex = /]*>([\s\S]*?)<\/span>/; const descriptionMatch = descriptionRegex.exec(text); let description = descriptionMatch ? descriptionMatch[1].trim() : 'No description available'; description = description.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'"); // get year (airdate) 2025 const yearRegex = /(\d{4})<\/a>/; const yearMatch = yearRegex.exec(text); const airdateMatch = yearMatch ? `${yearMatch[1]}` : 'Unknown Year'; // get genres /*