Skip to content

Commit d4fdd86

Browse files
Fix editability for owned YouTube Music playlists (#5187)
# 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>
1 parent 7fc184d commit d4fdd86

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎music_assistant/providers/ytmusic/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ def _parse_playlist(self, playlist_obj: dict[str, Any]) -> Playlist:
954954
raw_playlist_id = playlist_obj["id"]
955955
playlist_id = raw_playlist_id
956956
playlist_name = playlist_obj["title"]
957-
is_editable = playlist_obj.get("privacy", "") == "PRIVATE"
957+
is_editable = playlist_obj.get("owned", playlist_obj.get("privacy", "") == "PRIVATE")
958958
# Playlist ID's are not unique across instances for lists like 'Likes', 'Supermix', etc.
959959
# So suffix with the instance id to make them unique
960960
if playlist_id in YT_PERSONAL_PLAYLISTS:

‎tests/providers/ytmusic/test_ytmusic.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,18 @@ async def test_sync_library_keeps_other_errors_silent(provider: YoutubeMusicProv
9292
):
9393
await provider.sync_library(MediaType.PLAYLIST)
9494
provider.unload_with_error.assert_not_called()
95+
96+
97+
def test_parse_owned_playlist_is_editable_without_privacy(
98+
provider: YoutubeMusicProvider,
99+
) -> None:
100+
"""An owned playlist is editable even when the library response omits privacy."""
101+
playlist = provider._parse_playlist(
102+
{
103+
"id": "PL_owned",
104+
"title": "Owned playlist",
105+
"owned": True,
106+
}
107+
)
108+
109+
assert playlist.is_editable is True

0 commit comments

Comments
 (0)