mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +00:00
feat: initial project setup for AniKatoAPI
- Express.js server with Vercel deployment support - Complete API endpoints for anikototv.to anime data - Home, search, info, episodes, stream, schedule endpoints - Category filtering and genre support - Caching system with 5-minute TTL - CORS configuration - Public documentation page - Docker and Render deployment configs - MIT License
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import * as cheerio from "cheerio";
|
||||
import axios from "axios";
|
||||
import { headers } from "../configs/header.config.js";
|
||||
import { BASE_URL } from "../configs/dataUrl.js";
|
||||
|
||||
const extractEpisodeList = async (id) => {
|
||||
try {
|
||||
const url = `${BASE_URL}/anime/${id}`;
|
||||
const { data } = await axios.get(url, { headers });
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const episodes = [];
|
||||
$(".episodes-list .ep-item, .ss-list a").each((i, el) => {
|
||||
const epId = $(el).attr("data-id") || $(el).attr("href")?.split("/").pop() || "";
|
||||
const epNumber = parseInt($(el).find(".ep-number, .ep-num").text().trim()) || i + 1;
|
||||
const title = $(el).find(".ep-title, .ep-name").text().trim() || "";
|
||||
const japaneseTitle = $(el).find(".ep-jp").text().trim() || "";
|
||||
const filler = $(el).hasClass("filler") || false;
|
||||
|
||||
if (epId) {
|
||||
episodes.push({
|
||||
id: epId,
|
||||
episode_no: epNumber,
|
||||
title,
|
||||
japaneseTitle,
|
||||
filler
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
totalEpisodes: episodes.length,
|
||||
episodes
|
||||
};
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export { extractEpisodeList };
|
||||
Reference in New Issue
Block a user