Skip to content

Commit

Permalink
feat(music#getSearchSuggestions)!: Return array of `SearchSuggestions…
Browse files Browse the repository at this point in the history
…Section` instead of a single node
  • Loading branch information
LuanRT committed Oct 28, 2023
1 parent a45273f commit beaa28f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/clients/Music.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SectionList from '../../parser/classes/SectionList.js';
import Tab from '../../parser/classes/Tab.js';
import * as Proto from '../../proto/index.js';

import type { ObservedArray, YTNode } from '../../parser/helpers.js';
import type { ObservedArray } from '../../parser/helpers.js';
import type { MusicSearchFilters } from '../../types/index.js';
import { InnertubeError, generateRandomString, throwIfMissing } from '../../utils/Utils.js';
import type Actions from '../Actions.js';
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class Music {

const player_response = this.#actions.execute(PlayerEndpoint.PATH, player_payload);
const next_response = this.#actions.execute(NextEndpoint.PATH, next_payload);
const response = await Promise.all([ player_response, next_response ]);
const response = await Promise.all([player_response, next_response]);

Check failure on line 75 in src/core/clients/Music.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required after '['

Check failure on line 75 in src/core/clients/Music.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required before ']'

const cpn = generateRandomString(16);

Expand Down Expand Up @@ -105,7 +105,7 @@ export default class Music {

const cpn = generateRandomString(16);

const response = await Promise.all([ player_response, next_response ]);
const response = await Promise.all([player_response, next_response]);

Check failure on line 108 in src/core/clients/Music.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required after '['

Check failure on line 108 in src/core/clients/Music.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required before ']'
return new TrackInfo(response, this.#actions, cpn);
}

Expand Down Expand Up @@ -355,17 +355,17 @@ export default class Music {
* Retrieves search suggestions for the given query.
* @param query - The query.
*/
async getSearchSuggestions(query: string): Promise<ObservedArray<YTNode>> {
async getSearchSuggestions(query: string): Promise<ObservedArray<SearchSuggestionsSection>> {
const response = await this.#actions.execute(
GetSearchSuggestionsEndpoint.PATH,
{ ...GetSearchSuggestionsEndpoint.build({ input: query }), parse: true }
);

if (!response.contents_memo)
throw new InnertubeError('Unexpected response', response);
return [] as unknown as ObservedArray<SearchSuggestionsSection>;

const search_suggestions_section = response.contents_memo.getType(SearchSuggestionsSection).first();
const search_suggestions_sections = response.contents_memo.getType(SearchSuggestionsSection);

return search_suggestions_section.contents;
return search_suggestions_sections;
}
}

0 comments on commit beaa28f

Please sign in to comment.