Skip to content

Expose ownership for library playlists - #972

Merged
sigma67 merged 6 commits into
sigma67:mainfrom
seppegadeyne:fix/library-playlist-owned
Aug 8, 2026
Merged

Expose ownership for library playlists#972
sigma67 merged 6 commits into
sigma67:mainfrom
seppegadeyne:fix/library-playlist-owned

Conversation

@seppegadeyne

@seppegadeyne seppegadeyne commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose owned for playlists parsed from library/grid cards
  • derive ownership from the language-independent playlistEditorEndpoint
  • document the new return field and correct the library return description
  • add parser tests for owned and saved playlists

Why

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

pytest -o addopts='' tests/parsers -q
36 passed

pre-commit run --files ytmusicapi/parsers/browsing.py ytmusicapi/mixins/library.py tests/parsers/test_browsing.py
ruff: passed
ruff format: passed
mypy: passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: bool field to parse_playlist() derived from the presence of a matching playlistEditorEndpoint.playlistId.
  • Update get_library_playlists() docstring to describe library playlists (not only owned) and document the new owned field.
  • 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.

Comment thread tests/parsers/test_browsing.py Outdated
Copilot AI review requested due to automatic review settings August 3, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 count as an int (5), but parse_playlist() sets count to nav(...).split(' ')[0], which returns a string (e.g. '5'). This can mislead API consumers about the return type.
                'count': 5,

Copilot AI review requested due to automatic review settings August 3, 2026 08:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

# Conflicts:
#	tests/parsers/test_browsing.py
#	ytmusicapi/parsers/browsing.py
Copilot AI review requested due to automatic review settings August 8, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Copilot AI review requested due to automatic review settings August 8, 2026 17:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (488d39b) to head (b452698).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
unittests 95.78% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

…owned

# Conflicts:
#	tests/parsers/test_browsing.py
Copilot AI review requested due to automatic review settings August 8, 2026 18:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@sigma67
sigma67 merged commit 8d43d07 into sigma67:main Aug 8, 2026
5 checks passed
MarvinSchenkel added a commit to music-assistant/server that referenced this pull request Aug 17, 2026
# 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_library_playlists omits playlist ownership metadata

3 participants