add filters!!

This commit is contained in:
Ashley 2023-11-11 18:39:45 +00:00
parent e15597573f
commit 2509fde9d3

View file

@ -62,6 +62,7 @@ module.exports = function (app, config, renderTemplate) {
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;
const tab = req.query.tab; const tab = req.query.tab;
@ -101,28 +102,28 @@ module.exports = function (app, config, renderTemplate) {
} }
let continuation = req.query.continuation || ""; let continuation = req.query.continuation || "";
let date = req.query.date || "";
let type = req.query.type || "";
let duration = req.query.duration || "";
let sort = req.query.sort || "";
try { try {
const headers = {}; const headers = {};
const searchUrl = `https://inner-api.poketube.fun/api/search?query=${encodeURIComponent( const xmlData = await fetch(`https://invid-api.poketube.fun/api/v1/search?q=${encodeURIComponent(
query query
)}&continuation=${encodeURIComponent(continuation)}`; )}&page=${encodeURIComponent(continuation)}&date=${date}&type=${type}&duration=${duration}&sort=${sort}&hl=en+gb`)
const player = await fetch(searchUrl); .then((res) => res.text())
const xmlData = await player.text(); .then((txt) => getJson(txt));
const searchJson = JSON.parse(modules.toJson(xmlData));
let didYouMean;
if (
searchJson.Search?.Results?.DynamicItem?.id === "didYouMeanRenderer"
) {
didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
}
renderTemplate(res, req, "search.ejs", { renderTemplate(res, req, "search.ejs", {
j: searchJson, invresults: xmlData,
turntomins,
date,
type,
duration,
sort,
IsOldWindows, IsOldWindows,
h: didYouMean,
tab, tab,
continuation, continuation,
results: "", results: "",