Skip to content

Parse isAvailable for song/video search results - #1001

Merged
sigma67 merged 2 commits into
sigma67:mainfrom
MarvinSchenkel:search-isavailable
Aug 27, 2026
Merged

Parse isAvailable for song/video search results#1001
sigma67 merged 2 commits into
sigma67:mainfrom
MarvinSchenkel:search-isavailable

Conversation

@MarvinSchenkel

Copy link
Copy Markdown
Contributor

Search results currently carry no availability signal: when YouTube Music marks an item as unavailable for the requesting account or region, it sets musicItemRendererDisplayPolicy: MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT on the musicResponsiveListItemRenderer (the item shows greyed out in the web client). The playlist parser already translates this into isAvailable, but parse_search_result ignores it, so consumers treat every search hit as playable and only find out when playback fails (see music-assistant/support#6154 for a downstream report).

Changes:

  • parse_search_result now sets isAvailable on song and video results, mirroring the existing logic in parsers/playlists.py (defaults to true).
  • Documented the new field in the search() docstring examples.
  • Added pure-unit parser tests in tests/parsers/test_search.py.

pytest tests/parsers/ passes (59 tests, 4 new); ruff and mypy are clean on the touched files. I couldn't extend the live-API search tests as I have no way to reliably trigger a greyed-out result across accounts/regions.

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 availability signal (isAvailable) to parsed song/video search results so consumers can detect greyed-out (unplayable) items up front, aligning search parsing behavior with existing playlist parsing.

Changes:

  • Parse musicItemRendererDisplayPolicy in parse_search_result() and expose it as isAvailable for song/video results (defaulting to True).
  • Update search() docstring examples to include the new field.
  • Add unit tests covering default/greyed-out/other-policy behaviors for parse_search_result().

Reviewed changes

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

File Description
ytmusicapi/parsers/search.py Adds isAvailable parsing for song/video items in parse_search_result().
ytmusicapi/mixins/search.py Documents isAvailable in search() example output.
tests/parsers/test_search.py Adds unit tests validating isAvailable behavior in the search result parser.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ytmusicapi/mixins/search.py Outdated
Comment thread ytmusicapi/parsers/search.py

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.

MarvinSchenkel added a commit to music-assistant/server that referenced this pull request Aug 21, 2026
# 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).

- Pass the account headers and (brand account) user to the ytmusicapi
search call, like all other YTM helpers already do.
- Add a regression test that verifies search authenticates its client.

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):**

- related issue music-assistant/support#6154

## Types of changes

<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives
the label from the ticked box and applies it automatically; the
release-notes generator uses that same label to slot this change
into the next release notes.
-->

- [ ] 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`
- [x] 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](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.

@sigma67 sigma67 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good - parser-only change, defaults to available and only flips on the grey-out policy. Thanks!

@sigma67
sigma67 merged commit d69e7a1 into sigma67:main Aug 27, 2026
3 of 4 checks passed
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.

3 participants