mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-30 18:06:15 +00:00
chore: add jsdoc comments to selectFilter method
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Parser = require('../contents');
|
||||
const { InnertubeError } = require('../../utils/Utils');
|
||||
const { InnertubeError, observe } = require('../../utils/Utils');
|
||||
|
||||
/** namespace **/
|
||||
class VideoInfo {
|
||||
@@ -116,15 +116,31 @@ class VideoInfo {
|
||||
this.comments_entry_point_header = comments_entry_point?.contents.get({ type: 'commentsEntryPointHeaderRenderer' }) || {};
|
||||
}
|
||||
|
||||
async selectFilter(chip) {
|
||||
const response = await chip.endpoint.call(this.#actions);
|
||||
|
||||
/**
|
||||
* Applies given filter to the watch next feed.
|
||||
* @param {string} filter
|
||||
* @returns {Promise.<VideoInfo>}
|
||||
*/
|
||||
async selectFilter(name) {
|
||||
if (!this.filters.includes(name))
|
||||
throw new InnertubeError('Invalid filter', { available_filters: this.filters });
|
||||
|
||||
const filter = this.related_chip_cloud.chips.get({ text: name });
|
||||
if (filter.is_selected) return this;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/** @type {string} */
|
||||
get filters() {
|
||||
return this.related_chip_cloud.chips.map((chip) => chip.text);
|
||||
}
|
||||
|
||||
get page() {
|
||||
return this.#page;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user