From 1c652aa064ec502216d8f66d3cfda79c97df66f9 Mon Sep 17 00:00:00 2001 From: aka paul <50n50@noreply.localhost> Date: Sun, 28 Dec 2025 22:57:15 +0000 Subject: [PATCH] Add animekai/arabic/animekai.js --- animekai/arabic/animekai.js | 308 ++++++++++++++++++++++++++++++++++++ 1 file changed, 308 insertions(+) create mode 100644 animekai/arabic/animekai.js diff --git a/animekai/arabic/animekai.js b/animekai/arabic/animekai.js new file mode 100644 index 0000000..9ce281a --- /dev/null +++ b/animekai/arabic/animekai.js @@ -0,0 +1,308 @@ +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 = (/