Skip to content

Commit

Permalink
feat(YouTube Playlist): Add subtitle and fix author optionality (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored Jul 30, 2023
1 parent 02a1112 commit 0fa5a85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/parser/classes/PlaylistHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/parser/youtube/Playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Playlist extends Feed<IBrowseResponse> {
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),
Expand Down

0 comments on commit 0fa5a85

Please sign in to comment.