Update animedefenders/animedefenders.js
Fetch and Save Remote Content / fetch (push) Has been cancelled

This commit is contained in:
aka paul
2026-04-17 12:14:39 +00:00
parent 29c1eeb15e
commit c3dcbceefb
+61 -76
View File
@@ -1,20 +1,21 @@
async function searchResults(keyword) { async function searchResults(keyword) {
const results = []; const results = [];
try { try {
const response = await fetchv2("https://animedefenders.me/view/?wd=" + encodeURIComponent(keyword)); const response = await fetchv2("https://eng.animeapps.top/api/search2.php?keyword=" + encodeURIComponent(keyword) + "&page=1&limit=200");
const html = await response.text(); const json = await response.json();
const regex = /<a class="vod-item-img shining" href="(.*?)">[\s\S]*?data-original="(.*?)"[\s\S]*?<h3 class="vod-item-title.*?"><a href=".*?">(.*?)<\/a><\/h3>/g; if (json.status === "success" && json.data) {
let match; json.data.forEach(item => {
while ((match = regex.exec(html)) !== null) { let title = item.postname.trim();
let title = match[3].trim(); title = title.replace(/\s*\(Uncensored\)\s*$/i, '');
title = title.replace(/\s*\(Uncensored\)\s*$/i, ''); title = title.replace(/\s*BD\s*$/i, '');
title = title.replace(/\s*BD\s*$/i, ''); title = title.trim();
title = title.trim();
results.push({ results.push({
title: title, title: title,
image: match[2].trim(), image: item.ani_cover_large,
href: "https://animedefenders.me" + match[1].trim() href: "https://anibd.app/" + item.postid + "?anilist=" + item.anilist
});
}); });
} }
@@ -30,89 +31,73 @@ async function searchResults(keyword) {
async function extractDetails(url) { async function extractDetails(url) {
try { try {
const response = await fetchv2(url); const html = await (await fetchv2(url)).text();
const html = await response.text(); const match = html.match(/<div class="full-description">[\s\S]*?<h4[^>]*>Synopsis<\/h4>([\s\S]*?)<\/div>/);
const descriptionRegex = /<div class="detail-desc-content layout-box">\s*<p>(.*?)<\/p>\s*<\/div>/s;
const match = html.match(descriptionRegex);
let description = "N/A"; let description = "N/A";
if (match && match[1]) { if (match && match[1]) {
description = match[1] description = match[1]
.replace(/<br\s*\/?>/gi, ' ') .replace(/<p[^>]*>/g, '').replace(/<\/p>/g, ' ').replace(/<br\s*\/?>/gi, ' ')
.replace(/<[^>]*>/g, '') .replace(/<[^>]*>/g, '').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"')
.replace(/\s+/g, ' ') .replace(/&amp;/g, '&').replace(/&#39;/g, "'").replace(/&nbsp;/g, ' ')
.trim(); .replace(/\(Source:.*?\)\s*/gi, '').replace(/\s+/g, ' ').trim();
} }
return JSON.stringify([{ description, aliases: "N/A", airdate: "N/A" }]);
return JSON.stringify([{
description: description,
aliases: "N/A",
airdate: "N/A"
}]);
} catch (err) { } catch (err) {
return JSON.stringify([{ return JSON.stringify([{ description: "Error", aliases: "Error", airdate: "Error" }]);
description: "Error",
aliases: "Error",
airdate: "Error"
}]);
} }
} }
async function extractEpisodes(url) { async function extractEpisodes(url) {
const results = [];
try { try {
const response = await fetchv2(url); const postid = url.match(/(\d+)/)?.[1];
const html = await response.text(); if (!postid) return JSON.stringify([]);
const regex = /<a class="text-overflow ep" href="([^"]+)">(\d+)<\/a>/g; let anilist = url.match(/anilist=([\d]+)/)?.[1];
let match; if (!anilist) {
const html = await (await fetchv2(url)).text();
anilist = html.match(/const\s+EP_ID\s*=\s*["'](\d+)["']/)?.[1];
}
if (!anilist) return JSON.stringify([]);
while ((match = regex.exec(html)) !== null) { const json = await (await fetchv2("https://epeng.animeapps.top/api2.php?epid=" + anilist)).json();
results.push({ const results = [];
href: "https://animedefenders.me" + match[1].trim(), if (Array.isArray(json)) {
number: parseInt(match[2], 10) json.forEach(server => {
server.server_data?.forEach(ep => {
results.push({
number: parseInt(ep.name, 10),
href: "https://anibd.app/playid/" + postid + "/?server=" + server.id + "&slug=" + ep.slug
});
});
}); });
} }
return JSON.stringify(results);
return JSON.stringify(results.reverse());
} catch (err) { } catch (err) {
return JSON.stringify([{ return JSON.stringify([]);
href: "Error",
number: "Error"
}]);
} }
} }
async function extractStreamUrl(url) { async function extractStreamUrl(url) {
try { try {
const response = await fetchv2(url); const pageHtml = await (await fetchv2(url)).text();
const html = await response.text(); const iframeUrl = pageHtml.match(/id="video-player-iframe"\s+src="([^"]+)"/)?.[1]?.replace(/&#038;/g, '&');
if (!iframeUrl) return JSON.stringify({ streams: [], subtitle: "" });
const subUrlRegex = /"actual_url":"([^"]+)"/;
const match = html.match(subUrlRegex); const iframeHtml = await (await fetchv2(iframeUrl, { "Referer": "https://anibd.app/" })).text();
const streamUrl = iframeHtml.match(/url:\s*['"]([^'"]+\.m3u8)['"]/)?.[1];
if (match && match[1]) {
const subUrl = match[1].replace(/\\\//g, '/'); if (streamUrl) {
return JSON.stringify({
const headers = { streams: [{
"Referer": "https://ee.anih1.top", title: "Server 1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" streamUrl: "https://playeng.animeapps.top/r2/" + streamUrl,
}; headers: { "Referer": "https://anibd.app/" }
}],
const subResponse = await fetchv2(subUrl, headers); subtitle: ""
const subHtml = await subResponse.text(); });
const artplayerRegex = /url:\s*'([^']+\.m3u8)'/;
const artMatch = subHtml.match(artplayerRegex);
if (artMatch && artMatch[1]) {
return artMatch[1];
}
} }
console.log("No stream URL found"); return JSON.stringify({ streams: [], subtitle: "" });
return "https://error.org/";
} catch (err) { } catch (err) {
return "https://error.org/"; return JSON.stringify({ streams: [], subtitle: "" });
} }
} }