mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 17:37:51 +01:00
remove some unneeded stuff :3
This commit is contained in:
parent
57d5bb171e
commit
159e364075
1 changed files with 8 additions and 27 deletions
|
@ -6,13 +6,6 @@
|
||||||
* Please don't remove this comment while sharing this code.
|
* Please don't remove this comment while sharing this code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { curly } = require("node-libcurl");
|
|
||||||
const { toJson } = require("xml2json");
|
|
||||||
|
|
||||||
const YOUTUBE_URL = "https://www.youtube.com/watch?v=";
|
|
||||||
const DISLIKE_API = "https://p.poketube.fun/api?v=";
|
|
||||||
const NEW_API_URL = "https://inner-api.poketube.fun/api/player";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a PokeTube API instance for a specific video.
|
* A class representing a PokeTube API instance for a specific video.
|
||||||
*/
|
*/
|
||||||
|
@ -47,24 +40,13 @@ class PokeTubeAPI {
|
||||||
* @returns {Promise<object|null>} A Promise that resolves with the engagement data, or null if an error occurs.
|
* @returns {Promise<object|null>} A Promise that resolves with the engagement data, or null if an error occurs.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _getEngagementData(videoId) {
|
async _getEngagementData() {
|
||||||
|
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
|
||||||
|
|
||||||
const { fetch } = await import("undici");
|
const { fetch } = await import("undici");
|
||||||
|
|
||||||
const apiUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${videoId}`;
|
const engagement = await fetch(fallbackUrl).then((res) => res.json());
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(apiUrl);
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch data from ${apiUrl}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const engagement = await response.json();
|
|
||||||
return engagement;
|
return engagement;
|
||||||
} catch (error) {
|
|
||||||
console.error(error); // You might want to handle the error more gracefully
|
|
||||||
return null; // Return null or another appropriate value in case of an error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +58,6 @@ class PokeTubeAPI {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
engagement: this.engagement,
|
engagement: this.engagement,
|
||||||
videoUrlYoutube: `${YOUTUBE_URL}${this.videoId}`,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +67,7 @@ class PokeTubeAPI {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_handleError(args) {
|
_handleError(args) {
|
||||||
console.error(`[LIBPT FETCHER ERROR] ${args}`);
|
console.error(`[LIBPT DISLIKES ERROR] ${args}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue