From f573d0ddeb99b95215973bb63d337687a52d3a2b Mon Sep 17 00:00:00 2001 From: Ashley Date: Sun, 12 Nov 2023 08:39:46 +0000 Subject: [PATCH] add ryd api url back --- src/libpoketube/libpoketube-dislikes.js | 35 ++++++------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/src/libpoketube/libpoketube-dislikes.js b/src/libpoketube/libpoketube-dislikes.js index 7af72c0..8016bb3 100644 --- a/src/libpoketube/libpoketube-dislikes.js +++ b/src/libpoketube/libpoketube-dislikes.js @@ -9,7 +9,7 @@ /** * A class representing a PokeTube API instance for a specific video. */ -class PokeTubeDislikesAPIManager { +class PokeTubeDislikesAPIManager { /** * Creates a new PokeTube API instance for the given video ID. * @param {string} videoId - The ID of the YouTube video. @@ -41,31 +41,12 @@ class PokeTubeDislikesAPIManager { * @private */ async _getEngagementData() { - const apiUrls = [ - "https://returnyoutubedislikeapi.com/votes?videoId=", - "https://prod-poketube.testing.poketube.fun/api?v=", - ]; - - const { fetch } = await import("undici"); - - // Initialize an array to store errors when trying different URLs - const errors = []; - - for (const apiUrl of apiUrls) { - try { - // Fetch data from the current URL - const engagement = await fetch(apiUrl + this.videoId).then((res) => - res.json() - ); - - return engagement; // Exit the loop if successful - } catch (err) { - // Log the error for this URL and continue to the next URL - console.log(`Error fetching data from ${apiUrl}: ${err.message}`); - errors.push(err.message); - return ""; - } - } + const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`; + + const { fetch } = await import("undici"); + + const engagement = await fetch(fallbackUrl).then((res) => res.json()); + return engagement; } /** @@ -77,7 +58,7 @@ class PokeTubeDislikesAPIManager { return { engagement: this.engagement, - }; + }; } /**