From 0fa5a859ae15a35266297079e3e34fd9f3a5ebf4 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sun, 30 Jul 2023 20:59:39 +0200 Subject: [PATCH] feat(YouTube Playlist): Add subtitle and fix author optionality (#458) --- src/parser/classes/PlaylistHeader.ts | 6 ++++-- src/parser/youtube/Playlist.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/parser/classes/PlaylistHeader.ts b/src/parser/classes/PlaylistHeader.ts index 9c8a07119..b228d38a8 100644 --- a/src/parser/classes/PlaylistHeader.ts +++ b/src/parser/classes/PlaylistHeader.ts @@ -8,9 +8,10 @@ export default class PlaylistHeader extends YTNode { id: string; title: Text; + subtitle: Text | null; stats: Text[]; brief_stats: Text[]; - author: Author; + author: Author | null; description: Text; num_videos: Text; view_count: Text; @@ -27,9 +28,10 @@ export default class PlaylistHeader extends YTNode { super(); this.id = data.playlistId; this.title = new Text(data.title); + this.subtitle = data.subtitle ? new Text(data.subtitle) : null; this.stats = data.stats.map((stat: RawNode) => new Text(stat)); this.brief_stats = data.briefStats.map((stat: RawNode) => new Text(stat)); - this.author = new Author({ ...data.ownerText, navigationEndpoint: data.ownerEndpoint }, data.ownerBadges, null); + this.author = data.ownerText || data.ownerEndpoint ? new Author({ ...data.ownerText, navigationEndpoint: data.ownerEndpoint }, data.ownerBadges, null) : null; this.description = new Text(data.descriptionText); this.num_videos = new Text(data.numVideosText); this.view_count = new Text(data.viewCountText); diff --git a/src/parser/youtube/Playlist.ts b/src/parser/youtube/Playlist.ts index c6838e0b5..111a6db50 100644 --- a/src/parser/youtube/Playlist.ts +++ b/src/parser/youtube/Playlist.ts @@ -36,6 +36,7 @@ class Playlist extends Feed { this.info = { ...this.page.metadata?.item().as(PlaylistMetadata), ...{ + subtitle: header.subtitle, author: secondary_info?.owner?.as(VideoOwner).author ?? header?.author, thumbnails: primary_info?.thumbnail_renderer?.as(PlaylistVideoThumbnail, PlaylistCustomThumbnail).thumbnail as Thumbnail[], total_items: this.#getStat(0, primary_info),