add did you mean? prompt

This commit is contained in:
Ashley 2022-11-18 09:42:25 +00:00
parent 956df8e5cf
commit e3cb7256ee

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 { const {
IsJsonString, IsJsonString,
convert, convert,
@ -72,12 +81,23 @@ app.get("/search", async (req, res) => {
return res.redirect("/"); return res.redirect("/");
} }
h = " ";
if (j.Search.Results.DynamicItem) {
if (j.Search.Results.DynamicItem.id == "didYouMeanRenderer") {
var h = JSON.parse(j.Search.Results.DynamicItem.Title);
}
}
const summary = await wiki const summary = await wiki
.summary(query + " ") .summary(query + " ")
.then((summary_) => (summary_.title !== "Not found." ? summary_ : "none")); .then((summary_) =>
summary_.title !== "Not found." ? summary_ : "none"
);
renderTemplate(res, req, "search.ejs", { renderTemplate(res, req, "search.ejs", {
j, j,
h,
continuation, continuation,
q: query, q: query,
summary, summary,
@ -104,7 +124,8 @@ app.get("/channel/", async (req, res) => {
//videos //videos
const channel = await modules.fetch( const channel = await modules.fetch(
config.tubeApi + `channel?id=${ID}&tab=shorts&Continuation=${continuation}` config.tubeApi +
`channel?id=${ID}&tab=shorts&Continuation=${continuation}`
); );
const c = await channel.text(); const c = await channel.text();
const tj = JSON.parse(modules.toJson(c)); const tj = JSON.parse(modules.toJson(c));
@ -150,4 +171,4 @@ app.get("/channel/", async (req, res) => {
desc: d, desc: d,
}); });
}); });
} };