diff --git a/src/parser/youtube/VideoInfo.ts b/src/parser/youtube/VideoInfo.ts index ed917aece..1eba4ce47 100644 --- a/src/parser/youtube/VideoInfo.ts +++ b/src/parser/youtube/VideoInfo.ts @@ -164,7 +164,7 @@ class VideoInfo { this.watch_next_feed = secondary_results.firstOfType(ItemSection)?.contents || secondary_results; - if (this.watch_next_feed && Array.isArray(this.watch_next_feed)) + if (this.watch_next_feed && Array.isArray(this.watch_next_feed) && this.watch_next_feed.at(-1)?.is(ContinuationItem)) this.#watch_next_continuation = this.watch_next_feed.pop()?.as(ContinuationItem); this.player_overlays = next?.player_overlays.item().as(PlayerOverlay); @@ -254,7 +254,11 @@ class VideoInfo { throw new InnertubeError('AppendContinuationItemsAction not found'); this.watch_next_feed = data?.contents; - this.#watch_next_continuation = this.watch_next_feed?.pop()?.as(ContinuationItem); + if (this.watch_next_feed?.at(-1)?.is(ContinuationItem)) { + this.#watch_next_continuation = this.watch_next_feed.pop()?.as(ContinuationItem); + } else { + this.#watch_next_continuation = undefined; + } return this; }