use return youtube dislike API instead
This commit is contained in:
parent
4bb425429d
commit
e24a87d3e1
@ -39,7 +39,7 @@
|
||||
},
|
||||
{
|
||||
"name": "urlreply",
|
||||
"version": "1.0.3"
|
||||
"version": "1.0.5"
|
||||
},
|
||||
{
|
||||
"name": "utility",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"main": "plugin.js",
|
||||
"name": "urlreply",
|
||||
"description": "Fetch titles from web pages, specifically made for IRC",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"tags": ["irc"],
|
||||
"dependencies": [],
|
||||
"npmDependencies": ["cheerio@^1.0.0-rc.10"]
|
||||
|
@ -142,6 +142,14 @@ async function getYoutubeFromVideo(
|
||||
return false;
|
||||
}
|
||||
|
||||
const dislikeAPI = `https://returnyoutubedislikeapi.com/votes?videoId=${id}`;
|
||||
let dislikeData = await httpGET(dislikeAPI);
|
||||
try {
|
||||
dislikeData = JSON.parse(dislikeData);
|
||||
} catch (e) {
|
||||
dislikeData = null;
|
||||
}
|
||||
|
||||
const vid = data.items[0];
|
||||
const time = full.searchParams.get('t');
|
||||
let live = false;
|
||||
@ -176,12 +184,25 @@ async function getYoutubeFromVideo(
|
||||
keys.push(['field', ytDuration(vid.contentDetails.duration.toString()), { label: 'Duration' }]);
|
||||
}
|
||||
|
||||
let likeCount: number | null = null;
|
||||
let dislikeCount: number | null = null;
|
||||
if (vid.statistics && vid.statistics.likeCount != null) {
|
||||
const likeCount = vid.statistics.likeCount.toString();
|
||||
// const dislikeCount = vid.statistics.dislikeCount.toString();
|
||||
likeCount = vid.statistics.likeCount;
|
||||
}
|
||||
|
||||
if (dislikeData) {
|
||||
dislikeCount = dislikeData.dislikes;
|
||||
if (likeCount === null) {
|
||||
likeCount = dislikeData.likes;
|
||||
}
|
||||
}
|
||||
|
||||
if (likeCount !== null) {
|
||||
keys.push(['field', likeCount, { color: 'limegreen', label: ['▲', 'Likes'], type: 'metric' }]);
|
||||
// keys.push(['field', dislikeCount, { color: 'red', label: ['▼', 'Dislikes'], type: 'metric' }]);
|
||||
}
|
||||
|
||||
if (dislikeCount !== null) {
|
||||
keys.push(['field', dislikeCount, { color: 'red', label: ['▼', 'Dislikes'], type: 'metric' }]);
|
||||
}
|
||||
|
||||
keys.push(['field', vid.snippet.channelTitle, { label: ['By'] }]);
|
||||
|
Loading…
Reference in New Issue
Block a user