mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-25 19:28:40 +01:00
add engagement thingy
This commit is contained in:
parent
c19a4ea200
commit
49b037b129
1 changed files with 16 additions and 3 deletions
|
@ -17,7 +17,7 @@ const fetch = require("node-fetch"); //2.5.x
|
|||
const { toJson } = require("xml2json");
|
||||
|
||||
const youtubeUrl = "https://www.youtube.com/watch?v=";
|
||||
const dislikeApi = "https://p.poketube.fun/https://returnyoutubedislikeapi.com/votes?videoId=";
|
||||
const dislikeApi = "https://returnyoutubedislikeapi.com/votes?videoId=";
|
||||
const newApiUrl = "https://tube-srv.ashley143.gay/api/player";
|
||||
|
||||
const parseXml = async (videoId, headers) => {
|
||||
|
@ -36,10 +36,23 @@ const getJson = (str) => {
|
|||
};
|
||||
|
||||
const getEngagement = async (videoId) => {
|
||||
const engagement = await fetch(`${dislikeApi}${videoId}`).then((res) => res.json());
|
||||
return engagement;
|
||||
const apiUrl = `${dislikeApi}${videoId}`;
|
||||
const fallbackUrl = `https://p.poketube.fun/${apiUrl}`;
|
||||
|
||||
try {
|
||||
const engagement = await fetch(apiUrl).then((res) => res.json());
|
||||
return engagement;
|
||||
} catch {
|
||||
try {
|
||||
const engagement = await fetch(fallbackUrl).then((res) => res.json());
|
||||
return engagement;
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const getPokeTubeData = async (videoId) => {
|
||||
const headers = {};
|
||||
const videoData = await parseXml(videoId, headers);
|
||||
|
|
Loading…
Reference in a new issue