mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 16:18:51 +00:00
feat: add support for captions
This commit is contained in:
@@ -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')}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
29
lib/parser/contents/classes/PlayerCaptionsTracklist.js
Normal file
29
lib/parser/contents/classes/PlayerCaptionsTracklist.js
Normal 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;
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user