Expose ownership for library playlists - #972
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an ownership signal to playlist objects returned from library/grid playlist cards so downstream clients can distinguish owned (editable) playlists from saved playlists without additional requests.
Changes:
- Add an
owned: boolfield toparse_playlist()derived from the presence of a matchingplaylistEditorEndpoint.playlistId. - Update
get_library_playlists()docstring to describe library playlists (not only owned) and document the newownedfield. - Add parser tests for owned vs not-owned playlists.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ytmusicapi/parsers/browsing.py | Derives and exposes owned for playlists parsed from browsing/grid cards via playlistEditorEndpoint. |
| ytmusicapi/mixins/library.py | Updates get_library_playlists() documentation to include owned and correct the return description/example. |
| tests/parsers/test_browsing.py | Adds unit tests asserting parse_playlist() sets owned appropriately. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
ytmusicapi/mixins/library.py:34
- Docstring example shows
countas an int (5), butparse_playlist()setscounttonav(...).split(' ')[0], which returns a string (e.g.'5'). This can mislead API consumers about the return type.
'count': 5,
# Conflicts: # tests/parsers/test_browsing.py # ytmusicapi/parsers/browsing.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #972 +/- ##
=======================================
Coverage 95.77% 95.78%
=======================================
Files 47 47
Lines 2725 2727 +2
=======================================
+ Hits 2610 2612 +2
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. |
…owned # Conflicts: # tests/parsers/test_browsing.py
# What does this implement/fix? YouTube Music library playlist objects do not include `privacy`, so owned playlists were imported as read-only. This change uses the playlist `owned` flag as the editability signal when available, while retaining the existing private-playlist fallback for compatibility with the currently pinned ytmusicapi response shape. This depends on [ytmusicapi #972](sigma67/ytmusicapi#972) exposing `owned` for library playlists. It is safe to merge before that dependency is released because responses without `owned` keep the existing behavior. A regression test verifies that an owned playlist remains editable when `privacy` is absent. **Related issue (if applicable):** - [ytmusicapi #971](sigma67/ytmusicapi#971) ## Types of changes - [x] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [ ] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [x] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have raised a PR against the documentation repository targeting the main or beta branch as appropriate. Co-authored-by: Marvin Schenkel <marvinschenkel@gmail.com>
Summary
ownedfor playlists parsed from library/grid cardsplaylistEditorEndpointWhy
get_library_playlists()currently drops the edit endpoint contained in the raw playlist card. Downstream clients therefore cannot distinguish an owned playlist from a saved playlist without issuing an extra detail request per item.The new boolean is independent of playlist privacy: public, unlisted, and private playlists can all be editable when owned by the authenticated account.
Closes #971
Downstream
This unblocks the owned-playlist editability fix in music-assistant/server#5187, which is waiting for this change to be merged and released.
Tests