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
This commit is contained in:
LuanRT
2022-07-10 17:30:20 -03:00
committed by GitHub
parent 0356dafa96
commit 8a5073b0b9
26 changed files with 196 additions and 77 deletions

View File

@@ -29,13 +29,13 @@ describe('YouTube.js Tests', () => {
});
it('Should retrieve YouTube search suggestions', async () => {
const suggestions = await this.session.getSearchSuggestions(Constants.VIDEOS[0].QUERY, { client: 'YOUTUBE' });
expect(suggestions.results.length).toBeLessThanOrEqual(10);
const suggestions = await this.session.getSearchSuggestions(Constants.VIDEOS[0].QUERY);
expect(suggestions.length).toBeLessThanOrEqual(10);
});
it('Should retrieve YouTube Music search suggestions', async () => {
const suggestions = await this.session.getSearchSuggestions(Constants.VIDEOS[1].QUERY, { client: 'YTMUSIC' });
expect(suggestions.results.length).toBeLessThanOrEqual(10);
const suggestions = await this.session.music.getSearchSuggestions(Constants.VIDEOS[1].QUERY);
expect(suggestions.length).toBeLessThanOrEqual(10);
});
});