Skip to content

Return one station per stream in lists - #1633

Merged
frenck merged 1 commit into
mainfrom
frenck/deduplicate-stations
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/deduplicate-stations

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

The API stays the same, but stations() and search() can return fewer stations than before: duplicates of a stream are left out by default. Pass deduplicate=False to get every station, as before. Looking stations up by UUID and stations_by_url() are unchanged.

Proposed change

Radio Browser has no way to edit a station, so people add a station again instead. The whole catalog (66,944 records) has 8,669 streams listed more than once, together 13,173 extra records. The worst one is a Quran stream, listed 234 times, in 226 countries. Browsing or searching shows every copy.

Deleting those as corrections (#1604) would take 9,057 entries with the rules we use there, and new duplicates keep coming. So this handles them in the library instead:

  • stations() and search() return one station per stream: the one with the most votes, then the most clicks, in the place where that stream first shows up, so the order of the results holds.
  • Streams count as the same when only the scheme, the case of the host name, or a trailing / or /; (an old Shoutcast trick) differs. The path and the query string are kept as they are.
  • It runs after the corrections, so a corrected stream URL counts.
  • station(), stations_by_uuid() and stations_by_url() return every station, as before. A duplicate someone saved as a favorite, which Home Assistant stores by UUID, keeps working. That is the difference with deleting it.
  • RadioBrowser(deduplicate=False) turns it off.

The limit: only duplicates within one response are found. A page of results can be shorter than limit, and two copies on different pages both show up. The README says so.

Tests cover what counts as the same stream and what does not, which copy stays and where, the two list methods, turning it off, the lookups that keep every station, and a corrected URL that makes two stations the same. The README gets a section on duplicates, and AGENTS.md a gotcha.

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

  • This PR fixes or closes issue: fixes # None
  • This PR is related to: Ship corrections for station data #1604, radiobrowser-api-rust#219, radiobrowser-api-rust#235
  • Link to a separate documentation pull request: None

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.

Many streams are listed more than once, added again by someone who could
not edit the existing station: 8,669 streams across 13,173 extra records
in the catalog. stations() and search() now return one station per
stream, the one with the most votes, then the most clicks. Lookups by
UUID and stations_by_url() still return every one of them, so a saved
station keeps working. Pass deduplicate=False to get every station.
@frenck frenck added the new-feature New features or options. label Oct 2, 2026
@frenck
frenck merged commit dee73c1 into main Oct 2, 2026
31 checks passed
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