rename player-parsers to player-parser for consistency with docker image

This commit is contained in:
Kentai Radiquum 2025-07-09 15:31:51 +05:00
parent 4701f6f62e
commit 1a1b548d39
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
15 changed files with 11 additions and 11 deletions

59
player-parser/sibnet.ts Normal file
View file

@ -0,0 +1,59 @@
import { asJSON, randomUA } from "./shared";
export async function getSibnetURL(req, res, url: string) {
if (!url.includes("sibnet")) {
asJSON(req, res, { message: "SIBNET: Неправильная ссылка на плеер" }, 400);
return
}
const user_agent = randomUA();
let pageRes = await fetch(url, {
headers: {
"User-Agent": user_agent,
},
});
if (!pageRes.ok) {
asJSON(req, res, { message: `SIBNET: Не удалось загрузить страницу с плеером` }, 500)
return
}
const pageData = await pageRes.text();
const videoRe = /\/v\/.*?\.mp4/;
const videoMatch = videoRe.exec(pageData);
if (!videoMatch || videoMatch.length == 0) {
asJSON(req, res, { message: `SIBNET: Не удалось найти данные эпизода` }, 500)
return
}
const posterRe = /\/upload\/cover\/.*?\.jpg/;
const posterMatch = posterRe.exec(pageData);
const actualVideoRes = await fetch(
`https://video.sibnet.ru${videoMatch[0]}`,
{
headers: {
"User-Agent": user_agent,
Referer: url,
},
redirect: "manual",
}
);
if (!actualVideoRes.headers.get("location")) {
asJSON(req, res, { message: `SIBNET: Не удалось получить прямую ссылку` }, 500)
return
}
const video = `https:${actualVideoRes.headers.get("location")}`;
const poster =
posterMatch ?
posterMatch.length > 0 ?
`https://st.sibnet.ru${posterMatch[0]}`
: null
: null;
asJSON(req, res, { manifest: video, poster }, 200)
return
}