sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.59k stars 182 forks source link

Error in `get_artist` #575

Closed fabi321 closed 2 months ago

fabi321 commented 2 months ago

Describe the bug

ytmusic = YTMusic()
ytmusic.get_artist('MPADUCvkNfpMmpGTGI9dC2FW0baQ')

Fails with the following error:

  File "/.venv/lib/python3.11/site-packages/ytmusicapi/mixins/browsing.py", line 228, in get_artist
    header = response["header"]["musicImmersiveHeaderRenderer"]
             ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'musicImmersiveHeaderRenderer'

From my preliminary diagnosis, it seems like Youtube ships a musicHeaderRenderer instead of a musicImmersiveHeaderRenderer. Example response:

{
  ...,
  "header": {
    "musicHeaderRenderer": {
      "title": {
        "runs": [
          {
            "text": "SoulHikers"
          }
        ]
      },
      "trackingParams": "..."
    }
  },
  ...
}

Version: 1.6.0 (from pypi)

fabi321 commented 2 months ago

After looking a bit more into the response I got, it confuses me a lot. It doesn't match the website at all. I can only find all singles in it, and nothing else. No subscribe button, no videos. I suspect that they actually changed something about the API endpoint.

fabi321 commented 2 months ago

I have no clue, where I got the channel id from. I thought I copied it from the channel, but apparently I accidentally copied the singles screen, sorry, my bad.