sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.59k stars 182 forks source link

Gracefully retrieve uploaded songs with a blank duration (#578) #580

Closed apastel closed 1 month ago

apastel commented 1 month ago

Fixes #578

This prevents a possible KeyError or a int-parsing error when an uploaded song has a duration that is not a valid value like "3:31".

Per-recent changes by Google, an uploaded song can have a duration of ' ' or simply not have a fixedColumns object at all. This is most commonly seen immediately after uploading a song but can be seen in other cases as well.

I added a unit test that exercises this. It uploads a song and then starts calling get_library_upload_songs() in a loop, waiting for the song to be available. Without my duration fix, this encounters a parsing error. With the fix, it succeeds.