mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 22:38:14 +01:00
Update server.js
This commit is contained in:
parent
b6afba6a10
commit
a43cf9b8a5
1 changed files with 39 additions and 5 deletions
44
server.js
44
server.js
|
@ -29,8 +29,37 @@ const renderTemplate = async (res, req, template, data = {}) => {
|
||||||
Object.assign(data)
|
Object.assign(data)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const random_words = [
|
||||||
|
"banana pie",
|
||||||
|
"how to buy an atom bomb",
|
||||||
|
"is love just an illusion",
|
||||||
|
"things to do if ur face becomes benjamin frenklin",
|
||||||
|
"how do defeat an pasta",
|
||||||
|
"can you go to space?",
|
||||||
|
"how to become a god?",
|
||||||
|
"is a panda a panda if pandas???",
|
||||||
|
"Minecraft moive trailer"
|
||||||
|
]
|
||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const fetcher = require("./src/fetcher.js");
|
const fetcher = require("./src/fetcher.js");
|
||||||
|
app.get("/watchnew", async function (req, res) {
|
||||||
|
var url = req.query.v;
|
||||||
|
var uu = `https://www.youtube.com/watch?v=${url}`;
|
||||||
|
|
||||||
|
const json = await fetch(
|
||||||
|
`https://yt-proxy-api.herokuapp.com/get_player_info?v=${url}`
|
||||||
|
).then((res) => res.json());
|
||||||
|
|
||||||
|
const lyrics = await lyricsFinder(json.title);
|
||||||
|
if (lyrics == undefined) lyrics = "Lyrics not found";
|
||||||
|
renderTemplate(res, req, "youtubenew.ejs", {
|
||||||
|
url: json.formats[1].url,
|
||||||
|
title: json,
|
||||||
|
video: json,
|
||||||
|
date: json.upload_date,
|
||||||
|
lyrics: lyrics.replace(/\n/g, " <br> "),
|
||||||
|
});
|
||||||
|
});
|
||||||
app.get("/watch", async function (req, res) {
|
app.get("/watch", async function (req, res) {
|
||||||
var url = req.query.v;
|
var url = req.query.v;
|
||||||
var e = req.query.e;
|
var e = req.query.e;
|
||||||
|
@ -60,7 +89,7 @@ app.get("/watch", async function (req, res) {
|
||||||
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, "youtube.ejs", {
|
renderTemplate(res, req, "youtubenew.ejs", {
|
||||||
url: url,
|
url: url,
|
||||||
engagement:engagement,
|
engagement:engagement,
|
||||||
title: json,
|
title: json,
|
||||||
|
@ -72,8 +101,10 @@ app.get("/watch", async function (req, res) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.get("/", function (req, res) {
|
app.get("/", function (req, res) {
|
||||||
renderTemplate(res, req, "ytmain.ejs");
|
const things = random_words[Math.floor((Math.random()*random_words.length))];
|
||||||
});
|
renderTemplate(res, req, "ytmain.ejs", {
|
||||||
|
random:things,
|
||||||
|
});});
|
||||||
app.get("/channel", function (req, res) {
|
app.get("/channel", function (req, res) {
|
||||||
renderTemplate(res, req, "channel.ejs");
|
renderTemplate(res, req, "channel.ejs");
|
||||||
});
|
});
|
||||||
|
@ -93,8 +124,11 @@ app.get("/css/:id", (req, res) => {
|
||||||
});
|
});
|
||||||
app.get("/video/upload", (req, res) => {
|
app.get("/video/upload", (req, res) => {
|
||||||
res.redirect("https://youtube.com/upload?from=poketube_utc");
|
res.redirect("https://youtube.com/upload?from=poketube_utc");
|
||||||
|
|
||||||
});
|
});
|
||||||
app.get("*", function (req, res) {
|
app.get("*", function (req, res) {
|
||||||
renderTemplate(res, req, "404.ejs");
|
const things = random_words[Math.floor((Math.random()*random_words.length))];
|
||||||
});
|
renderTemplate(res, req, "404.ejs", {
|
||||||
|
random:things,
|
||||||
|
});});
|
||||||
const listener = app.listen(3000);
|
const listener = app.listen(3000);
|
||||||
|
|
Loading…
Reference in a new issue