From 9840acc63d8ac6ed2afb4c6ce6fb2609cea985fe Mon Sep 17 00:00:00 2001 From: LuanRT Date: Fri, 10 Jun 2022 03:57:05 -0300 Subject: [PATCH] feat: add support for retrieving watch next feed continuation --- lib/parser/youtube/VideoInfo.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/parser/youtube/VideoInfo.js b/lib/parser/youtube/VideoInfo.js index f7077e06..b48df9de 100644 --- a/lib/parser/youtube/VideoInfo.js +++ b/lib/parser/youtube/VideoInfo.js @@ -9,6 +9,8 @@ class VideoInfo { #actions; #player; + #watch_next_continuation; + /** * @param {object} data - API response. * @param {import('../../core/Actions')} actions @@ -69,7 +71,7 @@ class VideoInfo { this.related_chip_cloud = secondary_results?.get({ type: 'relatedChipCloudRenderer' }).content; this.watch_next_feed = secondary_results?.get({ target_id: 'watch-next-feed' }).contents; - this.watch_next_feed?.pop(); // get rid of the continuation item as it is of no use (for now). + this.#watch_next_continuation = this.watch_next_feed?.pop(); /** * @type {import('../contents/classes/PlayerOverlay')} @@ -130,12 +132,26 @@ class VideoInfo { const response = await filter.endpoint.call(this.#actions); const data = response.on_response_received_endpoints.get({ target_id: 'watch-next-feed' }); - + this.watch_next_feed = data.continuation_items; return this; } + /** + * Retrieves watch next feed continuation. + * @returns {Promise.} + */ + async getWatchNextContinuation() { + const response = await this.#watch_next_continuation.endpoint.call(this.#actions); + const data = response.on_response_received_endpoints.get({ type: 'appendContinuationItemsAction' }); + + this.watch_next_feed = data.continuation_items; + this.#watch_next_continuation = this.watch_next_feed.pop(); + + return this.watch_next_feed; + } + /** @type {string} */ get filters() { return this.related_chip_cloud.chips.map((chip) => chip.text);