Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'gridRenderer' for get_artist_albums #439

Closed
fabi321 opened this issue Sep 25, 2023 · 5 comments · Fixed by #440
Closed

KeyError: 'gridRenderer' for get_artist_albums #439

fabi321 opened this issue Sep 25, 2023 · 5 comments · Fixed by #440
Labels
yt-update A server-side change caused this issue

Comments

@fabi321
Copy link
Contributor

fabi321 commented Sep 25, 2023

Whenever using YTMusic.get_artist_albums, it fails with a KeyError: 'gridRenderer'

To Reproduce
Steps to reproduce the behavior:

>>> from ytmusicapi import YTMusic
>>> ytmusic = YTMusic()
>>> ytmusic.get_artist_albums('UCM-CWGUijAC-8idv6k6Fygw', 'ggMIegYIARoCAQI%3D')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/project/.venv/lib/python3.11/site-packages/ytmusicapi/mixins/browsing.py", line 255, in get_artist_albums
    results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + GRID_ITEMS)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/project/.venv/lib/python3.11/site-packages/ytmusicapi/navigation.py", line 81, in nav
    raise err
  File "~/project/.venv/lib/python3.11/site-packages/ytmusicapi/navigation.py", line 75, in nav
    root = root[k]
           ~~~~^^^
KeyError: 'gridRenderer'
@sigma67 sigma67 added the yt-update A server-side change caused this issue label Sep 25, 2023
@sigma67
Copy link
Owner

sigma67 commented Sep 25, 2023

Seems there's been an update and you can now filter by Albums/Singles and sort.

PR welcome.

fabi321 added a commit to fabi321/ytmusicapi that referenced this issue Sep 25, 2023
This doesn't touch singles at all, as I'm frankly too dumb to figure that out

Fixes sigma67#439
@fabi321
Copy link
Contributor Author

fabi321 commented Sep 25, 2023

One problem I'm currently facing is https://music.youtube.com/browse/UCNms80n59AltHVQuPgGrKkg
The params points to a list of musicResponsiveListItemRenderer, which matches the Songs shelf in ytmusic, but the params are clearly taken from the Albums shelf. I'm not sure, who's to fault there.

artist response:

[
  {
    "musicShelfRenderer": {
      "title": {
        "runs": [
          {
            "text": "Songs",
            ...
  },
  {
    "musicCarouselShelfRenderer": {
      "header": {
        "musicCarouselShelfBasicHeaderRenderer": {
          "title": {
            "runs": [
              {
                "text": "Albums",
                "navigationEndpoint": {
                  "browseEndpoint": {
                    "browseId": "MPADUCNms80n59AltHVQuPgGrKkg",
                    "params": "ggMIegYIARoCAQI%3D",
...

response using this endpoint + parameters:

{
  "musicShelfRenderer": {
    "title": {
      "runs": [
        {
          "text": "Songs",
          "navigationEndpoint": {
            "browseEndpoint": {
              "browseId": "VLOLAK5uy_l4hMfu2sKTre4vbmEVhMWXc7HXZcdc-Os",
              "params": "ggMCCAI%3D",
              }
            }
          }
        }
      ]
    },
    "contents": [
      {
        "musicResponsiveListItemRenderer": 
...

@fabi321
Copy link
Contributor Author

fabi321 commented Sep 25, 2023

I was to blame for that last mistake. I wrongly assumed, that I could use the channelId as browseId for getting albums, while that isn't always the case. Fixing that fixed the issue.

sigma67 pushed a commit that referenced this issue Sep 25, 2023
This doesn't touch singles at all, as I'm frankly too dumb to figure that out

Fixes #439
@sigma67
Copy link
Owner

sigma67 commented Sep 25, 2023

#441 for the new features

@sigma67
Copy link
Owner

sigma67 commented Jan 10, 2024

#441 is now completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
yt-update A server-side change caused this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants