* Rename youtube.ejs and ytmain.ejs

and use video object instead
This commit is contained in:
Ashley 2022-06-04 19:35:11 +03:00 committed by GitHub
parent a1e444654e
commit 31ab1776f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,7 +16,6 @@
*/ */
const path = require("path"); const path = require("path");
const htmlParser = require("node-html-parser"); const htmlParser = require("node-html-parser");
const moment = require("moment"); const moment = require("moment");
const templateDir = path.resolve(`${process.cwd()}${path.sep}html`); const templateDir = path.resolve(`${process.cwd()}${path.sep}html`);
var express = require("express"); var express = require("express");
@ -64,24 +63,19 @@ if (j_.URL != undefined)
const engagement = fetching.engagement const engagement = fetching.engagement
const lyrics = await lyricsFinder(json.Title); const lyrics = await lyricsFinder(json.Title);
if (lyrics == undefined) lyrics = "Lyrics not found"; if (lyrics == undefined) lyrics = "Lyrics not found";
renderTemplate(res, req, "poketube.ejs", {
renderTemplate(res, req, "youtube.ejs", {
url: url, url: url,
color: await getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`).then((colors) => colors[0].hex()), color: await getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`).then((colors) => colors[0].hex()),
engagement:engagement, engagement:engagement,
title: json,
a:json,
video: json, video: json,
date: moment(json.uploadDate).format("LL"), date: moment(json.uploadDate).format("LL"),
e:e, e:e,
lyrics: lyrics.replace(/\n/g, " <br> "), lyrics: lyrics.replace(/\n/g, " <br> "),
}); });
}); });
app.get("/", function (req, res) { app.get("/", function (req, res) {
const things = random_words[Math.floor((Math.random()*random_words.length))]; const things = random_words[Math.floor((Math.random()*random_words.length))];
renderTemplate(res, req, "ytmain.ejs", { renderTemplate(res, req, "main.ejs", {
random:things, random:things,
});}); });});
app.get("/channel", function (req, res) { app.get("/channel", function (req, res) {
@ -92,6 +86,9 @@ app.get("/channel", function (req, res) {
app.get("/privacy", function (req, res) { app.get("/privacy", function (req, res) {
renderTemplate(res, req, "priv.ejs"); renderTemplate(res, req, "priv.ejs");
}); });
app.get("/143", function (req, res) {
renderTemplate(res, req, "143.ejs");
});
app.get("/domains", function (req, res) { app.get("/domains", function (req, res) {
renderTemplate(res, req, "domains.ejs"); renderTemplate(res, req, "domains.ejs");
}); });
@ -118,15 +115,10 @@ app.get("/api/video/download", async function (req, res) {
app.get("/api/video/downloadjson", 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) 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) { app.get("*", function (req, res) {
const things = random_words[Math.floor((Math.random()*random_words.length))]; const things = random_words[Math.floor((Math.random()*random_words.length))];
renderTemplate(res, req, "404.ejs", { renderTemplate(res, req, "404.ejs", {
random:things, random:things,
});}); });});
app.listen("3000", () => { app.listen("3000", () => {
}) })