[GH-ISSUE #127] KeyError from "search()", missing navigationEndpoint in album result #93

Closed
opened 2026-02-27 22:07:58 +03:00 by kerem · 1 comment
Owner

Originally created by @wsidl on GitHub (Dec 17, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/127

Description

Running a search for track titles also returns album and artist results. "KeyError" is raised before the search function finishes.

Expected behaviour

results = yt.search("That's My Jam Skindred That's My Jam")
# parse results

Current behaviour

results = yt.search("That's My Jam Skindred That's My Jam")
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 167, in nav
    raise err
  File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 161, in nav
    root = root[k]
KeyError: 'navigationEndpoint'

Stack Trace:

  File "/scratch.py", line 110, in find
    results = YT.search(search_term)
  File "/usr/lib/python3.8/site-packages/ytmusicapi/mixins/browsing.py", line 119, in search
    search_results.extend(self.parser.parse_search_results(results, type))
  File "/usr/lib/python3.8/site-packages/ytmusicapi/helpers.py", line 78, in _impl
    return method(self, *method_args, **method_kwargs)
  File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/browsing.py", line 36, in parse_search_results
    search_result['browseId'] = nav(data, NAVIGATION_BROWSE_ID)
  File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 167, in nav
    raise err
  File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 161, in nav
    root = root[k]
KeyError: 'navigationEndpoint'

Additional Points

It does successfully parse many results, but gets stuck on an album entry.

nav(root, items, none_if_absent)
none_if_absent = False
items = ['navigationEndpoint', 'browseEndpoint', 'browseId']
root = {
	"trackingParams": "CLcBENjyAxgAIhMInoX5jfPV7QIV1YDECh09kgSk",
	"thumbnail": {
		"musicThumbnailRenderer": {
			"thumbnail": {
				"thumbnails": [
					{"url": "https://lh3.googleusercontent.com/FRFyrsX2NYZqwQmazxCOIx6rCW-KvLMSNlB0SJ0Nm39pGNeDiE1h3Koka9FPALCXwE7-ArSd1lIFfQrv=w60-h60-l90-rj", "width": 60, "height": 60},
					{"url": "https://lh3.googleusercontent.com/FRFyrsX2NYZqwQmazxCOIx6rCW-KvLMSNlB0SJ0Nm39pGNeDiE1h3Koka9FPALCXwE7-ArSd1lIFfQrv=w120-h120-l90-rj", "width": 120, "height": 120}
				]
			},
			"thumbnailCrop": "MUSIC_THUMBNAIL_CROP_UNSPECIFIED",
			"thumbnailScale": "MUSIC_THUMBNAIL_SCALE_ASPECT_FIT",
			"trackingParams": "CLkBEIS_AiITCJ6F-Y3z1e0CFdWAxAodPZIEpA=="
		}
	},
	"overlay": {
		"musicItemThumbnailOverlayRenderer": {
			"background": {
				"verticalGradient": {
					"gradientLayerColors": ["3422552064", "3422552064"]
				}
			},
			"content": {
				"musicPlayButtonRenderer": {
					"trackingParams": "CLgBEMjeAiITCJ6F-Y3z1e0CFdWAxAodPZIEpA==",
					"playIcon": {"iconType": "PLAY_ARROW"},
					"pauseIcon": {"iconType": "PAUSE"},
					"iconColor": 4294967295,
					"backgroundColor": 0,
					"activeBackgroundColor": 0,
					"loadingIndicatorColor": 4294901760,
					"playingIcon": {"iconType": "VOLUME_UP"},
					"iconLoadingColor": 0,
					"activeScaleFactor": 1,
					"buttonSize": "MUSIC_PLAY_BUTTON_SIZE_SMALL",
					"rippleTarget": "MUSIC_PLAY_BUTTON_RIPPLE_TARGET_SELF"
				}
			},
			"contentPosition": "MUSIC_ITEM_THUMBNAIL_OVERLAY_CONTENT_POSITION_CENTERED",
			"displayStyle": "MUSIC_ITEM_THUMBNAIL_OVERLAY_DISPLAY_STYLE_PERSISTENT"
		}
	},
	"flexColumns": [
		{
			"musicResponsiveListItemFlexColumnRenderer": {
				"text": {"runs": [{"text": "That's My Jam"}]},
				"displayPriority": "MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH"
			}
		},
		{
			"musicResponsiveListItemFlexColumnRenderer": {
				"text": {
					"runs": [
						{"text": "Skindred"},
						{"text": " • "},
						{"text": "3:17"}
					]
				},
				"displayPriority": "MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH"
			}
		}
	],
	"flexColumnDisplayStyle": "MUSIC_RESPONSIVE_LIST_ITEM_FLEX_COLUMN_DISPLAY_STYLE_TWO_LINE_STACK",
	"itemHeight": "MUSIC_RESPONSIVE_LIST_ITEM_HEIGHT_TALL",
	"musicItemRendererDisplayPolicy": "MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT"
}

_version.py

__version__ = "0.12.1"
Originally created by @wsidl on GitHub (Dec 17, 2020). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/127 ## Description Running a search for track titles also returns album and artist results. "KeyError" is raised before the search function finishes. ## Expected behaviour ```python results = yt.search("That's My Jam Skindred That's My Jam") # parse results ``` ## Current behaviour ```python results = yt.search("That's My Jam Skindred That's My Jam") Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 167, in nav raise err File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 161, in nav root = root[k] KeyError: 'navigationEndpoint' ``` Stack Trace: ``` File "/scratch.py", line 110, in find results = YT.search(search_term) File "/usr/lib/python3.8/site-packages/ytmusicapi/mixins/browsing.py", line 119, in search search_results.extend(self.parser.parse_search_results(results, type)) File "/usr/lib/python3.8/site-packages/ytmusicapi/helpers.py", line 78, in _impl return method(self, *method_args, **method_kwargs) File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/browsing.py", line 36, in parse_search_results search_result['browseId'] = nav(data, NAVIGATION_BROWSE_ID) File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 167, in nav raise err File "/usr/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 161, in nav root = root[k] KeyError: 'navigationEndpoint' ``` ## Additional Points It does successfully parse many results, but gets stuck on an album entry. ``` nav(root, items, none_if_absent) none_if_absent = False items = ['navigationEndpoint', 'browseEndpoint', 'browseId'] root = { "trackingParams": "CLcBENjyAxgAIhMInoX5jfPV7QIV1YDECh09kgSk", "thumbnail": { "musicThumbnailRenderer": { "thumbnail": { "thumbnails": [ {"url": "https://lh3.googleusercontent.com/FRFyrsX2NYZqwQmazxCOIx6rCW-KvLMSNlB0SJ0Nm39pGNeDiE1h3Koka9FPALCXwE7-ArSd1lIFfQrv=w60-h60-l90-rj", "width": 60, "height": 60}, {"url": "https://lh3.googleusercontent.com/FRFyrsX2NYZqwQmazxCOIx6rCW-KvLMSNlB0SJ0Nm39pGNeDiE1h3Koka9FPALCXwE7-ArSd1lIFfQrv=w120-h120-l90-rj", "width": 120, "height": 120} ] }, "thumbnailCrop": "MUSIC_THUMBNAIL_CROP_UNSPECIFIED", "thumbnailScale": "MUSIC_THUMBNAIL_SCALE_ASPECT_FIT", "trackingParams": "CLkBEIS_AiITCJ6F-Y3z1e0CFdWAxAodPZIEpA==" } }, "overlay": { "musicItemThumbnailOverlayRenderer": { "background": { "verticalGradient": { "gradientLayerColors": ["3422552064", "3422552064"] } }, "content": { "musicPlayButtonRenderer": { "trackingParams": "CLgBEMjeAiITCJ6F-Y3z1e0CFdWAxAodPZIEpA==", "playIcon": {"iconType": "PLAY_ARROW"}, "pauseIcon": {"iconType": "PAUSE"}, "iconColor": 4294967295, "backgroundColor": 0, "activeBackgroundColor": 0, "loadingIndicatorColor": 4294901760, "playingIcon": {"iconType": "VOLUME_UP"}, "iconLoadingColor": 0, "activeScaleFactor": 1, "buttonSize": "MUSIC_PLAY_BUTTON_SIZE_SMALL", "rippleTarget": "MUSIC_PLAY_BUTTON_RIPPLE_TARGET_SELF" } }, "contentPosition": "MUSIC_ITEM_THUMBNAIL_OVERLAY_CONTENT_POSITION_CENTERED", "displayStyle": "MUSIC_ITEM_THUMBNAIL_OVERLAY_DISPLAY_STYLE_PERSISTENT" } }, "flexColumns": [ { "musicResponsiveListItemFlexColumnRenderer": { "text": {"runs": [{"text": "That's My Jam"}]}, "displayPriority": "MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH" } }, { "musicResponsiveListItemFlexColumnRenderer": { "text": { "runs": [ {"text": "Skindred"}, {"text": " • "}, {"text": "3:17"} ] }, "displayPriority": "MUSIC_RESPONSIVE_LIST_ITEM_COLUMN_DISPLAY_PRIORITY_HIGH" } } ], "flexColumnDisplayStyle": "MUSIC_RESPONSIVE_LIST_ITEM_FLEX_COLUMN_DISPLAY_STYLE_TWO_LINE_STACK", "itemHeight": "MUSIC_RESPONSIVE_LIST_ITEM_HEIGHT_TALL", "musicItemRendererDisplayPolicy": "MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT" } ``` _version.py ```python __version__ = "0.12.1" ```
kerem closed this issue 2026-02-27 22:07:58 +03:00
Author
Owner

@sigma67 commented on GitHub (Dec 18, 2020):

The search query you listed works fine for me. I'm not sure why the album would be missing the browseId.

In your PR you mention the item in question is uploaded or private. How could an uploaded item appear in normal search? As far as I'm aware regular YTMusic songs are strictly separated from uploaded/private items.

Edit: Never mind, I have found another search query to reproduce this.

<!-- gh-comment-id:748012315 --> @sigma67 commented on GitHub (Dec 18, 2020): The search query you listed works fine for me. I'm not sure why the album would be missing the browseId. In your PR you mention the item in question is uploaded or private. How could an uploaded item appear in normal search? As far as I'm aware regular YTMusic songs are strictly separated from uploaded/private items. Edit: Never mind, I have found another search query to reproduce this.
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#93
No description provided.