1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2024-11-17 03:34:46 -05:00

add 143 easter egg

This commit is contained in:
Ashley 2022-11-06 12:09:28 +01:00
parent 05c6b9de6c
commit 9028e48cd7

View file

@ -19,11 +19,13 @@
*/ */
const { fetcher, core, wiki, musicInfo, modules } = require("./src/libpoketube/loader.js") const { fetcher, core, wiki, musicInfo, modules } = require("./src/libpoketube/loader.js")
const { IsJsonString, convert, getFirstLine, capitalizeFirstLetter, turntomins } = require("./src/libpoketube/ptutils/libpt-coreutils.js"); const { IsJsonString, convert, getFirstLine, capitalizeFirstLetter, turntomins, getRandomInt, getRandomArbitrary } = require("./src/libpoketube/ptutils/libpt-coreutils.js");
const templateDir = modules.path.resolve(`${process.cwd()}${modules.path.sep}html`); const templateDir = modules.path.resolve(
`${process.cwd()}${modules.path.sep}html`
);
const sha384 = modules.hash const sha384 = modules.hash;
var app = modules.express(); var app = modules.express();
app.engine("html", require("ejs").renderFile); app.engine("html", require("ejs").renderFile);
@ -278,9 +280,9 @@ app.get("/music", async function (req, res) {
renderTemplate(res, req, "poketube-music.ejs", { renderTemplate(res, req, "poketube-music.ejs", {
url: url_e, url: url_e,
info: song, info: song,
color: await modules.getColors( color: await modules
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg` .getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`)
).then((colors) => colors[0].hex()), .then((colors) => colors[0].hex()),
engagement: engagement, engagement: engagement,
process: process, process: process,
ip: ip, ip: ip,
@ -324,9 +326,9 @@ app.get("/download", async function (req, res) {
k: k, k: k,
video: json, video: json,
date: k.Video.uploadDate, date: k.Video.uploadDate,
color: await modules.getColors( color: await modules
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg` .getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`)
).then((colors) => colors[0].hex()), .then((colors) => colors[0].hex()),
}); });
}); });
@ -363,7 +365,6 @@ app.get("/search", async (req, res) => {
.summary(query + " ") .summary(query + " ")
.then((summary_) => (summary_.title !== "Not found." ? summary_ : "none")); .then((summary_) => (summary_.title !== "Not found." ? summary_ : "none"));
renderTemplate(res, req, "search.ejs", { renderTemplate(res, req, "search.ejs", {
j, j,
continuation, continuation,
@ -377,7 +378,9 @@ app.get("/channel/", async (req, res) => {
const tab = req.query.tab; const tab = req.query.tab;
// about // about
const bout = await modules.fetch(config.tubeApi + `channel?id=${ID}&tab=about`); const bout = await modules.fetch(
config.tubeApi + `channel?id=${ID}&tab=about`
);
const h = await bout.text(); const h = await bout.text();
const k = JSON.parse(modules.toJson(h)); const k = JSON.parse(modules.toJson(h));
@ -443,7 +446,14 @@ app.get("/privacy", function (req, res) {
}); });
app.get("/143", function (req, res) { app.get("/143", function (req, res) {
renderTemplate(res, req, "143.ejs"); var number_easteregg = getRandomArbitrary(0, 150);
if (number_easteregg == "143") {
renderTemplate(res, req, "143.ejs");
}
if (number_easteregg != "143") {
return res.redirect("/");
}
}); });
app.get("/domains", function (req, res) { app.get("/domains", function (req, res) {
@ -603,41 +613,39 @@ app.get("/", async function (req, res) {
if (!req.query.tab) var tab = ""; if (!req.query.tab) var tab = "";
const invtrend = await modules.fetch( const invtrend = await modules
`https://vid.puffyan.us/api/v1/trending${tab}` .fetch(`https://vid.puffyan.us/api/v1/trending${tab}`)
).then((res) => res.text()); .then((res) => res.text());
const t = JSON.parse(invtrend); const t = JSON.parse(invtrend);
if(req.query.mobilesearch) { if (req.query.mobilesearch) {
var query = req.query.mobilesearch; var query = req.query.mobilesearch;
tab = "search" tab = "search";
if (req.query.continuation) { if (req.query.continuation) {
var continuation = req.query.continuation; var continuation = req.query.continuation;
} }
if (!req.query.continuation) { if (!req.query.continuation) {
var continuation = ""; var continuation = "";
} }
const search = await modules.fetch(
`https://tube.kuylar.dev/api/search?query=${query}&continuation=${continuation}`
);
const text = await search.text();
var j = JSON.parse(modules.toJson(text));
const search = await modules.fetch(
`https://tube.kuylar.dev/api/search?query=${query}&continuation=${continuation}`
);
const text = await search.text();
var j = JSON.parse(modules.toJson(text));
} }
renderTemplate(res, req, "main.ejs", { renderTemplate(res, req, "main.ejs", {
k: k, k: k,
tab: req.query.tab, tab: req.query.tab,
isMobile: req.useragent.isMobile, isMobile: req.useragent.isMobile,
mobilesearch:req.query.mobilesearch, mobilesearch: req.query.mobilesearch,
inv: t, inv: t,
turntomins, turntomins,
continuation, continuation,
j j,
}); });
}); });