this is one of the commits ever lol

This commit is contained in:
Ashley 2023-10-21 05:10:02 +00:00
parent 44f05a83af
commit 3f2576c83c

View file

@ -42,19 +42,24 @@ class PokeTubeDislikesAPIManager {
*/
async _getEngagementData() {
const apiUrl = `https://p.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
const { fetch } = await import("undici");
const { fetch } = await import("undici");
try {
var engagementP = await fetch(apiUrl).then((res) => res.json());
if(!engagementP.dislikes) {
if (typeof engagementP.dislikes === 'number') {
return engagementP;
} else {
throw new Error("API response doesn't contain valid dislikes count. Using fallback URL.");
}
} catch (error) {
var engagement = await fetch(fallbackUrl).then((res) => res.json());
return engagement;
} else {
return engagementP;
}
}
}
}
/**