[GH-ISSUE #26] get_artist and get_album are broken #18

Closed
opened 2026-02-27 22:07:34 +03:00 by kerem · 3 comments
Owner

Originally created by @stephen-huan on GitHub (May 26, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/26

I tried the get_artist and get_album examples in the documentation, but both seem to be broken. I tried with and without headers_auth.json.

ytmusic = YTMusic()
print(ytmusic.get_artist("UCmMUZbaYdNH0bEd1PAlAqsA"))
print(ytmusic.get_album("OLAK5uy_kGnhwT08mQMGw8fArBowdtlew3DpgUt9c"))

Traceback for get_artist

Traceback (most recent call last):
  File "youtube-music-dl.py", line 61, in <module>
    print(ytmusic.get_artist("UCmMUZbaYdNH0bEd1PAlAqsA"))
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 302, in get_artist
    result['videoId'] = nav(item, TITLE + NAVIGATION_VIDEO_ID)
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/parsers.py", line 286, in nav
    root = root[k]
KeyError: 'navigationEndpoint'

Traceback for get_album

Traceback (most recent call last):
  File "youtube-music-dl.py", line 62, in <module>
    print(ytmusic.get_album("OLAK5uy_kGnhwT08mQMGw8fArBowdtlew3DpgUt9c"))
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 374, in get_album
    data = nav(response, FRAMEWORK_MUTATIONS)
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/parsers.py", line 286, in nav
    root = root[k]
KeyError: 'frameworkUpdates'

Operating system is macOS, Python version is 3.8.2, ytmusicapi version is 0.7.1.

Originally created by @stephen-huan on GitHub (May 26, 2020). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/26 I tried the `get_artist` and `get_album` examples in the documentation, but both seem to be broken. I tried with and without headers_auth.json. ``` ytmusic = YTMusic() print(ytmusic.get_artist("UCmMUZbaYdNH0bEd1PAlAqsA")) print(ytmusic.get_album("OLAK5uy_kGnhwT08mQMGw8fArBowdtlew3DpgUt9c")) ``` Traceback for `get_artist` ``` Traceback (most recent call last): File "youtube-music-dl.py", line 61, in <module> print(ytmusic.get_artist("UCmMUZbaYdNH0bEd1PAlAqsA")) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 302, in get_artist result['videoId'] = nav(item, TITLE + NAVIGATION_VIDEO_ID) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/parsers.py", line 286, in nav root = root[k] KeyError: 'navigationEndpoint' ``` Traceback for `get_album` ``` Traceback (most recent call last): File "youtube-music-dl.py", line 62, in <module> print(ytmusic.get_album("OLAK5uy_kGnhwT08mQMGw8fArBowdtlew3DpgUt9c")) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 374, in get_album data = nav(response, FRAMEWORK_MUTATIONS) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/parsers.py", line 286, in nav root = root[k] KeyError: 'frameworkUpdates' ``` Operating system is macOS, Python version is 3.8.2, ytmusicapi version is 0.7.1.
kerem 2026-02-27 22:07:34 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sigma67 commented on GitHub (May 26, 2020):

The get_artist error was fixed in 20e44873d3, which unfortunately didn't make the 0.7.1 release. A 0.8.0 release will be coming soon which includes the fix. Meanwhile you can work with the latest version by running pip install git+https://github.com/sigma67/ytmusicapi.

As for get_album, you need to provide a browseId as specified in the function signature. You are passing the album's audioPlaylistId, which doesn't work with the endpoint that's used by get_album.

The function could be expanded to work with audioPlaylistIds as well, but it would require an additional request. On the Web UI, when you open https://music.youtube.com/playlist?list=OLAK5uy_k0i7Z0ehZyxEGt9vVQz0EoHvRI96jVMY8, YouTube Music provides some javascript that contains the album's browseId. So ytmusicapi could provide a helper function to get the album browseId from the audioPlaylistId, which uses that GET request and parses the response HTML. But I'm not sure if that's of any practical use, since the other API endpoints provide browseIds for albums.

<!-- gh-comment-id:633881801 --> @sigma67 commented on GitHub (May 26, 2020): The `get_artist` error was fixed in 20e44873d34bb221ff01824ad5d1ac269f52b20f, which unfortunately didn't make the 0.7.1 release. A 0.8.0 release will be coming soon which includes the fix. Meanwhile you can work with the latest version by running `pip install git+https://github.com/sigma67/ytmusicapi`. As for `get_album`, you need to provide a browseId as specified in the function signature. You are passing the album's audioPlaylistId, which doesn't work with the endpoint that's used by `get_album`. The function could be expanded to work with audioPlaylistIds as well, but it would require an additional request. On the Web UI, when you open https://music.youtube.com/playlist?list=OLAK5uy_k0i7Z0ehZyxEGt9vVQz0EoHvRI96jVMY8, YouTube Music provides some javascript that contains the album's browseId. So ytmusicapi could provide a helper function to get the album browseId from the audioPlaylistId, which uses that GET request and parses the response HTML. But I'm not sure if that's of any practical use, since the other API endpoints provide browseIds for albums.
Author
Owner

@stephen-huan commented on GitHub (May 26, 2020):

Thanks for the help: when I updated the package, I could get those examples to work.
However, I still can't get a few artists to work.

This works:
https://music.youtube.com/channel/UClyW5VlmRBdFlRWLpMoHlbQ

print(ytmusic.get_artist("UClyW5VlmRBdFlRWLpMoHlbQ"))

But these don't:
https://music.youtube.com/channel/UC8y3Cf-TB5cTNugNtDl6XWw
https://music.youtube.com/channel/UCEsOqBVe_DNEUAer9TYk6bw

Traceback for the first one:

Traceback (most recent call last):
  File "youtube-music-dl.py", line 92, in <module>
    {ARTIST: download_artist, PLAYLIST: download_playlist, SONG: download_song}[content](ID)
  File "youtube-music-dl.py", line 68, in download_artist
    print(ytmusic.get_artist("UC8y3Cf-TB5cTNugNtDl6XWw"))
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 261, in get_artist
    artist['description'] = results[-1]['musicDescriptionShelfRenderer']['description'][
KeyError: 'musicDescriptionShelfRenderer'

Traceback for the second:

Traceback (most recent call last):  File "youtube-music-dl.py", line 92, in <module>    {ARTIST: download_artist, PLAYLIST: download_playlist, SONG: download_song}[content](ID)
  File "youtube-music-dl.py", line 68, in download_artist
    print(ytmusic.get_artist("UCEsOqBVe_DNEUAer9TYk6bw"))
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 268, in get_artist
    artist['songs']['browseId'] = nav(musicShelf, TITLE + NAVIGATION_BROWSE_ID)
  File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/parsers.py", line 299, in nav
    root = root[k]
KeyError: 'navigationEndpoint'

The first error appears to be caused by an artist without a description, but I thought that was fixed in a recent commit. The second artist has a description, but the error is different.

ytmusicapi version is most recent git commit (from Pipfile.lock):

"ytmusicapi": {
            "git": "https://github.com/sigma67/ytmusicapi",
            "ref": "4aae905a027875ab79ee50cd0b3e6c4e6dc63824"
        }
<!-- gh-comment-id:634080473 --> @stephen-huan commented on GitHub (May 26, 2020): Thanks for the help: when I updated the package, I could get those examples to work. However, I still can't get a few artists to work. This works: https://music.youtube.com/channel/UClyW5VlmRBdFlRWLpMoHlbQ ``` print(ytmusic.get_artist("UClyW5VlmRBdFlRWLpMoHlbQ")) ``` But these don't: https://music.youtube.com/channel/UC8y3Cf-TB5cTNugNtDl6XWw https://music.youtube.com/channel/UCEsOqBVe_DNEUAer9TYk6bw Traceback for the first one: ``` Traceback (most recent call last): File "youtube-music-dl.py", line 92, in <module> {ARTIST: download_artist, PLAYLIST: download_playlist, SONG: download_song}[content](ID) File "youtube-music-dl.py", line 68, in download_artist print(ytmusic.get_artist("UC8y3Cf-TB5cTNugNtDl6XWw")) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 261, in get_artist artist['description'] = results[-1]['musicDescriptionShelfRenderer']['description'][ KeyError: 'musicDescriptionShelfRenderer' ``` Traceback for the second: ``` Traceback (most recent call last): File "youtube-music-dl.py", line 92, in <module> {ARTIST: download_artist, PLAYLIST: download_playlist, SONG: download_song}[content](ID) File "youtube-music-dl.py", line 68, in download_artist print(ytmusic.get_artist("UCEsOqBVe_DNEUAer9TYk6bw")) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 268, in get_artist artist['songs']['browseId'] = nav(musicShelf, TITLE + NAVIGATION_BROWSE_ID) File "/Users/stephenhuan/.local/share/virtualenvs/youtube-music-dl-u083frPF/lib/python3.8/site-packages/ytmusicapi/parsers.py", line 299, in nav root = root[k] KeyError: 'navigationEndpoint' ``` The first error appears to be caused by an artist without a description, but I thought that was fixed in a recent commit. The second artist has a description, but the error is different. ytmusicapi version is most recent git commit (from Pipfile.lock): ``` "ytmusicapi": { "git": "https://github.com/sigma67/ytmusicapi", "ref": "4aae905a027875ab79ee50cd0b3e6c4e6dc63824" } ```
Author
Owner

@sigma67 commented on GitHub (May 27, 2020):

Good catch, I never tested that function for artists without description or with few songs. Should be fixed now.

<!-- gh-comment-id:634981008 --> @sigma67 commented on GitHub (May 27, 2020): Good catch, I never tested that function for artists without description or with few songs. Should be fixed now.
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#18
No description provided.