1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2024-11-17 03:14:40 -05:00

use duckduckscrape :3

This commit is contained in:
Ashley //// 2024-02-10 09:06:57 +00:00
parent 143353d4ae
commit 5f4c1783f9

View file

@ -53,7 +53,7 @@ const ChannelTabs = {
channels: "Y2hhbm5lbHM=",
store: "c3RvcmU=",
released: "cmVsZWFzZWQ=",
playlist:"cGxheWxpc3Rz"
playlist: "cGxheWxpc3Rz",
};
module.exports = function (app, config, renderTemplate) {
@ -167,14 +167,14 @@ module.exports = function (app, config, renderTemplate) {
});
app.get("/im-feeling-lucky", function (req, res) {
res.send("WIP")
res.send("WIP");
});
app.get("/web", async (req, res) => {
const query = req.query.query;
const tab = req.query.tab;
const search = require("duckduckgo-search");
const DDG = require("duck-duck-scrape");
if (req.query.lucky === "true") {
res.redirect("/im-feeling-lucky?query=" + query);
@ -213,11 +213,11 @@ module.exports = function (app, config, renderTemplate) {
let continuation = req.query.continuation || "";
try {
const results = []; // Initialize an array to store search results
const searchResults = await DDG.search(query, {
safeSearch: DDG.SafeSearchType.OFF,
});
for await (const result of search.text(query)) {
results.push(result); // Push each result to the results array
}
const results = searchResults.results;
renderTemplate(res, req, "search-web.ejs", {
j: "",
@ -306,7 +306,7 @@ module.exports = function (app, config, renderTemplate) {
const channelINVUrl = `${apiUrl}${ID}/`;
var [tj, shorts, playlist , stream, c, cinv] = await Promise.all([
var [tj, shorts, playlist, stream, c, cinv] = await Promise.all([
getChannelData(channelUrl),
getChannelData(shortsUrl),
getChannelData(PlaylistUrl),