mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-18 20:12:12 +00:00
- Finished Library parser - Fixed search continuations - Improved channel parser - Improved playlist parser - Added support for posts of type poll - Improved History parser - Removed redundant code
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
'use strict'
|
|
|
|
const Feed = require('../../core/Feed');
|
|
|
|
class Playlist extends Feed {
|
|
constructor(actions, data, already_parsed = false) {
|
|
super(actions, data, already_parsed);
|
|
|
|
const primary_info = this.page.sidebar.contents.get({ type: 'PlaylistSidebarPrimaryInfo' });
|
|
const secondary_info = this.page.sidebar.contents.get({ type: 'PlaylistSidebarSecondaryInfo' });
|
|
|
|
this.info = {
|
|
...this.page.metadata,
|
|
...{
|
|
author: secondary_info.owner.author,
|
|
thumbnails: primary_info.thumbnail_renderer.thumbnail,
|
|
total_items: this.#getStat(0, primary_info),
|
|
views: this.#getStat(1, primary_info),
|
|
last_updated: this.#getStat(2, primary_info)
|
|
}
|
|
}
|
|
|
|
this.menu = primary_info.menu;
|
|
this.endpoint = primary_info.endpoint;
|
|
}
|
|
|
|
#getStat(index, primary_info) {
|
|
if (!primary_info || !primary_info.stats) return 'N/A';
|
|
return primary_info.stats[index]?.toString() || 'N/A';
|
|
}
|
|
|
|
/**
|
|
* @alias videos
|
|
*/
|
|
get items() {
|
|
return this.videos;
|
|
}
|
|
}
|
|
|
|
module.exports = Playlist; |