Files
AniKotoAPI/src/extractors/episodeList.extractor.js
T
Sʜɪɴᴇɪ Nᴏᴜᴢᴇɴ 8269dcea8b 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
2026-06-08 15:54:22 +05:30

44 lines
1.2 KiB
JavaScript

import * as cheerio from "cheerio";
import axios from "axios";
import { headers } from "../configs/header.config.js";
import { URLS } from "../configs/dataUrl.js";
const extractEpisodeList = async (slug) => {
try {
const url = URLS.watch(slug);
const { data } = await axios.get(url, { headers });
const $ = cheerio.load(data);
const animeId = parseInt($("#watch-main").attr("data-id")) || 0;
const episodes = [];
$("#w-episodes a[data-num], #w-episodes a[data-slug]").each((i, el) => {
const epId = $(el).attr("data-id") || $(el).attr("data-ep-id") || "";
const epNum = parseInt($(el).attr("data-num")) || i + 1;
const epSlug = $(el).attr("data-slug") || "";
const epTitle = $(el).find(".ep-title, .ep-name").text().trim() || "";
const isActive = $(el).hasClass("active") || false;
const href = $(el).attr("href") || "";
episodes.push({
id: epId,
episode_no: epNum,
slug: epSlug,
title: epTitle,
active: isActive,
href
});
});
return {
animeId,
slug,
totalEpisodes: episodes.length,
episodes
};
} catch (error) {
throw error;
}
};
export { extractEpisodeList };