add try catch :p

This commit is contained in:
Ashley 2022-12-18 15:30:24 +00:00
parent 389844dc40
commit 3d44c7b6b4

View file

@ -18,7 +18,7 @@ const {
getRandomArbitrary, getRandomArbitrary,
} = require("../ptutils/libpt-coreutils.js"); } = require("../ptutils/libpt-coreutils.js");
const sha384 = modules.hash const sha384 = modules.hash;
function getJson(str) { function getJson(str) {
try { try {
@ -28,7 +28,6 @@ function getJson(str) {
} }
} }
module.exports = function (app, config, renderTemplate) { module.exports = function (app, config, renderTemplate) {
app.get("/download", async function (req, res) { app.get("/download", async function (req, res) {
var v = req.query.v; var v = req.query.v;
@ -132,19 +131,19 @@ module.exports = function (app, config, renderTemplate) {
} }
//videos //videos
const a = await modules.fetch(`${config.invapi}/channels/videos/${ID}/`).then((res) => const a = await modules
res.text() .fetch(`${config.invapi}/channels/videos/${ID}/`)
); .then((res) => res.text());
var tj = await getJson(a); var tj = await getJson(a);
const community = await modules
const community = await modules.fetch(`${config.invapi}/channels/community/${ID}/`).then((res) => .fetch(`${config.invapi}/channels/community/${ID}/`)
res.text() .then((res) => res.text());
);
var c = await getJson(community); var c = await getJson(community);
try {
const summary = await wiki.summary(k.Channel.Metadata.Name); const summary = await wiki.summary(k.Channel.Metadata.Name);
var w = ""; var w = "";
@ -188,5 +187,8 @@ module.exports = function (app, config, renderTemplate) {
: "Private", : "Private",
desc: d, desc: d,
}); });
} catch {
res.redirect("/");
}
}); });
}; };