From 870add0f82d97f86198ee70a5cd8ba3a4d8acc70 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Wed, 26 Nov 2025 22:42:31 +0000 Subject: [PATCH] Add anihq/anihq.js --- anihq/anihq.js | 147 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 anihq/anihq.js diff --git a/anihq/anihq.js b/anihq/anihq.js new file mode 100644 index 0000000..df70684 --- /dev/null +++ b/anihq/anihq.js @@ -0,0 +1,147 @@ +async function searchResults(keyword) { + const results = []; + try { + const response = await fetchv2("https://anihq.to/search/?s_keyword=" + encodeURIComponent(keyword)); + const html = await response.text(); + + const regex = /
]*alt=['"]([^'"]+)['"][\s\S]*?]+href=['"]([^'"]+)['"][\s\S]*?<\/div>\s*<\/div>/g; + + let match; + while ((match = regex.exec(html)) !== null) { + results.push({ + title: match[2].trim(), + image: match[1].trim(), + href: match[3].trim() + }); + } + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + title: "Error", + image: "Error", + href: "Error" + }]); + } +} + +async function extractDetails(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + + const descMatch = html.match(/]*>([\s\S]*?)<\/div>/); + let description = "N/A"; + + if (descMatch) { + description = descMatch[1] + .trim() + .replace(/<[^>]+>/g, '') + .replace(/\s+/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(); + + const watchUrlMatch = html.match(/]*class="[^"]*episode-list-item[^"]*"[^>]*data-episode-search-query="(\d+)"[\s\S]*?\s*(\d+)\s*<\/span>/g; + + let match; + while ((match = episodeRegex.exec(watchHtml)) !== null) { + results.push({ + href: match[1].trim(), + number: parseInt(match[2], 10) + }); + } + + if (results.length === 0) { + return JSON.stringify([{ + href: watchUrl, + number: 1 + }]); + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + href: "Error: " + err.message, + number: "Error" + }]); + } +} + +async function extractStreamUrl(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + + const iframeMatch = html.match(/(?:data-lazy-src|src)=["']https:\/\/(anihqq?\.strp2p\.com)\/#([^"']+)["']/); + + if (!iframeMatch) { + console.log("No iframe ID found"); + return "https://error.org/"; + } + + const domain = iframeMatch[1]; + const videoId = iframeMatch[2]; + + const apiUrl = `https://${domain}/api/v1/video?id=${videoId}&w=1792&h=1120&r=anihq.to`; + const apiResponse = await fetchv2(apiUrl); + const encodedString = await apiResponse.text(); + + const hasUppercase = /[A-Z]/.test(encodedString); + + let stringToSend; + if (hasUppercase) { + stringToSend = atob(encodedString); + console.log("Decoded string: " + stringToSend); + } else { + stringToSend = encodedString; + console.log("Using encoded string directly (no uppercase found)"); + } + + const postData = { + text: stringToSend + }; + const headers = { "Content-Type": "application/json" }; + const response2 = await fetchv2("https://enc-dec.app/api/dec-vidstack", headers, "POST", postData); + const data = await response2.json(); + console.log(JSON.stringify(data)); + console.log("Final URL: " + data.result.source); + return data.result.cf; + + } catch (err) { + console.log("Error: " + err.message); + return "https://error.org/"; + } +} \ No newline at end of file