From 892c83e5b05dd0e23573c43e2148003241832e31 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Mon, 2 Mar 2026 14:51:42 +0000 Subject: [PATCH] Add animekai/animekai.js --- animekai/animekai.js | 324 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 324 insertions(+) create mode 100644 animekai/animekai.js diff --git a/animekai/animekai.js b/animekai/animekai.js new file mode 100644 index 0000000..7550ae4 --- /dev/null +++ b/animekai/animekai.js @@ -0,0 +1,324 @@ +async function searchResults(query) { + const encodeQuery = keyword => encodeURIComponent(keyword); + const searchBaseUrl = "https://anikai.to/browser?keyword="; + const baseUrl = "https://anikai.to"; + + const posterHrefRegex = /href="[^"]*" class="poster"/g; + const titleRegex = /class="title"[^>]*title="[^"]*"/g; + const imageRegex = /data-src="[^"]*"/g; + const extractHrefRegex = /href="([^"]*)"/; + const extractImageRegex = /data-src="([^"]*)"/; + const extractTitleRegex = /title="([^"]*)"/; + + try { + const encodedQuery = encodeQuery(query); + const searchUrl = searchBaseUrl + encodedQuery; + const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(searchUrl)); + const htmlText = await response.text(); + + const results = []; + const posterMatches = htmlText.match(posterHrefRegex) || []; + const titleMatches = htmlText.match(titleRegex) || []; + const imageMatches = htmlText.match(imageRegex) || []; + + const minLength = Math.min(posterMatches.length, titleMatches.length, imageMatches.length); + + for (let index = 0; index < minLength; index++) { + const hrefMatch = posterMatches[index].match(extractHrefRegex); + const fullHref = hrefMatch ? + (hrefMatch[1].startsWith("http") ? hrefMatch[1] : baseUrl + hrefMatch[1]) : + null; + + const imageMatch = imageMatches[index].match(extractImageRegex); + const imageSrc = imageMatch ? imageMatch[1] : null; + + const titleMatch = titleMatches[index].match(extractTitleRegex); + const cleanTitle = titleMatch ? + decodeHtmlEntities(titleMatch[1]) : + null; + + if (fullHref && imageSrc && cleanTitle) { + results.push({ + href: fullHref, + image: "https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(imageSrc), + title: cleanTitle + }); + } + } + + return JSON.stringify(results); + } catch (error) { + return JSON.stringify([{ + href: "", + image: "", + title: "Search failed: " + error.message + }]); + } +} + +async function extractDetails(url) { + try { + const response = await fetchv2("https://deno-proxies-sznvnpnxwhbv.deno.dev/?url=" + encodeURIComponent(url)); + const htmlText = await response.text(); + console.log(htmlText); + + const descriptionMatch = (/