mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-23 03:17:47 +01:00
hmm
This commit is contained in:
parent
aac34995fd
commit
1e6b58a732
1 changed files with 4 additions and 29 deletions
|
@ -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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue