mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-14 18:08:49 +01:00
add try catch :p
This commit is contained in:
parent
24d21fda9d
commit
d0583af7f5
1 changed files with 53 additions and 51 deletions
|
@ -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,61 +131,64 @@ 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
|
||||||
|
.fetch(`${config.invapi}/channels/community/${ID}/`)
|
||||||
|
.then((res) => res.text());
|
||||||
|
|
||||||
const community = await modules.fetch(`${config.invapi}/channels/community/${ID}/`).then((res) =>
|
var c = await getJson(community);
|
||||||
res.text()
|
|
||||||
);
|
|
||||||
|
|
||||||
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 = "";
|
||||||
|
if (summary.title === "Not found.") {
|
||||||
|
w = "none";
|
||||||
|
}
|
||||||
|
if (summary.title !== "Not found.") {
|
||||||
|
w = summary;
|
||||||
|
}
|
||||||
|
|
||||||
var w = "";
|
const { Subscribers: subscribers } = k.Channel.Metadata;
|
||||||
if (summary.title === "Not found.") {
|
const description = k.Channel.Contents.ItemSection.About.Description;
|
||||||
w = "none";
|
|
||||||
|
var d = description.toString().replace(/\n/g, " <br> ");
|
||||||
|
if (d === "[object Object]") {
|
||||||
|
var d = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
var dnoreplace = description.toString();
|
||||||
|
if (dnoreplace === "[object Object]") {
|
||||||
|
var dnoreplace = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTemplate(res, req, "channel.ejs", {
|
||||||
|
ID,
|
||||||
|
tab,
|
||||||
|
j: k,
|
||||||
|
tj,
|
||||||
|
c,
|
||||||
|
convert,
|
||||||
|
turntomins,
|
||||||
|
dnoreplace: dnoreplace,
|
||||||
|
continuation: continuation,
|
||||||
|
wiki: w,
|
||||||
|
getFirstLine: getFirstLine,
|
||||||
|
isMobile: req.useragent.isMobile,
|
||||||
|
about: k.Channel.Contents.ItemSection.About,
|
||||||
|
subs:
|
||||||
|
typeof subscribers === "string"
|
||||||
|
? subscribers.replace("subscribers", "")
|
||||||
|
: "Private",
|
||||||
|
desc: d,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
if (summary.title !== "Not found.") {
|
|
||||||
w = summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { Subscribers: subscribers } = k.Channel.Metadata;
|
|
||||||
const description = k.Channel.Contents.ItemSection.About.Description;
|
|
||||||
|
|
||||||
var d = description.toString().replace(/\n/g, " <br> ");
|
|
||||||
if (d === "[object Object]") {
|
|
||||||
var d = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
var dnoreplace = description.toString();
|
|
||||||
if (dnoreplace === "[object Object]") {
|
|
||||||
var dnoreplace = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
renderTemplate(res, req, "channel.ejs", {
|
|
||||||
ID,
|
|
||||||
tab,
|
|
||||||
j: k,
|
|
||||||
tj,
|
|
||||||
c,
|
|
||||||
convert,
|
|
||||||
turntomins,
|
|
||||||
dnoreplace: dnoreplace,
|
|
||||||
continuation: continuation,
|
|
||||||
wiki: w,
|
|
||||||
getFirstLine: getFirstLine,
|
|
||||||
isMobile: req.useragent.isMobile,
|
|
||||||
about: k.Channel.Contents.ItemSection.About,
|
|
||||||
subs:
|
|
||||||
typeof subscribers === "string"
|
|
||||||
? subscribers.replace("subscribers", "")
|
|
||||||
: "Private",
|
|
||||||
desc: d,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue