mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +00:00
fix: critical fixes for 14 broken endpoints
- Fixed ALL CSS selectors to match actual anikototv.to HTML - Fixed search results returning empty data array - Fixed anime info returning empty fields - Fixed episode list returning 0 episodes - Fixed most-popular returning empty data - Fixed random endpoint 500 error - Fixed filter endpoint 500 error - Fixed suggestions returning empty array - Added /api/genre/:name and /api/type/:name routes - Fixed watch page server/episode extraction - Fixed rating field to return clean value
This commit is contained in:
@@ -5,34 +5,41 @@ import { URLS } from "../configs/dataUrl.js";
|
||||
|
||||
const extractRandom = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(URLS.random, {
|
||||
const { data, request, response } = await axios.get(URLS.random, {
|
||||
headers,
|
||||
maxRedirects: 5
|
||||
maxRedirects: 5,
|
||||
validateStatus: (status) => status < 400
|
||||
});
|
||||
|
||||
const finalUrl = request?.responseURL || URLS.random;
|
||||
const slug = finalUrl.split("/watch/").pop() || "";
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const slug = window.location.pathname.split("/watch/").pop() || "";
|
||||
const title = $(".film-name h1, .anisc-detail .film-name").text().trim() || "";
|
||||
const japaneseTitle = $(".film-name .alternate-title, .anisc-detail .film-name small").text().trim() || "";
|
||||
const poster = $(".film-poster img").attr("src") || "";
|
||||
const type = $(".film-info .row .col1 .item:first-child .name").text().trim() || "";
|
||||
const title = $("h1[itemprop='name'].title.d-title").text().trim() || "";
|
||||
const japaneseTitle = $("h1[itemprop='name'].title.d-title").attr("data-jp") || "";
|
||||
const poster = $("img[itemprop='image']").attr("src") || "";
|
||||
const type = $(".bmeta .meta:first-child > div:nth-child(1) span").text().trim() || "";
|
||||
const synopsis = $(".synopsis .content").text().trim() || "";
|
||||
const rating = $("#w-rating .score .value").text().trim() || "";
|
||||
const animeId = parseInt($("#watch-main").attr("data-id")) || 0;
|
||||
|
||||
const animeInfo = {};
|
||||
$(".anisc-info .item").each((i, el) => {
|
||||
const label = $(el).find(".name").text().trim().replace(":", "");
|
||||
const value = $(el).find(".text").text().trim();
|
||||
if (label && value) {
|
||||
animeInfo[label] = value;
|
||||
}
|
||||
const genres = [];
|
||||
$(".bmeta .meta:first-child > div:nth-child(5) span a[href*='/genre/']").each((i, el) => {
|
||||
genres.push($(el).text().trim());
|
||||
});
|
||||
|
||||
return {
|
||||
slug,
|
||||
animeId,
|
||||
title,
|
||||
japaneseTitle,
|
||||
poster,
|
||||
type,
|
||||
animeInfo
|
||||
synopsis,
|
||||
rating,
|
||||
genres,
|
||||
url: finalUrl
|
||||
};
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user