remove some unneeded stuff :3

This commit is contained in:
Ashley 2023-09-30 05:15:04 +00:00
parent 57d5bb171e
commit 159e364075

View file

@ -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 { fetch } = await import("undici"); const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
const { fetch } = await import("undici");
const apiUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${videoId}`; const engagement = await fetch(fallbackUrl).then((res) => res.json());
return engagement;
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;
} 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,8 +58,7 @@ 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}`);
} }
} }