mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 08:58:24 +01:00
add engagement thingy
This commit is contained in:
parent
242cb25620
commit
ec33351990
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