mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-28 14:29:04 +01:00
add try catch :p
This commit is contained in:
parent
1aae2b4973
commit
da5daddf49
1 changed files with 35 additions and 31 deletions
|
@ -79,39 +79,43 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
const search = await modules.fetch(
|
try {
|
||||||
`https://tube-srv.ashley143.gay/api/search?query=${query.replace(
|
const search = await modules.fetch(
|
||||||
"&",
|
`https://tube-srv.ashley143.gay/api/search?query=${query.replace(
|
||||||
"and"
|
"&",
|
||||||
)}&continuation=${continuation}`
|
"and"
|
||||||
);
|
)}&continuation=${continuation}`
|
||||||
|
|
||||||
const text = await search.text();
|
|
||||||
const j = JSON.parse(modules.toJson(text));
|
|
||||||
|
|
||||||
h = " ";
|
|
||||||
|
|
||||||
if (j.Search) {
|
|
||||||
if ("Results.DynamicItem" in j.Search) {
|
|
||||||
if (j.Search.Results.DynamicItem.id == "didYouMeanRenderer") {
|
|
||||||
var h = JSON.parse(j.Search.Results.DynamicItem.Title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const summary = await wiki
|
|
||||||
.summary(query + " ")
|
|
||||||
.then((summary_) =>
|
|
||||||
summary_.title !== "Not found." ? summary_ : "none"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
renderTemplate(res, req, "search.ejs", {
|
const text = await search.text();
|
||||||
j,
|
const j = JSON.parse(modules.toJson(text));
|
||||||
h,
|
|
||||||
continuation,
|
h = " ";
|
||||||
q: query,
|
|
||||||
summary,
|
if (j.Search) {
|
||||||
});
|
if ("Results.DynamicItem" in j.Search) {
|
||||||
|
if (j.Search.Results.DynamicItem.id == "didYouMeanRenderer") {
|
||||||
|
var h = JSON.parse(j.Search.Results.DynamicItem.Title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const summary = await wiki
|
||||||
|
.summary(query + " ")
|
||||||
|
.then((summary_) =>
|
||||||
|
summary_.title !== "Not found." ? summary_ : "none"
|
||||||
|
);
|
||||||
|
|
||||||
|
renderTemplate(res, req, "search.ejs", {
|
||||||
|
j,
|
||||||
|
h,
|
||||||
|
continuation,
|
||||||
|
q: query,
|
||||||
|
summary,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
res.redirect("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue