Files
YouTube.js/lib/parser/contents/classes/MusicShelf.js
LuanRT 8a5073b0b9 refactor: rewrite search suggestions logic (#92)
* refactor: rewrite YouTube Music search suggestions

The search suggestions method can be found under `Innertube#music.getSearchSuggestions(query)`

* feat: allow `execute(..)` to return parsed data

This simplifies how response data is handled and also makes it easier for end users to write custom functionality.

* style: lint code

* chore: change a few things

* refactor: rewrite YouTube search suggestions

* chore(package): build

* chore: update type declarations

* chore: fix tests
2022-07-10 17:30:20 -03:00

29 lines
651 B
JavaScript

'use strict';
const Parser = require('..');
const Text = require('./Text');
const NavigationEndpoint = require('./NavigationEndpoint');
class MusicShelf {
type = 'MusicShelf';
constructor(data) {
this.title = new Text(data.title).toString();
this.contents = Parser.parse(data.contents);
if (data.bottomEndpoint) {
this.endpoint = new NavigationEndpoint(data.bottomEndpoint);
}
if (data.continuations) {
this.continuation = data.continuations?.[0].nextContinuationData.continuation;
}
if (data.bottomText) {
this.bottom_text = new Text(data.bottomText);
}
}
}
module.exports = MusicShelf;