Added thumbnails array in youtube video
This commit is contained in:
parent
4492f8441f
commit
0b424062c9
@ -115,7 +115,7 @@ export class YouTubeVideo {
|
|||||||
/**
|
/**
|
||||||
* YouTube Thumbnail Data
|
* YouTube Thumbnail Data
|
||||||
*/
|
*/
|
||||||
thumbnail?: YouTubeThumbnail;
|
thumbnails: YouTubeThumbnail[];
|
||||||
/**
|
/**
|
||||||
* YouTube Video's uploader Channel Data
|
* YouTube Video's uploader Channel Data
|
||||||
*/
|
*/
|
||||||
@ -160,7 +160,11 @@ export class YouTubeVideo {
|
|||||||
this.durationInSec = (data.duration < 0 ? 0 : data.duration) || 0;
|
this.durationInSec = (data.duration < 0 ? 0 : data.duration) || 0;
|
||||||
this.uploadedAt = data.uploadedAt || undefined;
|
this.uploadedAt = data.uploadedAt || undefined;
|
||||||
this.views = parseInt(data.views) || 0;
|
this.views = parseInt(data.views) || 0;
|
||||||
this.thumbnail = new YouTubeThumbnail(data.thumbnail) || {};
|
const thumbnails = [];
|
||||||
|
for (const thumb of data.thumbnails) {
|
||||||
|
thumbnails.push(new YouTubeThumbnail(thumb));
|
||||||
|
}
|
||||||
|
this.thumbnails = thumbnails || [];
|
||||||
this.channel = new YouTubeChannel(data.channel) || {};
|
this.channel = new YouTubeChannel(data.channel) || {};
|
||||||
this.likes = data.likes || 0;
|
this.likes = data.likes || 0;
|
||||||
this.averageRating = data.averageRating || 0;
|
this.averageRating = data.averageRating || 0;
|
||||||
@ -189,7 +193,7 @@ export class YouTubeVideo {
|
|||||||
durationInSec: this.durationInSec,
|
durationInSec: this.durationInSec,
|
||||||
durationRaw: this.durationRaw,
|
durationRaw: this.durationRaw,
|
||||||
uploadedAt: this.uploadedAt,
|
uploadedAt: this.uploadedAt,
|
||||||
thumbnail: this.thumbnail?.toJSON() || this.thumbnail,
|
thumbnail: this.thumbnails[this.thumbnails.length - 1].toJSON() || this.thumbnails,
|
||||||
channel: this.channel,
|
channel: this.channel,
|
||||||
views: this.views,
|
views: this.views,
|
||||||
tags: this.tags,
|
tags: this.tags,
|
||||||
|
|||||||
@ -161,7 +161,7 @@ export async function video_basic_info(url: string, options: InfoOptions = {}):
|
|||||||
duration: Number(vid.lengthSeconds),
|
duration: Number(vid.lengthSeconds),
|
||||||
duration_raw: parseSeconds(Number(vid.lengthSeconds)),
|
duration_raw: parseSeconds(Number(vid.lengthSeconds)),
|
||||||
uploadedAt: microformat.publishDate,
|
uploadedAt: microformat.publishDate,
|
||||||
thumbnail: vid.thumbnail.thumbnails[vid.thumbnail.thumbnails.length - 1],
|
thumbnails: vid.thumbnail.thumbnails,
|
||||||
channel: {
|
channel: {
|
||||||
name: vid.author,
|
name: vid.author,
|
||||||
id: vid.channelId,
|
id: vid.channelId,
|
||||||
|
|||||||
@ -130,7 +130,7 @@ export function parseVideo(data?: any): YouTubeVideo {
|
|||||||
: '',
|
: '',
|
||||||
duration: data.videoRenderer.lengthText ? parseDuration(data.videoRenderer.lengthText.simpleText) : 0,
|
duration: data.videoRenderer.lengthText ? parseDuration(data.videoRenderer.lengthText.simpleText) : 0,
|
||||||
duration_raw: data.videoRenderer.lengthText ? data.videoRenderer.lengthText.simpleText : null,
|
duration_raw: data.videoRenderer.lengthText ? data.videoRenderer.lengthText.simpleText : null,
|
||||||
thumbnail: data.videoRenderer.thumbnail.thumbnails[data.videoRenderer.thumbnail.thumbnails.length - 1],
|
thumbnails: data.videoRenderer.thumbnail.thumbnails,
|
||||||
channel: {
|
channel: {
|
||||||
id: channel.navigationEndpoint.browseEndpoint.browseId || null,
|
id: channel.navigationEndpoint.browseEndpoint.browseId || null,
|
||||||
name: channel.text || null,
|
name: channel.text || null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user