mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 23:57:50 +01:00
lets try this
This commit is contained in:
parent
2c52963c84
commit
bfbf1fc795
1 changed files with 3 additions and 3 deletions
|
@ -42,14 +42,14 @@ class PokeTubeDislikesAPIManager {
|
||||||
*/
|
*/
|
||||||
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");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Set a timeout of 2 seconds.
|
// Set a timeout of 2 seconds.
|
||||||
const timeoutMilliseconds = 2000; // 2 seconds
|
const timeoutMilliseconds = 2000; // 2 seconds
|
||||||
var engagementP = await fetch(apiUrl, { timeout: timeoutMilliseconds })
|
var engagementP = await fetch(fallbackUrl, { timeout: timeoutMilliseconds })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.statusCode === 504) {
|
if (res.statusCode === 504) {
|
||||||
throw new Error("Request timed out.");
|
throw new Error("Request timed out.");
|
||||||
|
@ -64,7 +64,7 @@ try {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
var engagement = await fetch(fallbackUrl).then((res) => res.json());
|
var engagement = await fetch(apiUrl).then((res) => res.json());
|
||||||
return engagement;
|
return engagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue