mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 23:36:00 +03:00
[GH-ISSUE #69] get_library_albums and get_library_songs fail if library is empty #51
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tadly on GitHub (Aug 28, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/69
Calls like...
YTMusic.get_library_albumsYTMusic.get_library_songs...often result in
KeyErrors for various reasons.YTMusic.get_library_albumsIf there are 0 albums in the library,
YTMusic.get_library_albumsthrowsKeyError: 'items'because of thisPossible fix:
results.get('items', [])YTMusic.get_library_songsalso throws
KeyError: 'items'because of thisPossible fix:
items.extend(parse_func(results.get(continuation_contents, [])))I'm sure there are many more places where problems like this would appear.
It would make sense to either do more investigating as to why those keys don't exist in certain conditions and properly work around it or use default values via
.get()as outlined above.Sadly I'm way to busy with other stuff to proved a PR. This issue is all I can do for now (and the foreseeable future)
@kawaiiDango commented on GitHub (Sep 10, 2020):
I got a key error too and get_library_upload_songs(limit=100000) sometimes fails. Not sure if this is a rate limit issue.
The
responseobject looks like this:@tadly commented on GitHub (Sep 11, 2020):
In my case it might actually be because of the transfer from google play music to youtube music.
While doing so, they migrated non existing entries which are now stuck in the yt database which I am unable to remove.
I've been in contact with support for the past 3-4 weeks and they haven't been able to solve the issue yet 👏
Whether or not this is the actual root-cause I don't know but it would make sense.
My OP still holds true though.
@sigma67 commented on GitHub (Sep 11, 2020):
The origin of this issue is the unreliability of the API itself. Sometimes the continuation contents will be missing randomly, which is an error on YouTube's end. The hard part is finding all the situations where the API can fail.
In my opinion, the way this issue is worded it's kind of a catchall-complaint that there can be random server-side errors with YT's API. It would be more helpful to point out specific error cases for specific API calls, so we can implement the corresponding error handling as needed.
The issue you mention with empty libraries was recently fixed for uploads (#74) and should be simple to fix for the calls you mentioned as well. I'll rename this issue accordingly and suggest we close it when that issue is fixed. If you find other cases, feel free to open a separate issue for those.
@kawaiiDango I believe this issue was fixed in
ca8a73046band should be part of the next release.@sigma67 commented on GitHub (Sep 16, 2020):
So I've fixed get_library_songs, unfortunately I couldn't reproduce the issue with get_library_albums.
If you have no albums in the library, the function should end here:
github.com/sigma67/ytmusicapi@09daac66fc/ytmusicapi/mixins/library.py (L89-L90)So there's no way you'd get an error at l. 92. Perhaps there was a different issue?
@tadly commented on GitHub (Sep 17, 2020):
As mentioned in in my previous comment, there's a bug within youtube music which prevents me from removing certain, dead entries.
This might be the cause for it.
Google support hasn't been helpful so far