[GH-ISSUE #757] get_album fails with KeyError: 'navigationEndpoint' #485

Closed
opened 2026-02-27 23:01:03 +03:00 by kerem · 5 comments
Owner

Originally created by @FireTime on GitHub (Mar 30, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/757

Describe the bug
ytmusic.get_album fails on some albums with KeyError: 'navigationEndpoint'

To Reproduce
Steps to reproduce the behavior:
example browse IDs that result in a failure
ytmusic.get_album('MPREb_vS6PfafqppP')
ytmusic.get_album('MPREb_5iJFlBsHZOj')
ytmusic.get_album('MPREb_O5BghuJbKAz')

Error returned:

>>> ytmusic.get_album('MPREb_vS6PfafqppP')
Traceback (most recent call last):
  File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\navigation.py", line 117, in nav
    root = root[k]
           ~~~~^^^
KeyError: 'navigationEndpoint'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\mixins\browsing.py", line 565, in get_album
    album["other_versions"] = parse_content_list(other_versions["contents"], parse_album)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\parsers\browsing.py", line 52, in parse_content_list
    contents.append(parse_func(result[key]))
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\parsers\browsing.py", line 62, in parse_album
    "browseId": nav(result, TITLE + NAVIGATION_BROWSE_ID),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\navigation.py", line 121, in nav
    raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}")
KeyError: "Unable to find 'navigationEndpoint' using path ['title', 'runs', 0, 'navigationEndpoint', 'browseEndpoint', 'browseId'] on {'text': 'Back To Me'}, exception: 'navigationEndpoint'"

Additional context
Python 3.12.4
ytmusicapi 1.10.2
minimum program to reproduce:

from ytmusicapi import YTMusic, OAuthCredentials
ytmusic = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id=<<SNIP>>, client_secret=<<SNIP>>))
ytmusic.get_album('MPREb_5iJFlBsHZOj')

Originally created by @FireTime on GitHub (Mar 30, 2025). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/757 **Describe the bug** ytmusic.get_album fails on some albums with KeyError: 'navigationEndpoint' **To Reproduce** Steps to reproduce the behavior: example browse IDs that result in a failure `ytmusic.get_album('MPREb_vS6PfafqppP')` `ytmusic.get_album('MPREb_5iJFlBsHZOj')` `ytmusic.get_album('MPREb_O5BghuJbKAz')` Error returned: ``` >>> ytmusic.get_album('MPREb_vS6PfafqppP') Traceback (most recent call last): File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\navigation.py", line 117, in nav root = root[k] ~~~~^^^ KeyError: 'navigationEndpoint' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\mixins\browsing.py", line 565, in get_album album["other_versions"] = parse_content_list(other_versions["contents"], parse_album) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\parsers\browsing.py", line 52, in parse_content_list contents.append(parse_func(result[key])) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\parsers\browsing.py", line 62, in parse_album "browseId": nav(result, TITLE + NAVIGATION_BROWSE_ID), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FireTime\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\navigation.py", line 121, in nav raise type(e)(f"Unable to find '{k}' using path {items!r} on {root!r}, exception: {e}") KeyError: "Unable to find 'navigationEndpoint' using path ['title', 'runs', 0, 'navigationEndpoint', 'browseEndpoint', 'browseId'] on {'text': 'Back To Me'}, exception: 'navigationEndpoint'" ``` **Additional context** Python 3.12.4 ytmusicapi 1.10.2 minimum program to reproduce: ``` from ytmusicapi import YTMusic, OAuthCredentials ytmusic = YTMusic("oauth.json", oauth_credentials=OAuthCredentials(client_id=<<SNIP>>, client_secret=<<SNIP>>)) ytmusic.get_album('MPREb_5iJFlBsHZOj') ```
kerem 2026-02-27 23:01:03 +03:00
  • closed this issue
  • added the
    invalid
    label
Author
Owner

@sigma67 commented on GitHub (Apr 1, 2025):

I cannot reproduce this with a non-authenticated instance (YTMusic()). Is it only valid for authenticated accounts?

<!-- gh-comment-id:2768365825 --> @sigma67 commented on GitHub (Apr 1, 2025): I cannot reproduce this with a non-authenticated instance (`YTMusic()`). Is it only valid for authenticated accounts?
Author
Owner

@FireTime commented on GitHub (Apr 1, 2025):

I can confirm that this only happens when using an authenticated account.

So work around as of now is to have two instances of YTMusic loaded. One authenticated and one not depending on the API calls.

<!-- gh-comment-id:2770410651 --> @FireTime commented on GitHub (Apr 1, 2025): I can confirm that this only happens when using an authenticated account. So work around as of now is to have two instances of YTMusic loaded. One authenticated and one not depending on the API calls.
Author
Owner

@sigma67 commented on GitHub (Apr 3, 2025):

I just tried with my authenticated main account (non-brand) and it's not failing either.

Did you interact with the albums in a special way? Add them to your library? Although that doesn't make them fail for me either.

<!-- gh-comment-id:2774892578 --> @sigma67 commented on GitHub (Apr 3, 2025): I just tried with my authenticated main account (non-brand) and it's not failing either. Did you interact with the albums in a special way? Add them to your library? Although that doesn't make them fail for me either.
Author
Owner

@FireTime commented on GitHub (Apr 6, 2025):

Nothing special with these tracks. Previously I was able to reproduce the error 100% of the time on those select items. However, attempting the same action with the same demo file today I no longer get the error with any tracks. I'll chalk it up to google doing something strange.

Sorry for the distraction.

<!-- gh-comment-id:2781171066 --> @FireTime commented on GitHub (Apr 6, 2025): Nothing special with these tracks. Previously I was able to reproduce the error 100% of the time on those select items. However, attempting the same action with the same demo file today I no longer get the error with any tracks. I'll chalk it up to google doing something strange. Sorry for the distraction.
Author
Owner

@sigma67 commented on GitHub (Apr 6, 2025):

No worries, thanks for following up

<!-- gh-comment-id:2781443070 --> @sigma67 commented on GitHub (Apr 6, 2025): No worries, thanks for following up
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#485
No description provided.