mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 04:38:56 +01:00
add music (very beta)
This commit is contained in:
parent
731a83e90a
commit
0b416917ff
1 changed files with 45 additions and 1 deletions
44
server.js
44
server.js
|
@ -102,6 +102,46 @@ app.get("/watch", async function (req, res) {
|
|||
});
|
||||
});
|
||||
|
||||
app.get("/music", async function (req, res) {
|
||||
var v = req.query.v;
|
||||
const getColors = require("get-image-colors");
|
||||
var e = req.query.e;
|
||||
var r = req.query.r;
|
||||
var t = req.query.t;
|
||||
|
||||
const { toJson } = require("xml2json");
|
||||
const video = await fetch(config.tubeApi + `video?v=${v}`);
|
||||
const h = await video.text();
|
||||
const k = JSON.parse(toJson(h));
|
||||
if (!v) res.redirect("/");
|
||||
var fetching = await fetcher(v);
|
||||
const j = fetching.video.Player.Formats.Format,
|
||||
j_ = Array.isArray(j) ? j[j.length - 1] : j;
|
||||
let url;
|
||||
if (j_.URL != undefined) url = j_.URL;
|
||||
const json = fetching.video.Player;
|
||||
const engagement = fetching.engagement;
|
||||
const lyrics = await lyricsFinder(json.Title);
|
||||
if (lyrics == undefined) lyrics = "Lyrics not found";
|
||||
renderTemplate(res, req, "poketube-music.ejs", {
|
||||
url: url,
|
||||
color: await getColors(
|
||||
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
|
||||
).then((colors) => colors[0].hex()),
|
||||
engagement: engagement,
|
||||
video: json,
|
||||
date: moment(k.Video.uploadDate).format("LL"),
|
||||
e: e,
|
||||
k: k,
|
||||
r: r,
|
||||
t: config.t_url,
|
||||
optout: t,
|
||||
lyrics: lyrics.replace(/\n/g, " <br> "),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.get("/old/watch", async function (req, res) {
|
||||
var v = req.query.v;
|
||||
const getColors = require("get-image-colors");
|
||||
|
@ -220,4 +260,8 @@ app.get("*", function (req, res) {
|
|||
random: things,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
|
||||
app.listen("3000", () => {});
|
||||
|
|
Loading…
Reference in a new issue