mirror of
https://git.luna-app.eu/50n50/sources
synced 2025-12-21 21:26:19 +01:00
added animelib when extracting streams in animelib module
This commit is contained in:
parent
56e694cc4b
commit
5c17dc19f2
1 changed files with 92 additions and 22 deletions
|
|
@ -80,42 +80,112 @@ async function extractStreamUrl(ID) {
|
|||
const data = json.data || {};
|
||||
const players = data.players || [];
|
||||
|
||||
// const parserPromises = players
|
||||
// .filter(player => player.src && player.team && player.team.name)
|
||||
// .map(async (player) => {
|
||||
// try {
|
||||
// const kodikUrl = "https:" + player.src;
|
||||
// const qualitiesJson = await kodikParser(kodikUrl);
|
||||
// const qualities = JSON.parse(qualitiesJson);
|
||||
|
||||
// let highestQuality = null;
|
||||
// let highestQualityNum = 0;
|
||||
|
||||
// for (const quality in qualities) {
|
||||
// if (qualities[quality].src) {
|
||||
// const qualityNum = parseInt(quality.replace('p', '')) || 0;
|
||||
// if (qualityNum > highestQualityNum) {
|
||||
// highestQualityNum = qualityNum;
|
||||
// highestQuality = qualities[quality].src;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (highestQuality) {
|
||||
|
||||
// if (highestQuality.startsWith('//')) {
|
||||
// highestQuality = 'https:' + highestQuality;
|
||||
// }
|
||||
|
||||
// return {
|
||||
// title: player.team.name,
|
||||
// streamUrl: highestQuality,
|
||||
// headers: {
|
||||
// "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
||||
// "Referer": "https://kodik.info/"
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
// return null;
|
||||
// } catch (err) {
|
||||
// return null;
|
||||
// }
|
||||
// });
|
||||
|
||||
players.sort((a, b) => {
|
||||
const order = { Animelib: 0, Kodik: 1 };
|
||||
return (order[a.player] ?? 99) - (order[b.player] ?? 99);
|
||||
});
|
||||
|
||||
const parserPromises = players
|
||||
.filter(player => player.src && player.team && player.team.name)
|
||||
.filter(player => player.team && player.team.name)
|
||||
.map(async (player) => {
|
||||
try {
|
||||
let streamUrl = null;
|
||||
let highestQualityNum = 0;
|
||||
|
||||
if (player.player === "Animelib" && player.video && player.video.quality) {
|
||||
const qualities = player.video.quality;
|
||||
|
||||
console.log(qualities);
|
||||
|
||||
for (const qualityItem of qualities) {
|
||||
if (qualityItem.href && qualityItem.quality > highestQualityNum) {
|
||||
highestQualityNum = qualityItem.quality;
|
||||
streamUrl = qualityItem.href;
|
||||
|
||||
console.log("Found Animelib quality: " + qualityItem.quality + " URL: " + streamUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// Animelib URLs are relative, prepend base URL
|
||||
if (streamUrl && !streamUrl.startsWith('http')) {
|
||||
// https://video1.cdnlibs.org/.аs/
|
||||
// https://video2.anilib.me/.аs/
|
||||
// https://video3.anilib.me/.аs/
|
||||
streamUrl = 'https://video1.cdnlibs.org/.%D0%B0s/' + streamUrl;
|
||||
}
|
||||
} else if (player.player === "Kodik" && player.src) {
|
||||
const kodikUrl = "https:" + player.src;
|
||||
const qualitiesJson = await kodikParser(kodikUrl);
|
||||
const qualities = JSON.parse(qualitiesJson);
|
||||
|
||||
let highestQuality = null;
|
||||
let highestQualityNum = 0;
|
||||
|
||||
for (const quality in qualities) {
|
||||
if (qualities[quality].src) {
|
||||
const qualityNum = parseInt(quality.replace('p', '')) || 0;
|
||||
if (qualityNum > highestQualityNum) {
|
||||
highestQualityNum = qualityNum;
|
||||
highestQuality = qualities[quality].src;
|
||||
streamUrl = qualities[quality].src;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (highestQuality) {
|
||||
|
||||
if (highestQuality.startsWith('//')) {
|
||||
highestQuality = 'https:' + highestQuality;
|
||||
if (streamUrl && streamUrl.startsWith('//')) {
|
||||
streamUrl = 'https:' + streamUrl;
|
||||
}
|
||||
}
|
||||
|
||||
if (streamUrl) {
|
||||
return {
|
||||
title: player.team.name,
|
||||
streamUrl: highestQuality,
|
||||
title: player.team.name + (highestQualityNum ? ` (${highestQualityNum}p)` : '') + (player.player === "Animelib" ? " (Animelib)" : " (Kodik)"),
|
||||
streamUrl,
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
||||
"Referer": "https://kodik.info/"
|
||||
"Referer": player.player === "Kodik" ? "https://kodik.info/" : "https://v3.animelib.org/"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (err) {
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue