Skip to content

Fix station search parameters and add search filters - #1552

Merged
frenck merged 1 commit into
mainfrom
frenck/fix-search-params
Sep 30, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/fix-search-params

Conversation

@frenck

@frenck frenck commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Breaking change

None. The exact-match and bitrate filters never worked and filter_by on search() always failed, so nothing that worked before behaves differently. Callers that already passed those filters will now get the filtered results they asked for.

Proposed change

Station search was broken in three ways:

  • The exact-match and bitrate filters were sent in snake_case (name_exact, bitrate_min), while the API expects camelCase. The API ignores unknown parameters without an error, so these filters silently did nothing.
  • filter_by built paths like stations/search/bycountrycodeexact/NL. The search endpoint has no such paths, so that always returned a 404.
  • Calling search() without a name crashed, because None was passed as a query value and yarl rejects that.

Checked against the live API:

GET /json/stations/search?name=538&name_exact=true  -> 23 stations
GET /json/stations/search?name=538&nameExact=true   -> 1 station
GET /json/stations/search/bycountrycodeexact/NL     -> 404

This PR sends the parameter names the API expects, translates filter_by into search query parameters (raising ValueError for FilterBy.UUID, FilterBy.CODEC, or a missing filter_term), adds country_code, state, language and tag filters, and leaves unset filters out of the query. The Radio Browser media source in Home Assistant needs those filters to search inside a country, language or tag folder.

This combines #1549 and #1550 into a single change on top of the tooling update from #1551, since both touched the same code and conflicted with main and with each other.

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

The search endpoint silently ignored the exact-match and bitrate filters,
because they were sent in snake_case while the API expects camelCase.
Searching with filter_by always failed, since the search endpoint has no
by* paths. Calling search() without a name crashed on a None query value.

- Send nameExact, countryExact, stateExact, languageExact, tagExact,
  bitrateMin and bitrateMax.
- Translate filter_by into search query parameters; raise ValueError for
  values the search endpoint cannot express.
- Add country_code, state, language and tag filters.
- Leave unset filters out of the query.

Based on #1549 and #1550.
@frenck frenck added bugfix Inconsistencies or issues which will cause a problem for users or implementers. new-feature New features or options. labels Sep 30, 2026
@frenck
frenck merged commit 2fc8880 into main Sep 30, 2026
30 checks passed
@frenck frenck mentioned this pull request Sep 30, 2026
4 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers. new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant