add duckduckgo bangs to searcg!! :3

This commit is contained in:
Ashley 2023-08-09 18:44:59 +00:00
parent 326ace45ac
commit a403dd8a1a

View file

@ -78,6 +78,11 @@ module.exports = function (app, config, renderTemplate) {
} }
} }
if (query && query.startsWith('!')) {
res.redirect("https://duckduckgo.com/?q=" + query)
}
if (!query) { if (!query) {
return res.redirect("/"); return res.redirect("/");
} }
@ -154,7 +159,6 @@ module.exports = function (app, config, renderTemplate) {
.then((res) => res.text()) .then((res) => res.text())
.then((txt) => getJson(txt)); .then((txt) => getJson(txt));
} catch (error) { } catch (error) {
console.error("Failed to fetch channel data from API:", error);
return null; return null;
} }
}; };
@ -191,10 +195,7 @@ module.exports = function (app, config, renderTemplate) {
var { tj, shorts, stream, c, boutJson } = cache[ID].result; var { tj, shorts, stream, c, boutJson } = cache[ID].result;
} }
const summary = await wiki.summary(boutJson?.Channel?.Metadata.Name); const subscribers = boutJson.Channel?.Metadata.Subscribers;
const wikiSummary = summary.title !== "Not found." ? summary : "none";
const subscribers = boutJson.Channel.Metadata.Subscribers;
const about = boutJson.Channel.Contents.ItemSection.About; const about = boutJson.Channel.Contents.ItemSection.About;
const description = about.Description.toString().replace(/\n/g, " <br> "); const description = about.Description.toString().replace(/\n/g, " <br> ");
const dnoreplace = about.Description.toString(); const dnoreplace = about.Description.toString();
@ -212,7 +213,7 @@ module.exports = function (app, config, renderTemplate) {
turntomins, turntomins,
dnoreplace, dnoreplace,
continuation, continuation,
wiki: wikiSummary, wiki: "",
getFirstLine, getFirstLine,
isMobile: req.useragent.isMobile, isMobile: req.useragent.isMobile,
about, about,