add ryd api url back

This commit is contained in:
Ashley 2023-11-12 08:39:46 +00:00
parent b172ff12f9
commit f573d0ddeb

View file

@ -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 fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
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 engagement = await fetch(fallbackUrl).then((res) => res.json());
return engagement;
}
/**