From 0ade5a62534754ad0df4f80688e71d87043604d5 Mon Sep 17 00:00:00 2001 From: Ashley Date: Sat, 21 Oct 2023 07:28:29 +0000 Subject: [PATCH] does this work idk qwq --- src/libpoketube/libpoketube-dislikes.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libpoketube/libpoketube-dislikes.js b/src/libpoketube/libpoketube-dislikes.js index 98b49963..2f0a56a7 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. @@ -40,16 +40,17 @@ class PokeTubeDislikesAPIManager { * @returns {Promise} A Promise that resolves with the engagement data, or null if an error occurs. * @private */ -async _getEngagementData() { - const apiUrl = `https://returnyoutubedislikesapi.com/votes?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`; - -const { fetch } = await import("undici"); -var engagementp = await fetch(apiUrl) - -var engagement = await engagementp.json(); - return engagement; -} + async _getEngagementData() { + var url = [`https://p.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`, `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`] + const dislikes = + url[Math.floor(Math.random() * url.length)]; + + const { fetch } = await import("undici"); + + const engagement = await fetch(dislikes).then((res) => res.json()); + return engagement; + } /** * Retrieves data about the YouTube video and its engagement. @@ -74,7 +75,7 @@ var engagement = await engagementp.json(); } /* -Returns basic data about a given YouTube video using PokeTubeDislikesAPIManager. +Returns basic data about a given YouTube video using PokeTubeAPI. @async @function @param {string} videoId - The YouTube video ID to get data for. @@ -84,7 +85,7 @@ Returns basic data about a given YouTube video using PokeTubeDislikesAPIManager. const getDislikesData = async (videoId) => { const pokeTubeAPI = new PokeTubeDislikesAPIManager(videoId); - return await PokeTubeDislikesAPIManager.getData(); + return await pokeTubeAPI.getData(); }; module.exports = getDislikesData;