fix(VideoInfo): Gracefully handle missing watch next continuation (#288)

This commit is contained in:
absidue
2023-01-23 07:36:38 +01:00
committed by GitHub
parent 8051a7dee6
commit 13ad3774c9

View File

@@ -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;
}