mirror of
https://codeberg.org/ashley/poke.git
synced 2025-03-14 04:08:27 +01:00
add did you mean? prompt
This commit is contained in:
parent
64ff616867
commit
249a375aae
1 changed files with 142 additions and 121 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 {
|
const {
|
||||||
IsJsonString,
|
IsJsonString,
|
||||||
convert,
|
convert,
|
||||||
|
@ -41,17 +50,17 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
.getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`)
|
.getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`)
|
||||||
.then((colors) => colors[0].hex()),
|
.then((colors) => colors[0].hex()),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/old/watch", async function (req, res) {
|
app.get("/old/watch", async function (req, res) {
|
||||||
var v = req.query.v;
|
var v = req.query.v;
|
||||||
var e = req.query.e;
|
var e = req.query.e;
|
||||||
if (!v) res.redirect("/");
|
if (!v) res.redirect("/");
|
||||||
|
|
||||||
res.redirect(`/watch?v=${v}`);
|
res.redirect(`/watch?v=${v}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/search", async (req, res) => {
|
app.get("/search", async (req, res) => {
|
||||||
const query = req.query.query;
|
const query = req.query.query;
|
||||||
|
|
||||||
if (req.query.continuation) {
|
if (req.query.continuation) {
|
||||||
|
@ -72,19 +81,30 @@ 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,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/channel/", async (req, res) => {
|
app.get("/channel/", async (req, res) => {
|
||||||
const ID = req.query.id;
|
const ID = req.query.id;
|
||||||
const tab = req.query.tab;
|
const tab = req.query.tab;
|
||||||
|
|
||||||
|
@ -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));
|
||||||
|
@ -149,5 +170,5 @@ app.get("/channel/", async (req, res) => {
|
||||||
: "Private",
|
: "Private",
|
||||||
desc: d,
|
desc: d,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in a new issue