[GH-ISSUE #284] Not all channels have a 'musicImmersiveHeaderRenderer' #222

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

Originally created by @Yamboy1 on GitHub (Jul 28, 2022).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/284

Running

from ytmusicapi import YTMusic
ytmusic = YTMusic("headers_auth.json")
ytmusic.get_artist("UChTTUKuugGqU4F0UblZF5Kw")

causes this KeyError

Traceback (most recent call last):
  File "app.py", line 12, in <module>
    ytmusic.get_artist("UChTTUKuugGqU4F0UblZF5Kw")
  File "/home/user/project/venv/lib/python3.8/site-packages/ytmusicapi/mixins/browsing.py", line 213, in get_artist
    header = response['header']['musicImmersiveHeaderRenderer']
KeyError: 'musicImmersiveHeaderRenderer'

It appears that channels which only have videos, and not songs, have a less featureful 'musicVisualHeaderRenderer' instead of the normal 'musicImmersiveHeaderRenderer', without shuffle, radio and subscribe buttons. I was hoping this would be a quick fix, but the channel id is obtained from the subscribe button for some reason, which seems to complicate things slightly.
image

Originally created by @Yamboy1 on GitHub (Jul 28, 2022). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/284 Running ```py from ytmusicapi import YTMusic ytmusic = YTMusic("headers_auth.json") ytmusic.get_artist("UChTTUKuugGqU4F0UblZF5Kw") ``` causes this KeyError ```py Traceback (most recent call last): File "app.py", line 12, in <module> ytmusic.get_artist("UChTTUKuugGqU4F0UblZF5Kw") File "/home/user/project/venv/lib/python3.8/site-packages/ytmusicapi/mixins/browsing.py", line 213, in get_artist header = response['header']['musicImmersiveHeaderRenderer'] KeyError: 'musicImmersiveHeaderRenderer' ``` It appears that channels which only have videos, and not songs, have a less featureful 'musicVisualHeaderRenderer' instead of the normal 'musicImmersiveHeaderRenderer', without shuffle, radio and subscribe buttons. I was hoping this would be a quick fix, but the channel id is obtained from the subscribe button for some reason, which seems to complicate things slightly. ![image](https://user-images.githubusercontent.com/37413895/181432558-22c7083f-b192-4e2d-9c15-f435112fa9ae.png)
kerem closed this issue 2026-02-27 22:08:40 +03:00
Author
Owner

@sigma67 commented on GitHub (Aug 2, 2022):

It's because this is not an artist, it's a user. You need to use get_user.

This is usually the case when there are only videos and playlists on the page. Perhaps we could add an Exception to indicate that this might be a user if the musicImmersiveHeaderRenderer is missing.

<!-- gh-comment-id:1202793613 --> @sigma67 commented on GitHub (Aug 2, 2022): It's because this is not an artist, it's a user. You need to use [`get_user`](https://ytmusicapi.readthedocs.io/en/latest/reference.html?highlight=get_user#ytmusicapi.YTMusic.get_user). This is usually the case when there are only videos and playlists on the page. Perhaps we could add an Exception to indicate that this might be a user if the `musicImmersiveHeaderRenderer` is missing.
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#222
No description provided.