mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-05 22:15:36 +05:00
feat: rewrite player parsing to js and add it them to repo
This commit is contained in:
parent
743f756920
commit
990b3c1736
9 changed files with 1275 additions and 34 deletions
45
player-parsers/index.ts
Normal file
45
player-parsers/index.ts
Normal 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}`);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue