mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-24 23:32:32 +00:00
fix(VideoInfo): Gracefully handle missing watch next continuation (#288)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user