From c179221fb19be1c1612a1dcf56934a6bc77863a3 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 22 Jun 2022 12:52:00 +0300 Subject: [PATCH] new ui pog --- server.js | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/server.js b/server.js index 889afc14..823de330 100644 --- a/server.js +++ b/server.js @@ -46,13 +46,12 @@ const fetch = require("node-fetch"); const fetcher = require("./src/fetcher.js"); app.get("/watch", async function (req, res) { - var v = req.query.v; const getColors = require('get-image-colors') var e = req.query.e; if(!v) res.redirect("/") var fetching = await fetcher(v) -const j = fetching.video.Player.Formats.Format, + const j = fetching.video.Player.Formats.Format, j_ = Array.isArray(j) ? j[j.length - 1] : j; @@ -73,6 +72,34 @@ if (j_.URL != undefined) lyrics: lyrics.replace(/\n/g, "
"), }); }); + +app.get("/old/watch", async function (req, res) { + var v = req.query.v; + const getColors = require('get-image-colors') + var e = req.query.e; + 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-old.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(json.uploadDate).format("LL"), + e:e, + lyrics: lyrics.replace(/\n/g, "
"), + }); +}); app.get("/", function (req, res) { const things = random_words[Math.floor((Math.random()*random_words.length))]; renderTemplate(res, req, "main.ejs", { @@ -80,11 +107,9 @@ app.get("/", function (req, res) { }); }); app.get("/channel", async (req, res) => { - const ID = req.query.id; - const { toJson } = require("xml2json"); - const bout = await fetch( - `https://lighttube.herokuapp.com/api/channel?id=${ID}&tab=about` - ); + const ID = req.query.id; + const { toJson } = require("xml2json"); + const bout = await fetch( `https://tube.kuylar.dev/api/channel?id=${ID}&tab=about`); const h = await bout.text(); const k = JSON.parse(toJson(h)); const { Subscribers: subscribers } = k.Channel.Metadata; @@ -115,9 +140,7 @@ app.get("/api/search", async (req, res) => { app.get("/search", async (req, res) => { const { toJson } = require("xml2json"); const query = req.query.query; - const search = await fetch( - `https://tube.kuylar.dev/api/search?query=${query}` - ); + const search = await fetch(`https://tube.kuylar.dev/api/search?query=${query}`); const text = await search.text(); const j = JSON.parse(toJson(text)); if (!query) { @@ -143,6 +166,8 @@ app.get("/api/video/download", async function (req, res) { app.get("/api/video/downloadjson", async function (req, res) { var v = req.query.v;var fetching = await fetcher(v);const url = fetching.video.Player.Formats.Format[1].URL;res.json(url) }); + + app.get("*", function (req, res) { const things = random_words[Math.floor((Math.random()*random_words.length))]; renderTemplate(res, req, "404.ejs", {