Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: "Unable to find 'menu' using path #587

Closed
ClintGreen5150 opened this issue May 23, 2024 · 3 comments · Fixed by #590
Closed

KeyError: "Unable to find 'menu' using path #587

ClintGreen5150 opened this issue May 23, 2024 · 3 comments · Fixed by #590
Labels
bug Something isn't working

Comments

@ClintGreen5150
Copy link

I am very new to this so I apologize if I'm doing this wrong...

I'm trying to create playlists of a few thousand tracks but I keep hitting this keyerror. It's completely intermittent, occurs on a different track each time. I am using the search function to find an album, grabbing the albumID and using that to browse to the album, then selecting a random track and using its ID to add it to the playlist. This seems to happen around the 200 track mark but it has also happened after adding about 80 tracks in this manner.

I've tried batching the artist/album data to chunks of 100 but the issue persists.

To Reproduce
Steps to reproduce the behavior:
I really am not sure unfortunately, it is intermittent, it just happens on a random track when trying to add to a playlist.

Additional context
Using the latest version, 1.7.2

@sigma67
Copy link
Owner

sigma67 commented May 23, 2024

Hi, thanks for the report.

Please provide the full stack trace and error message, including the search term you used.

@ClintGreen5150
Copy link
Author

I hope this is correct and what you are looking for - I am still learning code, 2 months in :)

Search results for blackened entrails - manifesto sepulcral:
[{'title': 'manifesto sepulcral', 'artist': 'blackened entrails', 'browseId': 'MPREb_RME6sh1SHeK', 'resultType': 'album'}]
Traceback (most recent call last):
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\navigation.py", line 106, in nav
root = root[k]
~~~~^^^
KeyError: 'menu'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator\YT_playlist_gen.py", line 127, in
search_results = yt.search(search_query)
^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\mixins\search.py", line 236, in search
parse_search_results(shelf_contents, search_result_types, result_type, category)
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\parsers\search.py", line 178, in parse_search_results
parse_search_result(result[MRLIR], search_result_types, resultType, category) for result in results
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\parsers\search.py", line 91, in parse_search_result
parse_menu_playlists(data, search_result)
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\parsers_utils.py", line 7, in parse_menu_playlists
watch_menu = find_objects_by_key(nav(data, MENU_ITEMS), MNIR)
^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\User\PycharmProjects\YT-Music-Playlist-Generator.conda\Lib\site-packages\ytmusicapi\navigation.py", line 110, in nav
raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
KeyError: "Unable to find 'menu' using path ['menu', 'menuRenderer', 'items'] on {'trackingParams': 'CBAQyfQCGAAiEwi9rbHTwqSGAxWJyEkHHdMEDDM=', 'thumbnail': {'musicThumbnailRenderer': {'thumbnail':
{}, 'thumbnailCrop': 'MUSIC_THUMBNAIL_CROP_CIRCLE', 'thumbnailScale': 'MUSIC_THUMBNAIL_SCALE_ASPECT_FILL', 'trackingParams': 'CBEQhL8CIhMIva2x08KkhgMVichJBx3TBAwz'}}, 'flexColumns': [{'musicResponsiveListItemFlexColumnRenderer': {'text': {'runs': [{'text': 'Jianxin Li'}]}, 'displayPriority': 'MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH'}}, {'musicResponsiveListItemFlexColumnRenderer': {'text': {'runs': [{'text': 'Profile'}]}, 'displayPriority': 'MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH'}}], 'flexColumnDisplayStyle': 'MUSIC_RESPONSIVE_LIST_ITEM_FLEX_COLUMN_DISPLAY_STYLE_TWO_LINE_STACK', 'navigationEndpoint': {'clickTrackingParams': 'CBAQyfQCGAAiEwi9rbHTwqSGAxWJyEkHHdMEDDM=', 'browseEndpoint': {'browseId': 'UC_usPjyxDU93yOVnY32_b_Q', 'browseEndpointContextSupportedConfigs': {'browseEndpointContextMusicConfig': {'pageType': 'MUSIC_PAGE_TYPE_UNKNOWN'}}}}, 'itemHeight': 'MUSIC_RESPONSIVE_LIST_ITEM_HEIGHT_TALL'}, exception: 'menu'"

@sigma67
Copy link
Owner

sigma67 commented May 25, 2024

@ClintGreen5150 please check if the linked PR fixes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants