Tolerate missing thumbnails when parsing playlist items - #974
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes parse_playlist resilient to playlist items whose thumbnail renderer exists but contains an empty/missing thumbnail.thumbnails payload, preventing a single malformed card from causing get_library_playlists() to fail entirely.
Changes:
- Update
parse_playlistto callnav(..., none_if_absent=True)for playlist thumbnails so missing/empty thumbnail structures yieldthumbnails: Noneinstead of raising. - Add parser tests covering valid thumbnails and four “missing/empty thumbnail” renderer shapes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
ytmusicapi/parsers/browsing.py |
Makes playlist thumbnail parsing tolerant of absent/empty thumbnail payloads by allowing nav to return None. |
tests/parsers/test_browsing.py |
Adds coverage for valid thumbnails plus multiple missing/empty thumbnail renderer shapes to prevent regressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #974 +/- ##
=======================================
Coverage 95.77% 95.77%
=======================================
Files 47 47
Lines 2723 2723
=======================================
Hits 2608 2608
Misses 115 115
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
parse_playlistreads the thumbnail withnav(data, THUMBNAIL_RENDERER)and nonone_if_absent. Some library shelf cards return a thumbnail renderer with an emptythumbnailobject.navthen raises:parse_content_listhas no per-item error handling, so one such card makes the wholeget_library_playlists()call fail. The user gets no playlists at all.The
titlefield in the same function already guards against this case.parse_videoandparse_related_artistin the same module also read the thumbnail withnone_if_absent.Reported downstream at music-assistant/support#6011.
Changes
parse_playlistreturnsthumbnails: Noneinstead of raising when the thumbnail is absent or empty.tests/parsers/test_browsing.pycovering the four shapes: no renderer, empty renderer, empty music renderer, and empty thumbnail object.