Improvements owowowowowo

This commit is contained in:
Ashley 2022-11-07 20:33:46 +01:00
parent 4952705e07
commit 04898a9205

View file

@ -130,6 +130,8 @@ app.get("/watch", async function (req, res) {
const jj = await info.text(); const jj = await info.text();
const ip = JSON.parse(jj); const ip = JSON.parse(jj);
for (let i = 0; i < 2; i++) {
try {
core.video(v).then((data) => { core.video(v).then((data) => {
const k = data.video; const k = data.video;
const json = data.json; const json = data.json;
@ -197,6 +199,16 @@ app.get("/watch", async function (req, res) {
lyrics: "", lyrics: "",
}); });
}); });
break;
} catch (err) {
if (err.status === 503) {
// retry after a bit
await new Promise((resolve) => setTimeout(resolve, 1000));
} else {
return "";
}
}
}
}); });
app.get("/music", async function (req, res) { app.get("/music", async function (req, res) {
@ -588,7 +600,6 @@ app.get("/api/instances.json", async (req, res) => {
///////////// REDIRECTS / DEPRACATED ///////////// ///////////// REDIRECTS / DEPRACATED /////////////
app.get("/discover", async function (req, res) { app.get("/discover", async function (req, res) {
const trends = await modules.fetch(config.tubeApi + `trending`); const trends = await modules.fetch(config.tubeApi + `trending`);
const h = await trends.text(); const h = await trends.text();
const k = JSON.parse(modules.toJson(h)); const k = JSON.parse(modules.toJson(h));
@ -631,7 +642,6 @@ app.get("/discover", async function (req, res) {
continuation, continuation,
j, j,
}); });
}); });
app.get("/hashtag/:id", (req, res) => { app.get("/hashtag/:id", (req, res) => {
@ -648,22 +658,17 @@ app.get("/video/upload", (req, res) => {
///////////// 404 AND MAIN PAGES ETC ///////////// ///////////// 404 AND MAIN PAGES ETC /////////////
app.get("/:v*?", async function (req, res) { app.get("/:v*?", async function (req, res) {
if (req.params.v) { if (req.params.v) {
const isvld = await core.isvalidvideo(req.params.v); const isvld = await core.isvalidvideo(req.params.v);
if (isvld) { if (isvld) {
return res.redirect(`/watch?v=${req.params.v}`) return res.redirect(`/watch?v=${req.params.v}`);
} else { } else {
return res.redirect("/discover"); return res.redirect("/discover");
} }
} else { } else {
return res.redirect("/discover"); return res.redirect("/discover");
} }
}); });
app.get("/*", function (req, res) { app.get("/*", function (req, res) {