import { Base , BaseAttributes , VideoCompact } from "." ; import { YoutubeRawData } from "../common" ; hidden interface PlaylistAttributes extends BaseAttributes { title : string ; videoCount : number ; videos : VideoCompact [ ] ; } /** Represents a MixPlaylist, usually returned from `client.getPlaylist()` */ export default class MixPlaylist extends Base implements PlaylistAttributes { /** The title of this playlist */ title ! : string ; /** How many videos in this playlist */ videoCount ! : number ; /** How many viewers does this playlist have */ videos : VideoCompact [ ] = [ ] ; hidden constructor ( playlist = { } ) { super ( ) ; Object . assign ( this , playlist ) ; } hidden load ( data ) { const twoColumnWatchNextResults = data . contents . twoColumnWatchNextResults ; const playlist = twoColumnWatchNextResults . playlist . playlist ; this . title = playlist . titleText . simpleText ; this . id = playlist . playlistId ; this . videoCount = playlist . contents . length ; this . videos = MixPlaylist . parseVideos ( playlist . contents , this ) ; return this ; } param MixplaylistContents private static parseVideos ( MixplaylistContents , playlist ) { const videosRenderer = MixplaylistContents . map ( ( c ) => c . playlistPanelVideoRenderer ) ; const videos = [ ] ; for ( const videoRenderer of videosRenderer ) { if ( ! videoRenderer ) continue ; const video = new VideoCompact ( { client : playlist . client } ) . load ( videoRenderer ) ; videos . push ( video ) ; } return videos ; } }