Update anihq/anihq.js

This commit is contained in:
aka paul 2025-12-17 21:01:52 +00:00
parent 86df6eac73
commit 0008aeeede

View file

@ -1,21 +1,57 @@
async function searchResults(keyword) { async function searchResults(keyword) {
const results = []; const results = [];
const headers = {
"Content-Type": "multipart/form-data; boundary=----geckoformboundary38c356867533a17de80e8c65d9125df5"
};
const postData = `------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="s_keyword"
${keyword}
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="orderby"
popular
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="order"
DESC
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="action"
advanced_search
------geckoformboundary38c356867533a17de80e8c65d9125df5
Content-Disposition: form-data; name="page"
1
------geckoformboundary38c356867533a17de80e8c65d9125df5--`;
try { try {
const response = await fetchv2("https://anihq.to/search/?s_keyword=" + encodeURIComponent(keyword)); const response = await fetchv2("https://anihq.org/wp-admin/admin-ajax.php", headers, "POST", postData);
const html = await response.text(); const data = await response.json();
const html = data.data.html;
const articlePattern = /<article[^>]*class="anime-card[^"]*"[^>]*>([\s\S]*?)<\/article>/g;
let articleMatch;
const regex = /<div class="w-full bg-gradient-to-t from-primary to-transparent[^"]*"[\s\S]*?<img src=['"]([^'"]+)['"][^>]*alt=['"]([^'"]+)['"][\s\S]*?<a[^>]+href=['"]([^'"]+)['"][\s\S]*?<\/div>\s*<\/div>/g; while ((articleMatch = articlePattern.exec(html)) !== null) {
const articleHtml = articleMatch[1];
let match; const imgMatch = articleHtml.match(/<img[^>]+src=['"]([^'"]+)['"][^>]+alt=['"]([^'"]+)['"]/);
while ((match = regex.exec(html)) !== null) {
results.push({
title: match[2].trim(), const linkMatch = articleHtml.match(/<h3[^>]*>[\s\S]*?<a[^>]+href=['"]([^'"]+)['"][^>]*title=['"]([^'"]+)['"]/);
image: match[1].trim(),
href: match[3].trim() if (imgMatch && linkMatch) {
}); results.push({
title: linkMatch[2].trim(),
image: imgMatch[1].trim(),
href: linkMatch[1].trim()
});
}
} }
return JSON.stringify(results); return JSON.stringify(results);
} catch (err) { } catch (err) {
console.log(err);
return JSON.stringify([{ return JSON.stringify([{
title: "Error", title: "Error",
image: "Error", image: "Error",
@ -24,6 +60,7 @@ async function searchResults(keyword) {
} }
} }
async function extractDetails(url) { async function extractDetails(url) {
try { try {
const response = await fetchv2(url); const response = await fetchv2(url);
@ -105,7 +142,7 @@ async function extractStreamUrl(url) {
const response = await fetchv2(url); const response = await fetchv2(url);
const html = await response.text(); const html = await response.text();
const iframeMatch = html.match(/(?:data-lazy-src|src)=["']https:\/\/(anihqq?\.strp2p\.com)\/#([^"']+)["']/); const iframeMatch = html.match(/<iframe[^>]+src=['"]https:\/\/([^'"]+\.playerp2p\.com)\/#([^'"]+)['"]/);
if (!iframeMatch) { if (!iframeMatch) {
console.log("No iframe ID found"); console.log("No iframe ID found");