Update 'server.js'

This commit is contained in:
Ashley 2022-08-18 23:06:09 +02:00
parent e2db1a4d6e
commit 45d34792c3

View file

@ -41,6 +41,8 @@ var sha384 = require("js-sha512").sha384;
var sha512_256 = require("js-sha512").sha512_256;
var sha512_224 = require("js-sha512").sha512_224;
const musicInfo = require("music-info");
var app = express();
app.engine("html", require("ejs").renderFile);
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
@ -132,6 +134,7 @@ app.get("/watch", async function (req, res) {
var q = req.query.quality;
const video = await fetch(config.tubeApi + `video?v=${v}`);
var fetching = await fetcher(v);
const json = fetching.video.Player;
@ -197,17 +200,19 @@ app.get("/music", async function (req, res) {
var f = req.query.f;
var t = req.query.t;
if (!v) res.redirect("/");
const video = await fetch(config.tubeApi + `video?v=${v}`);
var fetching = await fetcher(v);
const json = fetching.video.Player;
const h = await video.text();
const k = JSON.parse(toJson(h));
if (!v) res.redirect("/");
if (!json.Channel.Name.endsWith(" - Topic")) {
res.redirect(`/watch?v=${v}`);
}
//video
var url = `https://tube.kuylar.dev/proxy/media/${v}/18`;
@ -225,8 +230,12 @@ app.get("/music", async function (req, res) {
// lyrics
const lyrics = await lyricsFinder(json.Title);
// info
const info = await musicInfo.searchSong({ title: json.Title, artist:json.Channel.Name.replace("- Topic", "")}, 1000)
renderTemplate(res, req, "poketube-music.ejs", {
url: url_e,
info: info,
color: await getColors(
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
).then((colors) => colors[0].hex()),