From bcbb72bc7e3b8eea6fc1b4477654f698ba3ea9c5 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 2 Mar 2023 20:26:26 +0000 Subject: [PATCH] Update 'src/libpoketube/libpoketube-core.js' --- src/libpoketube/libpoketube-core.js | 38 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/libpoketube/libpoketube-core.js b/src/libpoketube/libpoketube-core.js index 10685b35..d81909e0 100644 --- a/src/libpoketube/libpoketube-core.js +++ b/src/libpoketube/libpoketube-core.js @@ -83,35 +83,37 @@ async function video(v) { var comments = ""; } - const urls = [ + const urls = [ "invidious.sethforprivacy.com", "invidious.weblibre.org", - "inv.vern.cc", - "invidious.privacydev.net", "inv.zzls.xyz", - "vid.puffyan.us" -]; - + "invidious.privacydev.net" + ]; + let vid; -try { - for (const url of urls) { + for (const url of urls) { + try { const videoInfo = await fetch(`https://${url}/api/v1/videos/${v}`).then(res => res.text()); vid = await getJson(videoInfo); - if (vid?.descriptionHtml !== "

") { - break; + switch (true) { + case vid?.descriptionHtml !== "

": + break; + default: + continue; } + break; + } catch (error) { + continue; } - - if (!vid) { - // Handle error case - throw new Error('Unable to fetch video information.'); - } -} catch (error) { - console.error(error); - // Handle error case } + + +if (!vid) { + console.log(`Sorry nya, we couldn't find any information about that video qwq`); +} + if (checkUnexistingObject(vid)) { var a;