feat: add support for retrieving watch next feed continuation

This commit is contained in:
LuanRT
2022-06-10 03:57:05 -03:00
parent 1676b11b0e
commit 9840acc63d

View File

@@ -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.<CompactVideo[]>}
*/
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);