mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-14 17:28:43 +01:00
test this
This commit is contained in:
parent
45c5ba9201
commit
5f383b53d1
1 changed files with 27 additions and 8 deletions
|
@ -41,12 +41,31 @@ class PokeTubeDislikesAPIManager {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _getEngagementData() {
|
async _getEngagementData() {
|
||||||
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
|
const apiUrls = [
|
||||||
|
"https://returnyoutubedislikeapi.com/votes?videoId=",
|
||||||
|
"https://prod-poketube.testing.poketube.fun/api?v=",
|
||||||
|
];
|
||||||
|
|
||||||
const { fetch } = await import("undici");
|
const { fetch } = await import("undici");
|
||||||
|
|
||||||
const engagement = await fetch(fallbackUrl).then((res) => res.json());
|
// Initialize an array to store errors when trying different URLs
|
||||||
return engagement;
|
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 "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue