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:
@@ -54,7 +54,10 @@ const getStreamInfo = async (req, res, next) => {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
const data = await extractStreamInfo(id);
|
||||
setCache(cacheKey, data, TTL.default);
|
||||
if (!data.url) {
|
||||
return res.status(404).json({ success: false, message: "Stream URL not found for this link ID", results: data });
|
||||
}
|
||||
setCache(cacheKey, data, TTL.stream);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
@@ -94,7 +97,10 @@ const getServerList = async (req, res, next) => {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
const data = await extractServerList(ids);
|
||||
setCache(cacheKey, data, TTL.default);
|
||||
if (!data || data.length === 0) {
|
||||
return res.status(404).json({ success: false, message: "No servers found for the given episode IDs", results: [] });
|
||||
}
|
||||
setCache(cacheKey, data, TTL.servers);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
||||
Reference in New Issue
Block a user