Files
YouTube.js/lib/parser/contents/classes/Playlist.js
LuanRT 359020193b dev: start parser refactor on the main codebase, see #65 and #44
Things were getting a bit complicated and slow with the old parser so I decided to continue #44's work on the main codebase.
2022-06-06 04:19:14 -03:00

35 lines
1.0 KiB
JavaScript

'use strict';
const Text = require('./Text');
const Parser = require('..');
const Thumbnail = require('./Thumbnail');
const NavigationEndpoint = require('./NavigationEndpoint');
const PlaylistAuthor = require('./PlaylistAuthor');
class Playlist {
type = 'playlistRenderer';
constructor(data) {
this.id = data.playlistId;
this.title = new Text(data.title);
this.author = data.shortBylineText.simpleText &&
new Text(data.shortBylineText) ||
new PlaylistAuthor({ nav_text: data.shortBylineText, badges: data.ownerBadges });
this.badges = Parser.parse(data.ownerBadges);
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
this.thumbnail = {
thumbnails: new Thumbnail(data.thumbnail).thumbnails,
sampled_thumbnail_color: data.thumbnail?.sampledThumbnailColor
};
this.video_count = new Text(data.thumbnailText);
this.video_count_short_text = new Text(data.videoCountShortText);
this.first_videos = Parser.parse(data.videos);
}
}
module.exports = Playlist;