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:
Sʜɪɴᴇɪ Nᴏᴜᴢᴇɴ
2026-06-08 15:54:22 +05:30
parent 8e201ccb10
commit 8269dcea8b
12 changed files with 202 additions and 198 deletions
+9 -8
View File
@@ -1,5 +1,4 @@
import * as cheerio from "cheerio";
import axios from "axios";
import { headers } from "../configs/header.config.js";
import { URLS } from "../configs/dataUrl.js";
import { countPages } from "../helper/countPages.helper.js";
@@ -17,25 +16,27 @@ const extractCategory = async (category, page = 1) => {
} else {
url = `${URLS.home}/${category}`;
}
const $ = await extractPages(url, page);
const totalPages = countPages($);
const results = [];
$(".film_list-wrap .flw-item, .film-detail").each((i, el) => {
$("#list-items > .item").each((i, el) => {
const slug = $(el).find("a").attr("href")?.split("/watch/").pop() || "";
const poster = $(el).find("img").attr("src") || "";
const title = $(el).find(".film-name a, .name.d-title").text().trim() || "";
const japaneseTitle = $(el).find(".name.d-title").attr("data-jp") || "";
const poster = $(el).find(".ani.poster.tip > a > img").attr("src") || "";
const title = $(el).find(".info .b1 a.name.d-title").text().trim() || "";
const japaneseTitle = $(el).find(".info .b1 a.name.d-title").attr("data-jp") || "";
const animeId = $(el).find(".ani.poster.tip").attr("data-tip") || "";
const sub = parseInt($(el).find(".ep-status.sub span").text().trim()) || 0;
const dub = parseInt($(el).find(".ep-status.dub span").text().trim()) || 0;
const total = parseInt($(el).find(".ep-status.total span").text().trim()) || 0;
const type = $(el).find(".meta .inner .right, .fdi-item:nth-child(2)").text().trim() || "";
const rating = $(el).find(".rating, .fdi-item:nth-child(3)").text().trim() || "";
const type = $(el).find(".info .meta .m-item:nth-child(2) label").text().trim() || "";
const rating = $(el).find(".info .meta .m-item.rated span").text().trim() || "";
if (slug) {
results.push({
slug,
animeId,
poster,
title,
japaneseTitle,