mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +00:00
fix: resolve null values in stream server endpoints
- Fix extractServerList JSON parsing: fetchWithMirror returns raw text but code treated it as parsed object, causing Cheerio to parse JSON string as HTML resulting in empty server arrays - Fix extractMapperServers JSON parsing: same raw text issue caused data processing loop to be skipped, returning empty arrays - Fix streamInfo controller to return 404 with error message when stream URL is null instead of silently returning null values - Fix server list controller to use proper TTL and handle empty results - Fix JSON.parse error handling in episodeList and episodeListAjax extractors - Update CHANGELOG.md with v2.2.1 bug fixes
This commit is contained in:
@@ -110,7 +110,12 @@ const extractServerList = async (episodeIds, watchSlug = null) => {
|
||||
headers: { "X-Requested-With": "XMLHttpRequest" }
|
||||
});
|
||||
|
||||
const html = typeof raw === "string" ? raw : (raw?.result || "");
|
||||
// NOTE: Parse JSON response first — fetchWithMirror returns raw text by default
|
||||
let parsed = raw;
|
||||
if (typeof raw === "string") {
|
||||
try { parsed = JSON.parse(raw); } catch { parsed = {}; }
|
||||
}
|
||||
const html = parsed?.result || "";
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const servers = [];
|
||||
@@ -165,7 +170,13 @@ const extractMapperServers = async (malId, slug, timestamp) => {
|
||||
if (!Number.isFinite(Number(timestamp))) throw new Error("Invalid timestamp");
|
||||
|
||||
const path = `/ajax/mapper/${encodeURIComponent(malId)}/${encodeURIComponent(slug)}/${encodeURIComponent(timestamp)}`;
|
||||
const { data } = await fetchWithMirror(path);
|
||||
const { data: rawData } = await fetchWithMirror(path);
|
||||
|
||||
// NOTE: Parse JSON response first — fetchWithMirror returns raw text by default
|
||||
let data = rawData;
|
||||
if (typeof rawData === "string") {
|
||||
try { data = JSON.parse(rawData); } catch { data = {}; }
|
||||
}
|
||||
|
||||
const servers = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user