Skip to content

Ship corrections for station data - #1604

Merged
frenck merged 1 commit into
mainfrom
frenck/station-corrections
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/station-corrections

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

None. Corrections are on by default, but they only change stations that have one, and the only one shipped removes a duplicate. Pass corrections=False to get the stations exactly as the API returns them.

Proposed change

Radio Browser has no way to edit a station: the API and the website can only add one. Corrections go through merge requests on the radio-database repository, but that has not merged one since May 2025, and 196 are waiting. Users of this library, like everyone using the Radio Browser integration in Home Assistant, are left with stream URLs that moved, broken favicons and duplicates, with nowhere to get them fixed.

So the library now ships corrections of its own, a bit like quirks in ZHA, but as plain data:

src/radios/corrections/
  schema.json
  fr/radio-odyssey.json
  • A folder per country, and a JSON file per broadcaster or topic, like upstream. Two pull requests for different stations never touch the same file.
  • The format follows radio-database, with the field names of the API, so a correction can travel between the two.
  • A correction matches a station by its UUID, needs a reason, and either deletes the station ("delete": true) or overwrites one or more of name, url, homepage, favicon, tags, countrycode, state, iso_3166_2, language, languagecodes, geo_lat and geo_long.

The corrections are read once, on import, so no file is read in the event loop. They are applied to the API response before it becomes Station objects, for stations(), search(), station(), stations_by_uuid() and stations_by_url(). A corrected url also replaces url_resolved. station_click() still counts the click upstream, and returns the corrected stream URL. RadioBrowser(corrections=False) turns them off.

The test suite validates every shipped file against a probatio schema, checks the folder and file names, and refuses a station corrected in two places. schema.json is generated from the same schema, and a test keeps it in sync, so editors check a file while it is being written. Every other test runs without the shipped corrections, so adding one never breaks an unrelated test.

The first correction is real: Radio Odyssey has two records with the same stream URL, one without tags or language. Its operator asked upstream for that one to be removed (radiobrowser-api-rust#267, no reply). Verified against the live API.

The README, CONTRIBUTING.md and AGENTS.md describe the corrections, and CONTRIBUTING.md how to add one.

Known limits, documented: a page of results is shorter than limit when a station on it is deleted, the station counts of countries, languages and tags come from the API, and stations_by_url() does not find a station by its corrected URL.

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 Radio Browser API has no way to edit a station, and its corrections
repository has not merged a fix since May 2025. Ship corrections with the
library instead: JSON files in a folder per country, in the format of the
upstream radio-database repository, matched to stations by UUID. A
correction deletes a station or overwrites some of its fields, and
station_click() returns the corrected stream URL. Pass corrections=False
to get the stations as the API returns them.

The first correction removes a duplicate of Radio Odyssey, which its
operator asked for upstream.
@frenck frenck added the new-feature New features or options. label Oct 2, 2026
@frenck
frenck merged commit a2e7d83 into main Oct 2, 2026
31 checks passed
This was referenced Oct 2, 2026
@frenck frenck mentioned this pull request Oct 2, 2026
4 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant