Dislike count added
This commit is contained in:
parent
68f435a658
commit
f5da982b58
@ -55,6 +55,10 @@ interface VideoOptions {
|
||||
* YouTube Video's dislikes
|
||||
*/
|
||||
dislikes: number;
|
||||
/**
|
||||
* YouTube Video's average Rating
|
||||
*/
|
||||
averageRating: number;
|
||||
/**
|
||||
* YouTube Video live status
|
||||
*/
|
||||
@ -124,6 +128,10 @@ export class YouTubeVideo {
|
||||
* YouTube Video's dislikes
|
||||
*/
|
||||
dislikes: number;
|
||||
/**
|
||||
* YouTube Video's average Rating
|
||||
*/
|
||||
averageRating: number;
|
||||
/**
|
||||
* YouTube Video live status
|
||||
*/
|
||||
@ -155,7 +163,8 @@ export class YouTubeVideo {
|
||||
this.thumbnail = new YouTubeThumbnail(data.thumbnail) || {};
|
||||
this.channel = new YouTubeChannel(data.channel) || {};
|
||||
this.likes = data.likes || 0;
|
||||
this.dislikes = data.dislikes || 0;
|
||||
this.averageRating = data.averageRating || 0;
|
||||
this.dislikes = Math.floor((this.likes * (5 - this.averageRating)) / (this.averageRating - 1)) || 0;
|
||||
this.live = !!data.live;
|
||||
this.private = !!data.private;
|
||||
this.tags = data.tags || [];
|
||||
@ -186,6 +195,7 @@ export class YouTubeVideo {
|
||||
tags: this.tags,
|
||||
likes: this.likes,
|
||||
dislikes: this.dislikes,
|
||||
averageRating: this.averageRating,
|
||||
live: this.live,
|
||||
private: this.private
|
||||
};
|
||||
|
||||
@ -156,7 +156,6 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
||||
)?.videoPrimaryInfoRenderer.videoActions.menuRenderer.topLevelButtons ?? [];
|
||||
const video_details = new YouTubeVideo({
|
||||
id: vid.videoId,
|
||||
url: `https://www.youtube.com/watch?v=${vid.videoId}`,
|
||||
title: vid.title,
|
||||
description: vid.shortDescription,
|
||||
duration: Number(vid.lengthSeconds),
|
||||
@ -179,11 +178,6 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
||||
.find((button: any) => button.toggleButtonRenderer.defaultIcon.iconType === 'LIKE')
|
||||
?.toggleButtonRenderer.defaultText.accessibility?.accessibilityData.label.replace(/\D+/g, '') ?? 0
|
||||
),
|
||||
dislikes: parseInt(
|
||||
ratingButtons
|
||||
.find((button: any) => button.toggleButtonRenderer.defaultIcon.iconType === 'DISLIKE')
|
||||
?.toggleButtonRenderer.defaultText.accessibility?.accessibilityData.label.replace(/\D+/g, '') ?? 0
|
||||
),
|
||||
live: vid.isLiveContent,
|
||||
private: vid.isPrivate
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user