Use the logged-in account for YouTube Music searches - #5896
Conversation
|
✅ The title and description are good to go. Thanks! |
There was a problem hiding this comment.
Pull request overview
Authenticates YouTube Music searches so results respect the user’s account, region, and brand account context.
Changes:
- Passes authentication headers and user context into searches.
- Adds regression coverage for authenticated client construction.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
music_assistant/providers/ytmusic/helpers.py |
Authenticates the search client. |
music_assistant/providers/ytmusic/__init__.py |
Supplies provider account context. |
tests/providers/ytmusic/test_helpers.py |
Tests authenticated search setup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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)
music_assistant/providers/ytmusic/helpers.py:340
- [PROBLEM] This is a user-visible bug fix, but the PR is classified as Maintenance; select the Bugfix checkbox instead so CI applies the correct label and the change appears in the bug-fix release notes.
ytm = ytmusicapi.YTMusic(auth=headers, language=language, user=user)
184d777 to
90eab2d
Compare
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 (2)
music_assistant/providers/ytmusic/init.py:220
- [CRITICAL] This constant only invalidates the old anonymous entries once, but the newly cached results are account-specific: reconfiguring this provider with another username/cookie preserves its
instance_id, and provider reload does not clear that cache (music_assistant/mass.py:1292-1295,1035-1074), so the previous account/region's search results can be served for seven days. Include a non-secret account-context discriminator in the search cache key/checksum, or clear these entries when credentials change.
@use_cache(3600 * 24 * 7, cache_checksum="authenticated_search_v1") # Cache for 7 days
music_assistant/providers/ytmusic/helpers.py:340
- [PROBLEM] This is a user-visible bug fix, but the PR description selects “Maintenance / chore”; because CI derives the release label and release-notes category from that checkbox, select “Bugfix” instead.
ytm = ytmusicapi.YTMusic(auth=headers, language=language, user=user)
What does this implement/fix?
YouTube Music searches were performed without the user's credentials, while every other YTM call already authenticates. Because of that, YouTube could not apply the account and region context to search results, so tracks that are not playable for the user were still returned as regular results (and failed with "No playable items found" when played).
Note: the full fix for the linked issue also needs an upstream ytmusicapi change to expose the availability flag on search results (sigma67/ytmusicapi#1001); this PR is the server-side part and is safe on its own.
Related issue (if applicable):
Types of changes
bugfixnew-featureenhancementnew-providerbreaking-changerefactordocumentationmaintenancecidependenciesChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.