[GH-ISSUE #43] KeyError when retrieving library songs list #33

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

Originally created by @luckybuzz on GitHub (Jul 14, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/43

first off, huge thanks to sigma67 for taking on this project. i'm an addictive user of google play music, and have been dreading the switch... but thanks to this project i may be able to find a similar satisfaction with YT music in the long run.

this is my first issue, so apologies for any missing/incomplete info. thanks in advance for any assistance you can provide.

i have v0.8.1 installed, and have been poking around learning the usage. when i attempted get_library_songs(), i got the following result:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\isaacq\AppData\Roaming\Python\Python38\site-packages\ytmusicapi\ytmusic.py", line 554, in get_library_songs
results = nav(results, ITEM_SECTION)['musicShelfRenderer']
KeyError: 'musicShelfRenderer'

Originally created by @luckybuzz on GitHub (Jul 14, 2020). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/43 first off, huge thanks to sigma67 for taking on this project. i'm an addictive user of google play music, and have been dreading the switch... but thanks to this project i may be able to find a similar satisfaction with YT music in the long run. this is my first issue, so apologies for any missing/incomplete info. thanks in advance for any assistance you can provide. i have v0.8.1 installed, and have been poking around learning the usage. when i attempted get_library_songs(), i got the following result: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\isaacq\AppData\Roaming\Python\Python38\site-packages\ytmusicapi\ytmusic.py", line 554, in get_library_songs results = nav(results, ITEM_SECTION)['musicShelfRenderer'] KeyError: 'musicShelfRenderer'
kerem closed this issue 2026-02-27 22:07:39 +03:00
Author
Owner

@sigma67 commented on GitHub (Jul 14, 2020):

Glad you like it! I have also noticed odd behavior with get_library_songs like sporadically failing tests. The oddest part is that it seems to return a different count of songs every API call.

I haven't stumbled upon your error however. Do you have songs in your library?
If yes, would you mind placing a breakpoint at that line and sharing the contents of the response variable?

<!-- gh-comment-id:658327002 --> @sigma67 commented on GitHub (Jul 14, 2020): Glad you like it! I have also noticed odd behavior with get_library_songs like sporadically failing tests. The oddest part is that it seems to return a different count of songs every API call. I haven't stumbled upon your error however. Do you have songs in your library? If yes, would you mind placing a breakpoint at that line and sharing the contents of the `response` variable?
Author
Owner

@luckybuzz commented on GitHub (Jul 14, 2020):

thx for your quick reply! i couldn't think of an easy way to share the contents of response, so I saved to a .csv and saved it for you at [http://isaacq.ca/files/response.csv]. hope this helps!

EDIT: oh and to answer your question, there are only 2 songs in my library as of right now.

<!-- gh-comment-id:658360140 --> @luckybuzz commented on GitHub (Jul 14, 2020): thx for your quick reply! i couldn't think of an easy way to share the contents of `response`, so I saved to a .csv and saved it for you at [http://isaacq.ca/files/response.csv]. hope this helps! EDIT: oh and to answer your question, there are only 2 songs in my library as of right now.
Author
Owner

@luckybuzz commented on GitHub (Jul 14, 2020):

sigma i owe you a big apology. the problem was on my end and i've diagnosed it. turns out the cookie from my Firefox session was for my main Google account, but all my music and playlists were somehow on a brand account, so your script was talking to an empty YTM account. i'm very sorry for creating the extraneous issue and for wasting your time. will stay tuned for future developments!

<!-- gh-comment-id:658414729 --> @luckybuzz commented on GitHub (Jul 14, 2020): sigma i owe you a big apology. the problem was on my end and i've diagnosed it. turns out the cookie from my Firefox session was for my main Google account, but all my music and playlists were somehow on a brand account, so your script was talking to an empty YTM account. i'm very sorry for creating the extraneous issue and for wasting your time. will stay tuned for future developments!
Author
Owner

@sigma67 commented on GitHub (Jul 15, 2020):

No problem, this issue is still valid. You should not get an error if the account is empty, you should get an empty list instead. Can you verify if this issue appears with other library methods as well for your main account?

<!-- gh-comment-id:658650641 --> @sigma67 commented on GitHub (Jul 15, 2020): No problem, this issue is still valid. You should not get an error if the account is empty, you should get an empty list instead. Can you verify if this issue appears with other library methods as well for your main account?
Author
Owner

@luckybuzz commented on GitHub (Jul 15, 2020):

actually, there were playlists in my main account, just no individual
songs. so using playlist methods worked fine for me, i only got the error
previously mentioned when querying about my library songs.

at this point, i switched everything over to my main account, so can no
longer replicate the original error as all my songs are there now.

off topic, do you know if youtube music makes play counts for individual
songs available to the api, like google play music does?

thanks again :)

On Wed, Jul 15, 2020 at 4:15 AM sigmatics notifications@github.com wrote:

No problem, this issue is still valid. You should not get an error if the
account is empty, you should get an empty list instead. Can you verify if
this issue appears with other library methods as well for your main account?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/sigma67/ytmusicapi/issues/43#issuecomment-658650641,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AD7HBMFAKS2QCNMOYAHA6K3R3VXTPANCNFSM4OZWC6MQ
.

<!-- gh-comment-id:658960247 --> @luckybuzz commented on GitHub (Jul 15, 2020): actually, there were playlists in my main account, just no individual songs. so using playlist methods worked fine for me, i only got the error previously mentioned when querying about my library songs. at this point, i switched everything over to my main account, so can no longer replicate the original error as all my songs are there now. off topic, do you know if youtube music makes play counts for individual songs available to the api, like google play music does? thanks again :) On Wed, Jul 15, 2020 at 4:15 AM sigmatics <notifications@github.com> wrote: > No problem, this issue is still valid. You should not get an error if the > account is empty, you should get an empty list instead. Can you verify if > this issue appears with other library methods as well for your main account? > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/sigma67/ytmusicapi/issues/43#issuecomment-658650641>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AD7HBMFAKS2QCNMOYAHA6K3R3VXTPANCNFSM4OZWC6MQ> > . >
Author
Owner

@sigma67 commented on GitHub (Jul 15, 2020):

off topic, do you know if youtube music makes play counts for individual
songs available to the api, like google play music does?

No, they are not available. The best you can do is use get_history, but it only includes each song once. If you play it again the song just moves up in the list.

<!-- gh-comment-id:658974091 --> @sigma67 commented on GitHub (Jul 15, 2020): > off topic, do you know if youtube music makes play counts for individual songs available to the api, like google play music does? No, they are not available. The best you can do is use `get_history`, but it only includes each song once. If you play it again the song just moves up in the list.
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#33
No description provided.