mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 23:17:57 +01:00
this is one of the commits ever lol
This commit is contained in:
parent
44f05a83af
commit
3f2576c83c
1 changed files with 15 additions and 10 deletions
|
@ -41,20 +41,25 @@ class PokeTubeDislikesAPIManager {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _getEngagementData() {
|
async _getEngagementData() {
|
||||||
const apiUrl = `https://p.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
|
const apiUrl = `https://p.poketube.fun/api?v=${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
|
||||||
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
|
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
|
||||||
|
|
||||||
const { fetch } = await import("undici");
|
const { fetch } = await import("undici");
|
||||||
|
|
||||||
var engagementP = await fetch(apiUrl).then((res) => res.json());
|
try {
|
||||||
|
var engagementP = await fetch(apiUrl).then((res) => res.json());
|
||||||
|
|
||||||
if(!engagementP.dislikes) {
|
if (typeof engagementP.dislikes === 'number') {
|
||||||
var engagement = await fetch(fallbackUrl).then((res) => res.json());
|
return engagementP;
|
||||||
return engagement;
|
} else {
|
||||||
} else {
|
throw new Error("API response doesn't contain valid dislikes count. Using fallback URL.");
|
||||||
return engagementP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
var engagement = await fetch(fallbackUrl).then((res) => res.json());
|
||||||
|
return engagement;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue