Update animelib/animelib.js
This commit is contained in:
+12
-9
@@ -95,7 +95,8 @@ async function extractEpisodes(slug) {
|
|||||||
|
|
||||||
async function extractStreamUrl(ID) {
|
async function extractStreamUrl(ID) {
|
||||||
try {
|
try {
|
||||||
const response = await fetchv2("https://hapi.hentaicdn.org/api/episodes/" + ID);
|
const url = "https://hapi.hentaicdn.org/api/episodes/" + ID;
|
||||||
|
const response = await fetchv2(url);
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
const data = json.data || {};
|
const data = json.data || {};
|
||||||
@@ -104,7 +105,6 @@ async function extractStreamUrl(ID) {
|
|||||||
const order = { Animelib: 0, Kodik: 1 };
|
const order = { Animelib: 0, Kodik: 1 };
|
||||||
return (order[a.player] ?? 99) - (order[b.player] ?? 99);
|
return (order[a.player] ?? 99) - (order[b.player] ?? 99);
|
||||||
});
|
});
|
||||||
|
|
||||||
const parserPromises = players
|
const parserPromises = players
|
||||||
.filter(player => player.team && player.team.name)
|
.filter(player => player.team && player.team.name)
|
||||||
.map(async (player) => {
|
.map(async (player) => {
|
||||||
@@ -128,7 +128,10 @@ async function extractStreamUrl(ID) {
|
|||||||
streamUrl = 'https://video1.cdnlibs.org/.%D0%B0s/' + streamUrl;
|
streamUrl = 'https://video1.cdnlibs.org/.%D0%B0s/' + streamUrl;
|
||||||
}
|
}
|
||||||
} else if (player.player === "Kodik" && player.src) {
|
} else if (player.player === "Kodik" && player.src) {
|
||||||
const kodikUrl = "https:" + player.src;
|
let kodikUrl = player.src;
|
||||||
|
if (!kodikUrl.startsWith('http')) {
|
||||||
|
kodikUrl = "https:" + kodikUrl;
|
||||||
|
}
|
||||||
const qualitiesJson = await kodikParser(kodikUrl);
|
const qualitiesJson = await kodikParser(kodikUrl);
|
||||||
const qualities = JSON.parse(qualitiesJson);
|
const qualities = JSON.parse(qualitiesJson);
|
||||||
|
|
||||||
@@ -160,19 +163,19 @@ async function extractStreamUrl(ID) {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("[extractStreamUrl] Player processing error:", err.message, err.code);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const results = await Promise.all(parserPromises);
|
const results = await Promise.all(parserPromises);
|
||||||
|
|
||||||
const streams = results.filter(stream => stream !== null);
|
const streams = results.filter(stream => stream !== null);
|
||||||
|
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
streams: streams,
|
streams: streams,
|
||||||
subtitle: "https://none.com"
|
subtitle: "https://none.com"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("[extractStreamUrl] ERROR:", err.message);
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
streams: [],
|
streams: [],
|
||||||
subtitle: "https://none.com"
|
subtitle: "https://none.com"
|
||||||
@@ -206,17 +209,17 @@ async function kodikParser(url) {
|
|||||||
`&pd_sign=${urlParams.pd_sign}` +
|
`&pd_sign=${urlParams.pd_sign}` +
|
||||||
`&ref=${urlParams.ref}` +
|
`&ref=${urlParams.ref}` +
|
||||||
`&ref_sign=${urlParams.ref_sign}` +
|
`&ref_sign=${urlParams.ref_sign}` +
|
||||||
`&bad_user=false&cdn_is_working=false` +
|
`&bad_user=false&cdn_is_working=true` +
|
||||||
`&type=${videoInfo_type}&hash=${videoInfo_hash}&id=${videoInfo_id}&info=%7B%7D`;
|
`&type=${videoInfo_type}&hash=${videoInfo_hash}&id=${videoInfo_id}&info=%7B%7D`;
|
||||||
|
|
||||||
|
|
||||||
const headers2 = {
|
const headers2 = {
|
||||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
"Referer": "https://kodik.info",
|
"Referer": "https://v3.animelib.org/",
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
};
|
};
|
||||||
const apiResponse = await fetchv2("https://kodik.info/ftor", headers2, "POST", finalData);
|
const apiResponse = await fetchv2("https://kodikplayer.com/ftor", headers2, "POST", finalData);
|
||||||
const apiJson = await apiResponse.json();
|
const apiJson = await apiResponse.json();
|
||||||
|
|
||||||
const qualities = {};
|
const qualities = {};
|
||||||
@@ -239,7 +242,7 @@ async function kodikParser(url) {
|
|||||||
|
|
||||||
return JSON.stringify(qualities, null, 2);
|
return JSON.stringify(qualities, null, 2);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.error("[kodikParser] ERROR:", error.message);
|
||||||
return JSON.stringify({ error: "error.org" });
|
return JSON.stringify({ error: "error.org" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user