feat: add support for captions

This commit is contained in:
LuanRT
2022-06-07 02:52:01 -03:00
parent 5ec2a5512e
commit 4f7de3cc50
5 changed files with 39 additions and 5 deletions

View File

@@ -81,6 +81,11 @@ class VideoInfo {
* @type {import('../parser/contents/classes/Endscreen')}
*/
this.endscreen = info.endscreen;
/**
* @type {import('../parser/contents/classes/PlayerCaptionsTracklist')}
*/
this.captions = info.captions;
/**
* @type {import('../parser/contents/classes/CardCollection')}

View File

@@ -15,8 +15,8 @@ class Author {
this.endpoint = nav_text.runs[0].endpoint;
this.badges = badges || [];
this.is_verified = badges?.some((badge) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED') || false;
this.is_verified_artist = badges?.some((badge) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED_ARTIST') || false;
this.is_verified = badges?.some((badge) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED') || null;
this.is_verified_artist = badges?.some((badge) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED_ARTIST') || null;
}
}

View File

@@ -9,8 +9,8 @@ class CommentsEntryPointHeader {
constructor(data) {
this.header = new Text(data.headerText);
this.comment_count = new Text(data.commentCount);
this.teaser_avatar = new Thumbnail(data.teaserAvatar).thumbnails;
this.teaser_content = new Text(data.teaserContent);
this.teaser_avatar = new Thumbnail(data.teaserAvatar || data.simpleboxAvatar).thumbnails;
this.teaser_content = new Text(data.simpleboxPlaceholder);
}
}

View File

@@ -0,0 +1,29 @@
'use strict';
const Text = require('./Text');
class PlayerCaptionsTracklist {
type = 'playerCaptionsTracklistRenderer'
constructor(data) {
this.caption_tracks = data.captionTracks.map((ct) => ({
base_url: ct.baseUrl,
name: new Text(ct.name),
vss_id: ct.vssId,
language_code: ct.languageCode,
kind: ct.kind,
is_translatable: ct.isTranslatable
}));
this.audio_tracks = data.audioTracks.map((at) => ({
caption_track_indices: at.captionTrackIndices
}));
this.translation_languages = data.translationLanguages.map((tl) => ({
language_code: tl.languageCode,
language_name: new Text(tl.languageName)
}));
}
}
module.exports = PlayerCaptionsTracklist;

View File

@@ -7,7 +7,7 @@ class VideoDetails {
this.id = data.videoId;
this.title = data.title;
this.duration = parseInt(data.lengthSeconds);
this.keywords = data.keywords;
this.keywords = data.keywords || [];
this.channel_id = data.channelId;
this.is_owner_viewing = data.isOwnerViewing;
this.description = data.shortDescription;