1
0
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2024-11-17 10:34:38 -05:00

add try catch :p

This commit is contained in:
Ashley 2023-03-02 15:05:53 +00:00
parent a0cce7d4a1
commit ce1e7d8473

View file

@ -83,7 +83,6 @@ async function video(v) {
var comments = ""; var comments = "";
} }
const urls = [ const urls = [
"invidious.sethforprivacy.com", "invidious.sethforprivacy.com",
"invidious.weblibre.org", "invidious.weblibre.org",
@ -94,21 +93,25 @@ async function video(v) {
let vid; let vid;
for (const url of urls) { try {
const videoInfo = await fetch(`https://${url}/api/v1/videos/${v}`).then(res => res.text()); for (const url of urls) {
vid = await getJson(videoInfo); const videoInfo = await fetch(`https://${url}/api/v1/videos/${v}`).then(res => res.text());
vid = await getJson(videoInfo);
if (vid?.descriptionHtml !== "<p></p>") { if (vid?.descriptionHtml !== "<p></p>") {
break; break;
}
} }
}
if (!vid) { if (!vid) {
// Handle error case
throw new Error('Unable to fetch video information.');
}
} catch (error) {
console.error(error);
// Handle error case // Handle error case
} }
if (checkUnexistingObject(vid)) { if (checkUnexistingObject(vid)) {
var a; var a;