Refactor code, add more gooda error thingy :3

This commit is contained in:
Ashley 2022-11-14 18:36:00 +01:00
parent 05c9ba9304
commit b60e06a9cd

View file

@ -1,4 +1,13 @@
const { fetcher,core, wiki,musicInfo, modules, version, initlog, init,} = require("../libpoketube-initsys.js");
const {
fetcher,
core,
wiki,
musicInfo,
modules,
version,
initlog,
init,
} = require("../libpoketube-initsys.js");
const {
IsJsonString,
convert,
@ -69,7 +78,9 @@ app.get("/watch", async function (req, res) {
const info = await modules.fetch("http://ip-api.com/json/");
const jj = await info.text();
const ip = JSON.parse(jj);
const isvld = await core.isvalidvideo(v);
if (isvld) {
for (let i = 0; i < 3; i++) {
try {
core.video(v).then((data) => {
@ -93,25 +104,16 @@ app.get("/watch", async function (req, res) {
var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`;
}
// encryption
const url_e =
url +
"?e=" +
sha384(k.Video.Channel.id) +
sha384(k.Video.Channel.id) +
"Piwik" +
sha384(config.t_url);
const desc = data.desc;
if (d) {
var d = desc.toString().replace(/\n/g, " <br> ");
}
if (d === "[object Object]") {
var d = false;
}
renderTemplate(res, req, "poketube.ejs", {
url: url_e,
color: data.color,
engagement: engagement,
video: json,
@ -149,6 +151,9 @@ app.get("/watch", async function (req, res) {
}
}
}
} else {
res.redirect("/");
}
});
app.get("/music", async function (req, res) {
@ -208,7 +213,10 @@ app.get("/music", async function (req, res) {
// info
const song = await musicInfo.searchSong(
{ title: k.Video.Title, artist: json.Channel.Name.replace("- Topic", "") },
{
title: k.Video.Title,
artist: json.Channel.Name.replace("- Topic", ""),
},
1000
);
@ -252,4 +260,4 @@ app.get("/music", async function (req, res) {
lyrics: ly,
});
});
}
};