mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-24 04:28:03 +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.
|
||||
*/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -47,24 +40,13 @@ class PokeTubeAPI {
|
|||
* @returns {Promise<object|null>} A Promise that resolves with the engagement data, or null if an error occurs.
|
||||
* @private
|
||||
*/
|
||||
async _getEngagementData(videoId) {
|
||||
const { fetch } = await import("undici");
|
||||
async _getEngagementData() {
|
||||
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
|
||||
|
||||
const { fetch } = await import("undici");
|
||||
|
||||
const apiUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${videoId}`;
|
||||
|
||||
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
|
||||
}
|
||||
const engagement = await fetch(fallbackUrl).then((res) => res.json());
|
||||
return engagement;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,8 +58,7 @@ class PokeTubeAPI {
|
|||
|
||||
return {
|
||||
engagement: this.engagement,
|
||||
videoUrlYoutube: `${YOUTUBE_URL}${this.videoId}`,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +67,7 @@ class PokeTubeAPI {
|
|||
* @private
|
||||
*/
|
||||
_handleError(args) {
|
||||
console.error(`[LIBPT FETCHER ERROR] ${args}`);
|
||||
console.error(`[LIBPT DISLIKES ERROR] ${args}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue