mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 06:28:35 +01:00
use undici instead :3
This commit is contained in:
parent
7774ba67dd
commit
4e586e9cbd
1 changed files with 8 additions and 9 deletions
|
@ -47,7 +47,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
color: await modules
|
color: await modules
|
||||||
.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()),
|
||||||
isMobile: req.useragent.isMobile,
|
isMobile: req.useragent.isMobile,
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
|
@ -65,6 +65,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
app.get("/search", async (req, res) => {
|
app.get("/search", async (req, res) => {
|
||||||
const query = req.query.query;
|
const query = req.query.query;
|
||||||
const tab = req.query.tab;
|
const tab = req.query.tab;
|
||||||
|
const { fetch } = await import("undici");
|
||||||
|
|
||||||
const search = require("google-it");
|
const search = require("google-it");
|
||||||
|
|
||||||
|
@ -107,11 +108,9 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
const searchUrl = `https://inner-api.poketube.fun/api/search?query=${encodeURIComponent(
|
const searchUrl = `https://inner-api.poketube.fun/api/search?query=${encodeURIComponent(
|
||||||
query
|
query
|
||||||
)}&continuation=${encodeURIComponent(continuation)}`;
|
)}&continuation=${encodeURIComponent(continuation)}`;
|
||||||
const { data } = await curly.get(searchUrl, {
|
const player = await fetch(searchUrl);
|
||||||
httpHeader: Object.entries(headers).map(([k, v]) => `${k}: ${v}`),
|
const xmlData = await player.text();
|
||||||
});
|
const searchJson = JSON.parse(modules.toJson(xmlData));
|
||||||
const searchText = modules.toJson(data);
|
|
||||||
const searchJson = getJson(searchText);
|
|
||||||
|
|
||||||
let didYouMean;
|
let didYouMean;
|
||||||
if (
|
if (
|
||||||
|
@ -170,8 +169,8 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return renderTemplate(res, req, "search-web-main.ejs");
|
return renderTemplate(res, req, "search-web-main.ejs");
|
||||||
}
|
}
|
||||||
|
|
||||||
let continuation = req.query.continuation || "";
|
let continuation = req.query.continuation || "";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue