From 1c6673f62eaba53094d900cfb6228606cb2a4853 Mon Sep 17 00:00:00 2001 From: Ashley //// Date: Thu, 25 Apr 2024 18:05:45 +0000 Subject: [PATCH] use config.invidapi instead --- src/libpoketube/libpoketube-core.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libpoketube/libpoketube-core.js b/src/libpoketube/libpoketube-core.js index 0cd49cf2..8b541b26 100644 --- a/src/libpoketube/libpoketube-core.js +++ b/src/libpoketube/libpoketube-core.js @@ -108,14 +108,19 @@ async getYouTubeApiVideo(f, v, contentlang, contentregion) { var p = this.getJson(await channel_uploads.text()); } - let retryCount = 0; - while (vid.error && retryCount < 2) { - console.log(`Retrying fetching videoInfo... Retry ${retryCount + 1}`); + let retryCount = 0; + while (vid.error && retryCount < 1) { + console.log(`Retrying fetching videoInfo from iv.ggtyler.dev... Retry ${retryCount + 1}`); const retryVideoInfo = await fetch(`https://iv.ggtyler.dev/api/v1/videos/${v}?hl=${contentlang}®ion=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()); vid = await this.getJson(retryVideoInfo); retryCount++; } + if (vid.error) { + const fallbackVideoInfo = await fetch(`${this.config.invapi}/videos/${v}?hl=${contentlang}®ion=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()); + vid = await this.getJson(fallbackVideoInfo); + } + if (!vid) { console.log( `Sorry nya, we couldn't find any information about that video qwq`