Files
YouTube.js/lib/parser/ytmusic/HomeFeed.js
LuanRT 68cb841c00 refactor!: finish parser migration
Finally! :)

This removes all code related to the old parser.

#65
2022-07-11 06:19:10 -03:00

42 lines
1.0 KiB
JavaScript

'use strict';
const Parser = require('..');
/** @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('../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);
}
get page() {
return this.#page;
}
}
module.exports = HomeFeed;