This commit is contained in:
Ashley 2023-10-21 05:29:20 +00:00
parent aac34995fd
commit 1e6b58a732

View file

@ -41,38 +41,13 @@ class PokeTubeDislikesAPIManager {
* @private * @private
*/ */
async _getEngagementData() { async _getEngagementData() {
const apiUrl = `https://p.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`; const apiUrl = `https://ipv6-t.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
const { fetch } = await import("undici"); const { fetch } = await import("undici");
var engagementp = await fetch(apiUrl)
try { var engagement = await engagementp.json();
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();
return engagement; return engagement;
} else {
console.error("Fallback URL also failed. Returning error.");
throw new Error("Both API and fallback URL requests failed.");
}
} }