This commit is contained in:
+134
-147
@@ -1,179 +1,166 @@
|
|||||||
async function searchResults(keyword) {
|
async function searchResults(keyword) {
|
||||||
const results = [];
|
const results = [];
|
||||||
const baseUrl = "https://animeworld.ac";
|
const baseUrl = "https://animeworld.ac";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await soraFetch(
|
const response = await soraFetch(`${baseUrl}/search?keyword=${encodeURIComponent(keyword)}`);
|
||||||
`${baseUrl}/search?keyword=${encodeURIComponent(keyword)}`
|
const html = await response.text();
|
||||||
);
|
|
||||||
const html = await response.text();
|
|
||||||
|
|
||||||
const filmListRegex =
|
const filmListRegex =
|
||||||
/<div class="film-list">([\s\S]*?)<div class="clearfix"><\/div>\s*<\/div>/;
|
/<div class="film-list">([\s\S]*?)<div class="clearfix"><\/div>\s*<\/div>/;
|
||||||
const filmListMatch = html.match(filmListRegex);
|
const filmListMatch = html.match(filmListRegex);
|
||||||
|
|
||||||
if (!filmListMatch) {
|
if (!filmListMatch) {
|
||||||
return JSON.stringify(results);
|
return JSON.stringify(results);
|
||||||
}
|
|
||||||
|
|
||||||
const filmListContent = filmListMatch[1];
|
|
||||||
const itemRegex = /<div class="item">[\s\S]*?<\/div>[\s]*<\/div>/g;
|
|
||||||
const items = filmListContent.match(itemRegex) || [];
|
|
||||||
|
|
||||||
items.forEach((itemHtml) => {
|
|
||||||
const imgMatch = itemHtml.match(/src="([^"]+)"/);
|
|
||||||
let imageUrl = imgMatch ? imgMatch[1] : "";
|
|
||||||
|
|
||||||
const titleMatch = itemHtml.match(/class="name">([^<]+)</);
|
|
||||||
const title = titleMatch ? titleMatch[1] : "";
|
|
||||||
|
|
||||||
const hrefMatch = itemHtml.match(/href="([^"]+)"/);
|
|
||||||
let href = hrefMatch ? hrefMatch[1] : "";
|
|
||||||
|
|
||||||
if (imageUrl && title && href) {
|
|
||||||
if (!imageUrl.startsWith("https")) {
|
|
||||||
if (imageUrl.startsWith("/")) {
|
|
||||||
imageUrl = baseUrl + imageUrl;
|
|
||||||
} else {
|
|
||||||
imageUrl = baseUrl + "/" + href;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!href.startsWith("https")) {
|
|
||||||
if (href.startsWith("/")) {
|
const filmListContent = filmListMatch[1];
|
||||||
href = baseUrl + href;
|
const itemRegex = /<div class="item">[\s\S]*?<\/div>[\s]*<\/div>/g;
|
||||||
} else {
|
const items = filmListContent.match(itemRegex) || [];
|
||||||
href = baseUrl + "/" + href;
|
|
||||||
}
|
items.forEach((itemHtml) => {
|
||||||
}
|
const imgMatch = itemHtml.match(/src="([^"]+)"/);
|
||||||
results.push({
|
let imageUrl = imgMatch ? imgMatch[1] : "";
|
||||||
title: title.trim(),
|
|
||||||
image: imageUrl,
|
const titleMatch = itemHtml.match(/class="name">([^<]+)</);
|
||||||
href: href,
|
const title = titleMatch ? titleMatch[1] : "";
|
||||||
|
|
||||||
|
const hrefMatch = itemHtml.match(/href="([^"]+)"/);
|
||||||
|
let href = hrefMatch ? hrefMatch[1] : "";
|
||||||
|
|
||||||
|
if (imageUrl && title && href) {
|
||||||
|
if (!imageUrl.startsWith("https")) {
|
||||||
|
if (imageUrl.startsWith("/")) {
|
||||||
|
imageUrl = baseUrl + imageUrl;
|
||||||
|
} else {
|
||||||
|
imageUrl = baseUrl + "/" + href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!href.startsWith("https")) {
|
||||||
|
if (href.startsWith("/")) {
|
||||||
|
href = baseUrl + href;
|
||||||
|
} else {
|
||||||
|
href = baseUrl + "/" + href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results.push({
|
||||||
|
title: title.trim(),
|
||||||
|
image: imageUrl,
|
||||||
|
href: href,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(JSON.stringify(results));
|
console.log(JSON.stringify(results));
|
||||||
return JSON.stringify(results);
|
return JSON.stringify(results);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Search error:", error);
|
console.log("Search error:", error);
|
||||||
return JSON.stringify([]);
|
return JSON.stringify([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractDetails(url) {
|
async function extractDetails(url) {
|
||||||
try {
|
try {
|
||||||
const response = await soraFetch(url);
|
const response = await soraFetch(url);
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
|
|
||||||
const details = [];
|
const details = [];
|
||||||
|
|
||||||
const descriptionMatch = html.match(/<div class="desc">([\s\S]*?)<\/div>/);
|
const descriptionMatch = html.match(/<div class="desc">([\s\S]*?)<\/div>/);
|
||||||
let description = descriptionMatch ? descriptionMatch[1] : "";
|
let description = descriptionMatch ? descriptionMatch[1] : "";
|
||||||
|
|
||||||
const aliasesMatch = html.match(/<h2 class="title" data-jtitle="([^"]+)">/);
|
const aliasesMatch = html.match(/<h2 class="title" data-jtitle="([^"]+)">/);
|
||||||
let aliases = aliasesMatch ? aliasesMatch[1] : "";
|
let aliases = aliasesMatch ? aliasesMatch[1] : "";
|
||||||
|
|
||||||
const airdateMatch = html.match(
|
const airdateMatch = html.match(/<dt>Data di Uscita:<\/dt>\s*<dd>([^<]+)<\/dd>/);
|
||||||
/<dt>Data di Uscita:<\/dt>\s*<dd>([^<]+)<\/dd>/
|
let airdate = airdateMatch ? airdateMatch[1] : "";
|
||||||
);
|
|
||||||
let airdate = airdateMatch ? airdateMatch[1] : "";
|
|
||||||
|
|
||||||
if (description && aliases && airdate) {
|
if (description && aliases && airdate) {
|
||||||
details.push({
|
details.push({
|
||||||
description: description,
|
description: description,
|
||||||
aliases: aliases,
|
aliases: aliases,
|
||||||
airdate: airdate,
|
airdate: airdate,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(JSON.stringify(details));
|
||||||
|
return JSON.stringify(details);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Details error:", error);
|
||||||
|
return JSON.stringify([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.stringify(details));
|
|
||||||
return JSON.stringify(details);
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Details error:", error);
|
|
||||||
return JSON.stringify([]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractEpisodes(url) {
|
async function extractEpisodes(url) {
|
||||||
try {
|
try {
|
||||||
const response = await soraFetch(url);
|
const response = await soraFetch(url);
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
|
|
||||||
const episodes = [];
|
const episodes = [];
|
||||||
const baseUrl = "https://animeworld.ac";
|
const baseUrl = "https://animeworld.ac";
|
||||||
|
|
||||||
const serverActiveRegex =
|
const serverActiveRegex = /<div class="server active"[^>]*>([\s\S]*?)<\/ul>\s*<\/div>/;
|
||||||
/<div class="server active"[^>]*>([\s\S]*?)<\/ul>\s*<\/div>/;
|
const serverActiveMatch = html.match(serverActiveRegex);
|
||||||
const serverActiveMatch = html.match(serverActiveRegex);
|
|
||||||
|
|
||||||
if (!serverActiveMatch) {
|
if (!serverActiveMatch) {
|
||||||
return JSON.stringify(episodes);
|
return JSON.stringify(episodes);
|
||||||
}
|
|
||||||
|
|
||||||
const serverActiveContent = serverActiveMatch[1];
|
|
||||||
const episodeRegex =
|
|
||||||
/<li class="episode">\s*<a[^>]*?href="([^"]+)"[^>]*?>([^<]+)<\/a>/g;
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = episodeRegex.exec(serverActiveContent)) !== null) {
|
|
||||||
let href = match[1];
|
|
||||||
const number = parseInt(match[2], 10);
|
|
||||||
|
|
||||||
if (!href.startsWith("https")) {
|
|
||||||
if (href.startsWith("/")) {
|
|
||||||
href = baseUrl + href;
|
|
||||||
} else {
|
|
||||||
href = baseUrl + "/" + href;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
episodes.push({
|
const serverActiveContent = serverActiveMatch[1];
|
||||||
href: href,
|
const episodeRegex = /<li class="episode">\s*<a[^>]*?href="([^"]+)"[^>]*?>([^<]+)<\/a>/g;
|
||||||
number: number,
|
let match;
|
||||||
});
|
|
||||||
|
while ((match = episodeRegex.exec(serverActiveContent)) !== null) {
|
||||||
|
let href = match[1];
|
||||||
|
const number = parseInt(match[2], 10);
|
||||||
|
|
||||||
|
if (!href.startsWith("https")) {
|
||||||
|
if (href.startsWith("/")) {
|
||||||
|
href = baseUrl + href;
|
||||||
|
} else {
|
||||||
|
href = baseUrl + "/" + href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
episodes.push({
|
||||||
|
href: href,
|
||||||
|
number: number,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(JSON.stringify(episodes));
|
||||||
|
return JSON.stringify(episodes);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Episodes error:", error);
|
||||||
|
return JSON.stringify([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.stringify(episodes));
|
|
||||||
return JSON.stringify(episodes);
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Episodes error:", error);
|
|
||||||
return JSON.stringify([]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractStreamUrl(url) {
|
async function extractStreamUrl(url) {
|
||||||
try {
|
|
||||||
const response = await soraFetch(url);
|
|
||||||
const html = await response.text();
|
|
||||||
|
|
||||||
const idRegex = /<a[^>]+href="([^"]+)"[^>]*id="alternativeDownloadLink"/;
|
|
||||||
const match = html.match(idRegex);
|
|
||||||
return match ? match[1] : null;
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Stream URL error:", error);
|
|
||||||
return "https://files.catbox.moe/avolvc.mp4";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function soraFetch(
|
|
||||||
url,
|
|
||||||
options = { headers: {}, method: "GET", body: null, encoding: "utf-8" }
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
return await fetchv2(
|
|
||||||
url,
|
|
||||||
options.headers ?? {},
|
|
||||||
options.method ?? "GET",
|
|
||||||
options.body ?? null,
|
|
||||||
true,
|
|
||||||
options.encoding ?? "utf-8"
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
try {
|
try {
|
||||||
return await fetch(url, options);
|
const pathParts = url.split('/');
|
||||||
|
const code = pathParts[pathParts.length - 1];
|
||||||
|
|
||||||
|
const apiUrl = `https://www.animeworld.ac/api/episode/info?id=${code}&alt=0`;
|
||||||
|
|
||||||
|
const response = await soraFetch(apiUrl);
|
||||||
|
const json = JSON.parse(await response.text());
|
||||||
|
|
||||||
|
return json.grabber;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null;
|
console.log("Stream URL error:", error);
|
||||||
|
return "https://files.catbox.moe/avolvc.mp4";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function soraFetch(url, options = { headers: {}, method: "GET", body: null, encoding: "utf-8" }) {
|
||||||
|
try {
|
||||||
|
return await fetchv2(url, options.headers ?? {}, options.method ?? "GET", options.body ?? null, true, options.encoding ?? "utf-8");
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
return await fetch(url, options);
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user