mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 23:17:57 +01:00
add ryd api url back
This commit is contained in:
parent
b172ff12f9
commit
f573d0ddeb
1 changed files with 8 additions and 27 deletions
|
@ -9,7 +9,7 @@
|
||||||
/**
|
/**
|
||||||
* A class representing a PokeTube API instance for a specific video.
|
* 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.
|
* Creates a new PokeTube API instance for the given video ID.
|
||||||
* @param {string} videoId - The ID of the YouTube video.
|
* @param {string} videoId - The ID of the YouTube video.
|
||||||
|
@ -41,31 +41,12 @@ class PokeTubeDislikesAPIManager {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _getEngagementData() {
|
async _getEngagementData() {
|
||||||
const apiUrls = [
|
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
|
||||||
"https://returnyoutubedislikeapi.com/votes?videoId=",
|
|
||||||
"https://prod-poketube.testing.poketube.fun/api?v=",
|
const { fetch } = await import("undici");
|
||||||
];
|
|
||||||
|
const engagement = await fetch(fallbackUrl).then((res) => res.json());
|
||||||
const { fetch } = await import("undici");
|
return engagement;
|
||||||
|
|
||||||
// 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 "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +58,7 @@ class PokeTubeDislikesAPIManager {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
engagement: this.engagement,
|
engagement: this.engagement,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue