Files
YouTube.js/lib/parser/ytmusic/HomeFeed.js
LuanRT 1d62e469a9 refactor: rewrite Comments Section logic (#88)
* feat: add core comments section classes

* chore: update type declarations

* chore: fix linter warnings

* style: fix linter

* chore: update tests

* chore(tests): fix typo

* chore(tests): fix typo x2

* fix(tests): `getReplies()` method is only present in `CommentThread` and not `Comment`

* chore(tests): fix comment id path

* chore(tests): remove outdated code

* chore(tests): fix results path

* chore: enforce code style

* chore: update type declarations

* docs: add examples and documentation

* chore(docs): fix paths

* chore(docs): fix more paths

* chore(docs): fix `Comments.js` path

* chore(docs): fix typo

* chore(docs): mention example file

* chore(examples): fix imports

* chore(examples): fix typo
2022-07-02 19:55:33 -03:00

38 lines
999 B
JavaScript

'use strict';
const Parser = require('../contents');
/** @namespace */
class HomeFeed {
#page;
#actions;
#continuation;
/**
* @param {object} response - API response.
* @param {import('../../core/Actions')} actions
*/
constructor(response, actions) {
this.#actions = actions;
this.#page = Parser.parseResponse(response.data);
const tab = this.#page.contents.tabs.get({ title: 'Home' });
this.#continuation = tab.content?.continuation || this.#page.continuation_contents.continuation;
/** @type {import('../contents/classes/MusicCarouselShelf')[]} */
this.sections = tab.content?.contents || this.#page.continuation_contents.contents;
}
/**
* Retrieves home feed continuation.
*
* @returns {Promise.<HomeFeed>}
*/
async getContinuation() {
const response = await this.#actions.browse(this.#continuation, { is_ctoken: true, client: 'YTMUSIC' });
return new HomeFeed(response, this.#actions);
}
}
module.exports = HomeFeed;