From d2b3eead415f59156efbf8bf8f1a2632f18b528e Mon Sep 17 00:00:00 2001 From: LuanRT Date: Thu, 23 Jun 2022 03:13:15 -0300 Subject: [PATCH] fix: ItemSection `target_id` not being parsed --- lib/parser/contents/classes/CompactVideo.js | 2 +- lib/parser/contents/classes/ItemSection.js | 6 +++--- lib/parser/contents/classes/MovingThumbnail.js | 2 +- lib/parser/youtube/VideoInfo.js | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/parser/contents/classes/CompactVideo.js b/lib/parser/contents/classes/CompactVideo.js index 04596915..e5e5aa02 100644 --- a/lib/parser/contents/classes/CompactVideo.js +++ b/lib/parser/contents/classes/CompactVideo.js @@ -12,7 +12,7 @@ class CompactVideo { constructor(data) { this.id = data.videoId; - this.thumbnails = Thumbnail.fromResponse(data.thumbnail); + this.thumbnails = Thumbnail.fromResponse(data.thumbnail) || null; this.rich_thumbnail = data.richThumbnail && Parser.parse(data.richThumbnail); this.title = new Text(data.title); this.author = new Author(data.longBylineText, data.ownerBadges, data.channelThumbnail); diff --git a/lib/parser/contents/classes/ItemSection.js b/lib/parser/contents/classes/ItemSection.js index 295474d5..70550ba4 100644 --- a/lib/parser/contents/classes/ItemSection.js +++ b/lib/parser/contents/classes/ItemSection.js @@ -8,9 +8,9 @@ class ItemSection { constructor(data) { this.header = Parser.parse(data.header); this.contents = Parser.parse(data.contents); - - data.targetId || data.sectionIdentifier && - (this.target_id = data.targetId ? data.sectionIdentifier : null); + + (data.targetId || data.sectionIdentifier) && + (this.target_id = data?.target_id || data?.sectionIdentifier); } } diff --git a/lib/parser/contents/classes/MovingThumbnail.js b/lib/parser/contents/classes/MovingThumbnail.js index c9ecd5b4..22834972 100644 --- a/lib/parser/contents/classes/MovingThumbnail.js +++ b/lib/parser/contents/classes/MovingThumbnail.js @@ -6,7 +6,7 @@ class MovingThumbnail { type = 'MovingThumbnail'; constructor(data) { - return data.movingThumbnailDetails.thumbnails.map((thumbnail) => new Thumbnail(thumbnail)).sort((a, b) => b.width - a.width); + return data.movingThumbnailDetails?.thumbnails.map((thumbnail) => new Thumbnail(thumbnail)).sort((a, b) => b.width - a.width); } } diff --git a/lib/parser/youtube/VideoInfo.js b/lib/parser/youtube/VideoInfo.js index 764f156c..de183c8f 100644 --- a/lib/parser/youtube/VideoInfo.js +++ b/lib/parser/youtube/VideoInfo.js @@ -26,7 +26,7 @@ class VideoInfo { this.#actions = actions; this.#player = player; this.#cpn = cpn; - + const info = Parser.parseResponse(data[0]); const next = Parser.parseResponse(data[1].data || {}); @@ -105,7 +105,7 @@ class VideoInfo { */ this.related_chip_cloud = secondary_results?.get({ type: 'RelatedChipCloud' })?.content; - this.watch_next_feed = secondary_results?.get({ target_id: 'watch-next-feed' })?.contents; + this.watch_next_feed = secondary_results?.get({ type: 'ItemSection' })?.contents; this.#watch_next_continuation = this.watch_next_feed?.pop(); /** @@ -116,7 +116,7 @@ class VideoInfo { this.basic_info.like_count = this.primary_info.menu.top_level_buttons.get({ icon_type: 'LIKE' }).like_count; this.basic_info.is_liked = this.primary_info.menu.top_level_buttons.get({ icon_type: 'LIKE' }).is_toggled; this.basic_info.is_disliked = this.primary_info.menu.top_level_buttons.get({ icon_type: 'DISLIKE' }).is_toggled; - + const comments_entry_point = results.get({ target_id: 'comments-entry-point' }); /**