mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 11:58:14 +01:00
fix a silly issue :3
This commit is contained in:
parent
bbd66005a3
commit
5bed2dba4e
1 changed files with 71 additions and 62 deletions
|
@ -1,4 +1,13 @@
|
||||||
const { fetcher,core, wiki,musicInfo, modules, version, initlog, init,} = require("../libpoketube-initsys.js");
|
const {
|
||||||
|
fetcher,
|
||||||
|
core,
|
||||||
|
wiki,
|
||||||
|
musicInfo,
|
||||||
|
modules,
|
||||||
|
version,
|
||||||
|
initlog,
|
||||||
|
init,
|
||||||
|
} = require("../libpoketube-initsys.js");
|
||||||
const {
|
const {
|
||||||
IsJsonString,
|
IsJsonString,
|
||||||
convert,
|
convert,
|
||||||
|
@ -12,71 +21,71 @@ const {
|
||||||
const sha384 = modules.hash;
|
const sha384 = modules.hash;
|
||||||
|
|
||||||
module.exports = function (app, config, renderTemplate) {
|
module.exports = function (app, config, renderTemplate) {
|
||||||
app.get("/:v*?", async function (req, res) {
|
app.get("/discover", async function (req, res) {
|
||||||
let rendermainpage = () => {
|
const trends = await modules.fetch(config.tubeApi + `trending`);
|
||||||
if (req.useragent.isMobile) {
|
const h = await trends.text();
|
||||||
return res.redirect(`/discover`);
|
const k = JSON.parse(modules.toJson(h));
|
||||||
} else {
|
|
||||||
return renderTemplate(res, req, "landing.ejs");
|
if (req.query.tab)
|
||||||
|
var tab = `/?type=${capitalizeFirstLetter(req.query.tab)}`;
|
||||||
|
|
||||||
|
if (!req.query.tab) var tab = "";
|
||||||
|
|
||||||
|
const invtrend = await modules
|
||||||
|
.fetch(`https://vid.puffyan.us/api/v1/trending${tab}`)
|
||||||
|
.then((res) => res.text());
|
||||||
|
|
||||||
|
const t = JSON.parse(invtrend);
|
||||||
|
|
||||||
|
if (req.query.mobilesearch) {
|
||||||
|
var query = req.query.mobilesearch;
|
||||||
|
tab = "search";
|
||||||
|
if (req.query.continuation) {
|
||||||
|
var continuation = req.query.continuation;
|
||||||
|
}
|
||||||
|
if (!req.query.continuation) {
|
||||||
|
var continuation = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const search = await modules.fetch(
|
||||||
|
`https://tube.kuylar.dev/api/search?query=${query}&continuation=${continuation}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const text = await search.text();
|
||||||
|
var j = JSON.parse(modules.toJson(text));
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (req.params.v) {
|
renderTemplate(res, req, "main.ejs", {
|
||||||
const isvld = await core.isvalidvideo(req.params.v);
|
k: k,
|
||||||
|
tab: req.query.tab,
|
||||||
|
isMobile: req.useragent.isMobile,
|
||||||
|
mobilesearch: req.query.mobilesearch,
|
||||||
|
inv: t,
|
||||||
|
turntomins,
|
||||||
|
continuation,
|
||||||
|
j,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (isvld) {
|
app.get("/:v*?", async function (req, res) {
|
||||||
return res.redirect(`/watch?v=${req.params.v}`);
|
let rendermainpage = () => {
|
||||||
|
if (req.useragent.isMobile) {
|
||||||
|
return res.redirect(`/discover`);
|
||||||
|
} else {
|
||||||
|
return renderTemplate(res, req, "landing.ejs");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (req.params.v) {
|
||||||
|
const isvld = await core.isvalidvideo(req.params.v);
|
||||||
|
|
||||||
|
if (isvld) {
|
||||||
|
return res.redirect(`/watch?v=${req.params.v}`);
|
||||||
|
} else {
|
||||||
|
return rendermainpage();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return rendermainpage();
|
return rendermainpage();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return rendermainpage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/discover", async function (req, res) {
|
|
||||||
const trends = await modules.fetch(config.tubeApi + `trending`);
|
|
||||||
const h = await trends.text();
|
|
||||||
const k = JSON.parse(modules.toJson(h));
|
|
||||||
|
|
||||||
if (req.query.tab) var tab = `/?type=${capitalizeFirstLetter(req.query.tab)}`;
|
|
||||||
|
|
||||||
if (!req.query.tab) var tab = "";
|
|
||||||
|
|
||||||
const invtrend = await modules
|
|
||||||
.fetch(`https://vid.puffyan.us/api/v1/trending${tab}`)
|
|
||||||
.then((res) => res.text());
|
|
||||||
|
|
||||||
const t = JSON.parse(invtrend);
|
|
||||||
|
|
||||||
if (req.query.mobilesearch) {
|
|
||||||
var query = req.query.mobilesearch;
|
|
||||||
tab = "search";
|
|
||||||
if (req.query.continuation) {
|
|
||||||
var continuation = req.query.continuation;
|
|
||||||
}
|
|
||||||
if (!req.query.continuation) {
|
|
||||||
var continuation = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
const search = await modules.fetch(
|
|
||||||
`https://tube.kuylar.dev/api/search?query=${query}&continuation=${continuation}`
|
|
||||||
);
|
|
||||||
|
|
||||||
const text = await search.text();
|
|
||||||
var j = JSON.parse(modules.toJson(text));
|
|
||||||
}
|
|
||||||
|
|
||||||
renderTemplate(res, req, "main.ejs", {
|
|
||||||
k: k,
|
|
||||||
tab: req.query.tab,
|
|
||||||
isMobile: req.useragent.isMobile,
|
|
||||||
mobilesearch: req.query.mobilesearch,
|
|
||||||
inv: t,
|
|
||||||
turntomins,
|
|
||||||
continuation,
|
|
||||||
j,
|
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue