mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 08:08:54 +00:00
Things were getting a bit complicated and slow with the old parser so I decided to continue #44's work on the main codebase.
35 lines
1.0 KiB
JavaScript
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; |