feat: rewrite player parsing to js and add it them to repo

This commit is contained in:
Kentai Radiquum 2025-05-29 22:36:44 +05:00
parent 743f756920
commit 990b3c1736
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
9 changed files with 1275 additions and 34 deletions

45
player-parsers/index.ts Normal file
View file

@ -0,0 +1,45 @@
import { asJSON } from "./shared";
import { getAnilibriaURL } from "./libria";
import { getSibnetURL } from "./sibnet";
import { getKodikURL } from "./kodik";
import express from "express";
const app = express();
const host = "0.0.0.0";
const port = 7000;
const allowedPlayers = ["kodik", "libria", "sibnet"];
app.get("/", (req, res) => {
const url = req.query.url;
const player = req.query.player;
if (!url) {
asJSON(res, { message: "no 'url' query provided" }, 400)
return
}
if (!player) {
asJSON(res, { message: "no 'player' query provided" }, 400)
return
}
switch (player) {
case "libria":
getAnilibriaURL(res, url)
return
case "sibnet":
getSibnetURL(res, url)
return
case "kodik":
getKodikURL(res, url)
return
default:
asJSON(res, { message: `player '${player}' is not supported. choose one of: ${allowedPlayers.join(", ")}` }, 400)
return
}
});
app.listen(port, host, function () {
console.log(`Server listens http://${host}:${port}`);
});