update
This commit is contained in:
+41
-6
@@ -1,8 +1,13 @@
|
||||
async function searchResults(keyword) {
|
||||
const results = [];
|
||||
const headers = {
|
||||
"Referer": "https://v3.animelib.org/",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
||||
};
|
||||
try {
|
||||
const response = await fetchv2(
|
||||
"https://hapi.hentaicdn.org/api/anime?fields[]=rate_avg&fields[]=rate&fields[]=releaseDate&q=" + keyword
|
||||
"https://hapi.hentaicdn.org/api/anime?fields[]=rate_avg&fields[]=rate&fields[]=releaseDate&q=" + keyword,
|
||||
headers
|
||||
);
|
||||
const json = await response.json();
|
||||
|
||||
@@ -15,7 +20,7 @@ async function searchResults(keyword) {
|
||||
title,
|
||||
image: "https://passthrough-worker.simplepostrequest.workers.dev/?simple=" +
|
||||
image +
|
||||
"&referer=https://animelib.org/",
|
||||
"&referer=https://v3.animelib.org/",
|
||||
href: item.slug_url || item.slug || item.id,
|
||||
_score: scoreTitle(title, keyword)
|
||||
});
|
||||
@@ -47,16 +52,38 @@ function scoreTitle(title, keyword) {
|
||||
}
|
||||
|
||||
async function extractDetails(slug) {
|
||||
const headers = {
|
||||
"Referer": "https://v3.animelib.org/",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
||||
};
|
||||
try {
|
||||
const response = await fetchv2(
|
||||
"https://hapi.hentaicdn.org/api/anime/" + slug +
|
||||
"?fields[]=background&fields[]=eng_name&fields[]=otherNames&fields[]=summary&fields[]=releaseDate&fields[]=type_id&fields[]=caution&fields[]=views&fields[]=close_view&fields[]=rate_avg&fields[]=rate&fields[]=genres&fields[]=tags&fields[]=teams&fields[]=user&fields[]=franchise&fields[]=authors&fields[]=publisher&fields[]=userRating&fields[]=moderated&fields[]=metadata&fields[]=metadata.count&fields[]=metadata.close_comments&fields[]=anime_status_id&fields[]=time&fields[]=episodes&fields[]=episodes_count&fields[]=episodesSchedule&fields[]=shiki_rate"
|
||||
);
|
||||
, headers);
|
||||
const json = await response.json();
|
||||
const data = json.data || {};
|
||||
|
||||
let description = "No summary available";
|
||||
if (data.summary) {
|
||||
if (typeof data.summary === "string") {
|
||||
description = data.summary;
|
||||
} else if (data.summary.content && Array.isArray(data.summary.content)) {
|
||||
description = data.summary.content
|
||||
.map(block => {
|
||||
if (block.content && Array.isArray(block.content)) {
|
||||
return block.content.map(t => t.text || "").join("");
|
||||
}
|
||||
return "";
|
||||
})
|
||||
.join("\n")
|
||||
.trim();
|
||||
}
|
||||
}
|
||||
|
||||
const aliases = Array.isArray(data.otherNames) ? data.otherNames.join(", ") : "";
|
||||
return JSON.stringify([{
|
||||
description: data.summary || "No summary available",
|
||||
description: description,
|
||||
airdate: data.releaseDate || "Unknown",
|
||||
aliases: aliases
|
||||
}]);
|
||||
@@ -71,8 +98,12 @@ async function extractDetails(slug) {
|
||||
|
||||
async function extractEpisodes(slug) {
|
||||
const results = [];
|
||||
const headers = {
|
||||
"Referer": "https://v3.animelib.org/",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
||||
};
|
||||
try {
|
||||
const response = await fetchv2("https://hapi.hentaicdn.org/api/episodes?anime_id=" + slug);
|
||||
const response = await fetchv2("https://hapi.hentaicdn.org/api/episodes?anime_id=" + slug, headers);
|
||||
const json = await response.json();
|
||||
|
||||
if (json && Array.isArray(json.data)) {
|
||||
@@ -94,9 +125,13 @@ async function extractEpisodes(slug) {
|
||||
}
|
||||
|
||||
async function extractStreamUrl(ID) {
|
||||
const headers = {
|
||||
"Referer": "https://v3.animelib.org/",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
||||
};
|
||||
try {
|
||||
const url = "https://hapi.hentaicdn.org/api/episodes/" + ID;
|
||||
const response = await fetchv2(url);
|
||||
const response = await fetchv2(url, headers);
|
||||
const json = await response.json();
|
||||
|
||||
const data = json.data || {};
|
||||
|
||||
Reference in New Issue
Block a user