mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +00:00
fix: update extractors to match actual anikototv.to structure
- Analyzed actual HTML structure of anikototv.to - Updated all extractors with correct CSS selectors - Changed ID-based to slug-based lookups - Updated URL patterns to match actual website - Fixed stream info to use AJAX server list - Improved error handling
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import * as cheerio from "cheerio";
|
||||
import axios from "axios";
|
||||
import { headers } from "../configs/header.config.js";
|
||||
import { BASE_URL } from "../configs/dataUrl.js";
|
||||
import { URLS } from "../configs/dataUrl.js";
|
||||
|
||||
const extractStreamInfo = async (episodeId, server = "hd-1", type = "sub") => {
|
||||
const extractStreamInfo = async (episodeId) => {
|
||||
try {
|
||||
const url = `${BASE_URL}/watch/${episodeId}`;
|
||||
const { data } = await axios.get(url, { headers });
|
||||
const url = `${URLS.serverList}?episodeId=${episodeId}`;
|
||||
const { data } = await axios.get(url, {
|
||||
headers: {
|
||||
...headers,
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
}
|
||||
});
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const servers = [];
|
||||
@@ -20,35 +26,20 @@ const extractStreamInfo = async (episodeId, server = "hd-1", type = "sub") => {
|
||||
}
|
||||
});
|
||||
|
||||
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";
|
||||
const links = [];
|
||||
$("li[data-link-id]").each((i, el) => {
|
||||
const linkId = $(el).attr("data-link-id") || "";
|
||||
const linkType = $(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 });
|
||||
if (linkId) {
|
||||
links.push({ id: linkId, type: linkType });
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
episodeId,
|
||||
server,
|
||||
type,
|
||||
servers,
|
||||
sources,
|
||||
subtitles
|
||||
links
|
||||
};
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user