mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-18 20:12:12 +00:00
* feat: add core comments section classes * chore: update type declarations * chore: fix linter warnings * style: fix linter * chore: update tests * chore(tests): fix typo * chore(tests): fix typo x2 * fix(tests): `getReplies()` method is only present in `CommentThread` and not `Comment` * chore(tests): fix comment id path * chore(tests): remove outdated code * chore(tests): fix results path * chore: enforce code style * chore: update type declarations * docs: add examples and documentation * chore(docs): fix paths * chore(docs): fix more paths * chore(docs): fix `Comments.js` path * chore(docs): fix typo * chore(docs): mention example file * chore(examples): fix imports * chore(examples): fix typo
44 lines
1.2 KiB
JavaScript
44 lines
1.2 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),
|
|
can_share: this.page.header.can_share,
|
|
can_delete: this.page.header.can_delete,
|
|
is_editable: this.page.header.is_editable,
|
|
privacy: this.page.header.privacy
|
|
}
|
|
};
|
|
|
|
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; |