mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 18:38:18 +01:00
make it faster
This commit is contained in:
parent
6e2907f667
commit
d79678d4cc
1 changed files with 61 additions and 35 deletions
|
@ -32,10 +32,10 @@ function getJson(str) {
|
||||||
|
|
||||||
const ChannelTabs = {
|
const ChannelTabs = {
|
||||||
community: "Y29tbXVuaXR5",
|
community: "Y29tbXVuaXR5",
|
||||||
shorts:"c2hvcnRz",
|
shorts: "c2hvcnRz",
|
||||||
videos:"dmlkZW9z",
|
videos: "dmlkZW9z",
|
||||||
streams:"c3RyZWFtcw=="
|
streams: "c3RyZWFtcw==",
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = function (app, config, renderTemplate) {
|
module.exports = function (app, config, renderTemplate) {
|
||||||
app.get("/download", async function (req, res) {
|
app.get("/download", async function (req, res) {
|
||||||
|
@ -63,10 +63,9 @@ 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 search = require('google-it')
|
|
||||||
|
|
||||||
|
const search = require("google-it");
|
||||||
|
|
||||||
var uaos = req.useragent.os;
|
var uaos = req.useragent.os;
|
||||||
var IsOldWindows;
|
var IsOldWindows;
|
||||||
|
@ -114,24 +113,41 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
const searchJson = getJson(searchText);
|
const searchJson = getJson(searchText);
|
||||||
|
|
||||||
let didYouMean;
|
let didYouMean;
|
||||||
if ( searchJson.Search?.Results?.DynamicItem?.id === "didYouMeanRenderer" ) { didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
|
if (
|
||||||
|
searchJson.Search?.Results?.DynamicItem?.id === "didYouMeanRenderer"
|
||||||
|
) {
|
||||||
|
didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
search({'query': `${req.query.query}`}).then(results => {
|
if (tab) {
|
||||||
|
search({ query: `${req.query.query}` })
|
||||||
|
.then((results) => {
|
||||||
renderTemplate(res, req, "search.ejs", {
|
renderTemplate(res, req, "search.ejs", {
|
||||||
j: searchJson,
|
j: searchJson,
|
||||||
IsOldWindows,
|
IsOldWindows,
|
||||||
h: didYouMean,
|
h: didYouMean,
|
||||||
tab,
|
tab,
|
||||||
continuation,
|
continuation,
|
||||||
results:results,
|
results: results,
|
||||||
q: query,
|
q: query,
|
||||||
summary: "",
|
summary: "",
|
||||||
});
|
});
|
||||||
}).catch(e => {
|
})
|
||||||
console.log(e)
|
.catch((e) => {
|
||||||
})
|
console.log(e);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
renderTemplate(res, req, "search.ejs", {
|
||||||
|
j: searchJson,
|
||||||
|
IsOldWindows,
|
||||||
|
h: didYouMean,
|
||||||
|
tab,
|
||||||
|
continuation,
|
||||||
|
results: "",
|
||||||
|
q: query,
|
||||||
|
summary: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error while searching for '${query}':`, error);
|
console.error(`Error while searching for '${query}':`, error);
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
|
@ -175,12 +191,19 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const apiUrl = "https://invid-api.poketube.fun/api/v1/channels/";
|
const apiUrl = "https://invid-api.poketube.fun/api/v1/channels/";
|
||||||
const channelUrl = `${apiUrl}${atob(ChannelTabs.videos)}/${ID}/?sort_by=${sort_by}${continuation}`;
|
const channelUrl = `${apiUrl}${atob(
|
||||||
const shortsUrl = `${apiUrl}${ID}/${atob(ChannelTabs.shorts)}?sort_by=${sort_by}${continuations}`;
|
ChannelTabs.videos
|
||||||
const streamUrl = `${apiUrl}${ID}/${atob(ChannelTabs.streams)}?sort_by=${sort_by}${continuationl}`;
|
)}/${ID}/?sort_by=${sort_by}${continuation}`;
|
||||||
const communityUrl = `${apiUrl}${atob(ChannelTabs.community)}/${ID}/?hl=en-US`;
|
const shortsUrl = `${apiUrl}${ID}/${atob(
|
||||||
|
ChannelTabs.shorts
|
||||||
|
)}?sort_by=${sort_by}${continuations}`;
|
||||||
|
const streamUrl = `${apiUrl}${ID}/${atob(
|
||||||
|
ChannelTabs.streams
|
||||||
|
)}?sort_by=${sort_by}${continuationl}`;
|
||||||
|
const communityUrl = `${apiUrl}${atob(
|
||||||
|
ChannelTabs.community
|
||||||
|
)}/${ID}/?hl=en-US`;
|
||||||
|
|
||||||
const channelINVUrl = `${apiUrl}${ID}/`;
|
const channelINVUrl = `${apiUrl}${ID}/`;
|
||||||
|
|
||||||
|
@ -210,7 +233,10 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
|
|
||||||
const subscribers = boutJson.Channel?.Metadata.Subscribers;
|
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();
|
||||||
|
|
||||||
renderTemplate(res, req, "channel.ejs", {
|
renderTemplate(res, req, "channel.ejs", {
|
||||||
|
|
Loading…
Reference in a new issue