mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 11:58:14 +01:00
Refactor code, add more gooda error thingy :3
This commit is contained in:
parent
cfb03a6003
commit
5b747a82dd
1 changed files with 243 additions and 235 deletions
|
@ -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,
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue