From 1e6b58a7329a23437b0f09086e5fea9a3ba0c623 Mon Sep 17 00:00:00 2001 From: Ashley Date: Sat, 21 Oct 2023 05:29:20 +0000 Subject: [PATCH] hmm --- src/libpoketube/libpoketube-dislikes.js | 33 +++---------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/libpoketube/libpoketube-dislikes.js b/src/libpoketube/libpoketube-dislikes.js index f436eb07..5544f24f 100644 --- a/src/libpoketube/libpoketube-dislikes.js +++ b/src/libpoketube/libpoketube-dislikes.js @@ -41,38 +41,13 @@ class PokeTubeDislikesAPIManager { * @private */ async _getEngagementData() { - const apiUrl = `https://p.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`; -const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`; - + const apiUrl = `https://ipv6-t.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`; + const { fetch } = await import("undici"); +var engagementp = await fetch(apiUrl) -try { - var engagementP = await fetch(apiUrl) - .then((res) => { - if (res.statusCode === 504) { - throw new Error("Request timed out."); - } - return res.json(); - }); - - if (typeof engagementP.dislikes === 'number') { - return engagementP; - } else { - throw new Error("API response doesn't contain valid dislikes count."); - } -} catch (error) { - console.error(error); - - // Check the status of the fallback URL response. - var fallbackResponse = await fetch(fallbackUrl); - - if (fallbackResponse.statusCode === 200) { - var engagement = await fallbackResponse.json(); +var engagement = await engagementp.json(); return engagement; - } else { - console.error("Fallback URL also failed. Returning error."); - throw new Error("Both API and fallback URL requests failed."); - } }