mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +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,58 @@
|
||||
import * as cheerio from "cheerio";
|
||||
import axios from "axios";
|
||||
import { headers } from "../configs/header.config.js";
|
||||
import { BASE_URL } from "../configs/dataUrl.js";
|
||||
|
||||
const extractStreamInfo = async (episodeId, server = "hd-1", type = "sub") => {
|
||||
try {
|
||||
const url = `${BASE_URL}/watch/${episodeId}`;
|
||||
const { data } = await axios.get(url, { headers });
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const servers = [];
|
||||
$(".servers .server-item, .type-list .server-item").each((i, el) => {
|
||||
const serverId = $(el).attr("data-id") || $(el).attr("data-server-id") || "";
|
||||
const serverName = $(el).text().trim() || "";
|
||||
const serverType = $(el).hasClass("sub") ? "sub" : "dub";
|
||||
|
||||
if (serverId) {
|
||||
servers.push({ id: serverId, name: serverName, type: serverType });
|
||||
}
|
||||
});
|
||||
|
||||
const sources = [];
|
||||
$(".player-source .source-item, .embed-source").each((i, el) => {
|
||||
const sourceId = $(el).attr("data-id") || "";
|
||||
const sourceUrl = $(el).attr("data-src") || $(el).find("iframe").attr("src") || "";
|
||||
const sourceType = $(el).attr("data-type") || "hls";
|
||||
|
||||
if (sourceId || sourceUrl) {
|
||||
sources.push({ id: sourceId, url: sourceUrl, type: sourceType });
|
||||
}
|
||||
});
|
||||
|
||||
const subtitles = [];
|
||||
$(".player-sub .sub-item, .subtitle-item").each((i, el) => {
|
||||
const subUrl = $(el).attr("data-url") || $(el).attr("src") || "";
|
||||
const subLabel = $(el).text().trim() || "";
|
||||
const subLang = $(el).attr("data-lang") || "en";
|
||||
|
||||
if (subUrl) {
|
||||
subtitles.push({ url: subUrl, label: subLabel, language: subLang });
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
episodeId,
|
||||
server,
|
||||
type,
|
||||
servers,
|
||||
sources,
|
||||
subtitles
|
||||
};
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export { extractStreamInfo };
|
||||
Reference in New Issue
Block a user