[GH-ISSUE #119] KeyError: 'runs' while fetching playlists #86

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

Originally created by @KoljaWindeler on GitHub (Dec 11, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/119

hi, i'm using great api for this media_player: https://github.com/KoljaWindeler/ytube_music_player and it works great in general. a user hit the error below (https://community.home-assistant.io/t/youtube-music-media-browser/226367/129?u=jkw) any idea what happened here and how to prevent this?
thanks


  File "/config/custom_components/ytube_music_player/media_player.py", line 387, in _update_playlists
    self._playlists = self._api.get_library_playlists(limit = 99)
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 39, in get_library_playlists
    get_continuations(results, 'gridContinuation', limit - len(playlists),
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 67, in get_continuations
    contents = get_continuation_contents(results, parse_func)
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 110, in get_continuation_contents
    return parse_func(continuation[term])
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 37, in <lambda>
    parse_func = lambda contents: parse_content_list(contents, parse_playlist)
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/browsing.py", line 139, in parse_content_list
    contents.append(parse_func(result['musicTwoRowItemRenderer']))
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/browsing.py", line 176, in parse_playlist
    'title': nav(data, TITLE_TEXT),
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 148, in nav
    raise err
  File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 142, in nav
    root = root[k]
KeyError: 'runs'

edit another user pointed out that it is caused by empty playlists?

Originally created by @KoljaWindeler on GitHub (Dec 11, 2020). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/119 hi, i'm using great api for this media_player: https://github.com/KoljaWindeler/ytube_music_player and it works great in general. a user hit the error below (https://community.home-assistant.io/t/youtube-music-media-browser/226367/129?u=jkw) any idea what happened here and how to prevent this? thanks ``` File "/config/custom_components/ytube_music_player/media_player.py", line 387, in _update_playlists self._playlists = self._api.get_library_playlists(limit = 99) File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 39, in get_library_playlists get_continuations(results, 'gridContinuation', limit - len(playlists), File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 67, in get_continuations contents = get_continuation_contents(results, parse_func) File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 110, in get_continuation_contents return parse_func(continuation[term]) File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 37, in <lambda> parse_func = lambda contents: parse_content_list(contents, parse_playlist) File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/browsing.py", line 139, in parse_content_list contents.append(parse_func(result['musicTwoRowItemRenderer'])) File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/browsing.py", line 176, in parse_playlist 'title': nav(data, TITLE_TEXT), File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 148, in nav raise err File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 142, in nav root = root[k] KeyError: 'runs' ``` edit another user pointed out that it is caused by empty playlists?
kerem closed this issue 2026-02-27 22:07:57 +03:00
Author
Owner

@sigma67 commented on GitHub (Dec 11, 2020):

Unfortunately I can't reproduce it even when I create an empty playlist in my library. There must be some odd playlist in there that is causing this issue. The playlist title should never be missing.

Could you ask the users to take screenshots of any odd playlists in their library, or even better provide the response from YouTube Music when they open the library page/retrieve it with ytmusicapi? Kind of hard to tell what edge case we're running into here without more detail.

<!-- gh-comment-id:743127102 --> @sigma67 commented on GitHub (Dec 11, 2020): Unfortunately I can't reproduce it even when I create an empty playlist in my library. There must be some odd playlist in there that is causing this issue. The playlist title should never be missing. Could you ask the users to take screenshots of any odd playlists in their library, or even better provide the response from YouTube Music when they open the library page/retrieve it with ytmusicapi? Kind of hard to tell what edge case we're running into here without more detail.
Author
Owner

@sigma67 commented on GitHub (Dec 16, 2020):

Is this issue still relevant @KoljaWindeler ? Any idea under what circumstances this is happening?

<!-- gh-comment-id:745909281 --> @sigma67 commented on GitHub (Dec 16, 2020): Is this issue still relevant @KoljaWindeler ? Any idea under what circumstances this is happening?
Author
Owner

@KoljaWindeler commented on GitHub (Dec 16, 2020):

I guess we can close it. no feedback from the user who reported the issue and it is working fine here

<!-- gh-comment-id:745927832 --> @KoljaWindeler commented on GitHub (Dec 16, 2020): I guess we can close it. no feedback from the user who reported the issue and it is working fine here
Author
Owner

@KoljaWindeler commented on GitHub (Dec 30, 2020):

Hi just because we might have the same case again and this time a user who is willing to help .. can you give some guidance on "or even better provide the response from YouTube Music when they open the library page/retrieve it with ytmusicapi?"

<!-- gh-comment-id:752718303 --> @KoljaWindeler commented on GitHub (Dec 30, 2020): Hi just because we might have the same case again and this time a user who is willing to help .. can you give some guidance on "or even better provide the response from YouTube Music when they open the library page/retrieve it with ytmusicapi?"
Author
Owner

@sigma67 commented on GitHub (Dec 31, 2020):

Similar to when you set up ytmusicapi, open the network requests tab in your browser's developer tools. Then click on 'Library', which should fetch the playlists also. You will see a request to /browse, where you can right click -> copy -> copy response (in Firefox). The procedure is similar in Chrome.

To ensure you selected the correct request you can clear your network tab beforehand (trash icon) or search the response for the title of some of the playlists that appear on the page.

<!-- gh-comment-id:752910980 --> @sigma67 commented on GitHub (Dec 31, 2020): Similar to when you set up ytmusicapi, open the network requests tab in your browser's developer tools. Then click on 'Library', which should fetch the playlists also. You will see a request to /browse, where you can right click -> copy -> copy response (in Firefox). The procedure is similar in Chrome. To ensure you selected the correct request you can clear your network tab beforehand (trash icon) or search the response for the title of some of the playlists that appear on the page.
Author
Owner

@KoljaWindeler commented on GitHub (Jan 2, 2021):

no feedback from user, sorry. will reopen if i get more feedback

<!-- gh-comment-id:753519133 --> @KoljaWindeler commented on GitHub (Jan 2, 2021): no feedback from user, sorry. will reopen if i get more feedback
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#86
No description provided.