[GH-ISSUE #472] Get_search_suggestions KeyError: 'searchSuggestionRenderer' #350

Closed
opened 2026-02-27 23:00:19 +03:00 by kerem · 1 comment
Owner

Originally created by @nick42d on GitHub (Nov 16, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/472

Describe the bug
Google seems to have added history type suggestions to the search suggestions (example below from the app) at some point. These are under a different key to regular search suggestions so the current implementation will fail if history exists (example below of the JSON structure).
image
image

Proposal:
get_search_suggestions revised to:

  1. look at historySuggestionRenderer if searchSuggestionRenderers not in the list of contents.
  2. return suggestion type as well as the suggestions themselves.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a new Oauth session
  2. Run get_search_suggestions twice in a row (first time adds it to your history).
  3. KeyError: 'searchSuggestionRenderer'

Additional notes
From the screenshot, seems there is also a way to delete search history suggestions, this could be a future enhancement

Originally created by @nick42d on GitHub (Nov 16, 2023). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/472 **Describe the bug** Google seems to have added history type suggestions to the search suggestions (example below from the app) at some point. These are under a different key to regular search suggestions so the current implementation will fail if history exists (example below of the JSON structure). ![image](https://github.com/sigma67/ytmusicapi/assets/133559267/8da6618d-2a72-4075-86ad-8f22b0e1bd07) ![image](https://github.com/sigma67/ytmusicapi/assets/133559267/078d458a-126b-4696-a531-e4e68828471d) Proposal: get_search_suggestions revised to: 1. look at historySuggestionRenderer if searchSuggestionRenderers not in the list of contents. 2. return suggestion type as well as the suggestions themselves. **To Reproduce** Steps to reproduce the behavior: 1. Setup a new Oauth session 2. Run get_search_suggestions twice in a row (first time adds it to your history). 4. KeyError: 'searchSuggestionRenderer' **Additional notes** From the screenshot, seems there is also a way to delete search history suggestions, this could be a future enhancement
kerem 2026-02-27 23:00:19 +03:00
  • closed this issue
  • added the
    yt-update
    label
Author
Owner

@sigma67 commented on GitHub (Jan 6, 2024):

was addressed in #495

the future enhancement to delete search suggestions is tracked in #497

<!-- gh-comment-id:1879801944 --> @sigma67 commented on GitHub (Jan 6, 2024): was addressed in #495 the future enhancement to delete search suggestions is tracked in #497
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#350
No description provided.