mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 15:38:14 +01:00
fix some issues regarding the api :3
This commit is contained in:
parent
ff3406e4d5
commit
99501793c2
1 changed files with 13 additions and 8 deletions
21
server.js
21
server.js
|
@ -177,19 +177,24 @@ app.get("/watch", async function (req, res) {
|
||||||
|
|
||||||
var badges = "";
|
var badges = "";
|
||||||
|
|
||||||
// try 4 times, thanks kuylar
|
// try few times, thanks kuylar
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
try {
|
try {
|
||||||
const nightly = await fetch(
|
const nightly = await fetch(
|
||||||
`https://lighttube-nightly.kuylar.dev/api/video?v=${v}`
|
`https://lighttube-nightly.kuylar.dev/api/video?v=${v}`
|
||||||
);
|
);
|
||||||
var n = await nightly.text();
|
var n = await nightly.text();
|
||||||
|
|
||||||
|
if(n == undefined) {
|
||||||
|
for(let i=0;i<3;i+=1){try{const nightly=await fetch(`https://lighttube-nightly.kuylar.dev/api/video?v=${ v }`);var n=await nightly.text()}catch(err){if(err.status===500){await new Promise((resolve)=>setTimeout(resolve,1000))}else{return(n="")}}}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 503) {
|
if (err.status === 500) {
|
||||||
// retry after a bit
|
// retry after a bit
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
} else {
|
} else {
|
||||||
return (n = "none");
|
return (n = "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,15 +203,15 @@ app.get("/watch", async function (req, res) {
|
||||||
var nnn = "";
|
var nnn = "";
|
||||||
var comments = "";
|
var comments = "";
|
||||||
|
|
||||||
if (n === "none") {
|
if (n == "") {
|
||||||
badges, nnn, comments = "";
|
badges, nnn, comments = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsJsonString(n)) {
|
if (IsJsonString(n)) {
|
||||||
if (n !== "none") {
|
if (n != "") {
|
||||||
badges = JSON.parse(n).channel.badges[0];
|
|
||||||
nnn = JSON.parse(n);
|
nnn = JSON.parse(n);
|
||||||
comments = JSON.parse(n).commentCount;
|
badges = nnn.channel.badges[0];
|
||||||
|
comments = nnn.commentCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue