Matching the same song across Spotify, Apple Music, TIDAL and Deezer
How Melodius merges four music catalogues into one search without merging the wrong tracks: ISRC first, then strict title, version, artist, featuring and duration gates.
Search in Melodius asks Spotify, Apple Music, TIDAL and Deezer at once and shows one list. Without matching, every popular song appears four times. With careless matching, a live version, a remix or a clean edit gets folded into the original and becomes impossible to find. This is the matcher that decides whether two results are the same recording.
One list, no duplicates, no wrong merges
The two failure modes are not equally bad. A missed merge shows a duplicate, which is ugly. A wrong merge hides a song, which is a bug the listener cannot work around. So the matcher is deliberately conservative: it merges on an ISRC, or when every one of several strict metadata checks agrees. Title plus artist alone never merges.
The result is a verdict with a reason, which makes every decision testable:
type MatchVerdict =
| { same: true; method: "isrc" | "metadata" }
| { same: false; reason: "isrc" | "title" | "version" | "artist" | "featured" | "duration" | "explicit" };ISRC first, but not blindly
An ISRC is the international code assigned to a specific recording. When both tracks have one, it decides: different codes are different recordings. Equal codes still have to pass two checks, because catalogues are not perfect. Durations must be within five seconds, and an explicit track never merges with a clean one, even under the same code.
Normalising text
Before comparing anything, text is reduced to a stable form: Unicode-normalised, accents removed, lowercased, punctuation turned into spaces.
const normalizeText = (value: string) =>
value
.normalize("NFKC")
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.replace(/[^\p{L}\p{N}\s]/gu, " ")
.replace(/\s+/g, " ")
.trim();Artist credits are split on commas, ampersands, "and" and "x", and a leading "The" is dropped, so "The Weeknd" and "Weeknd" compare equal.
Reading a title
Titles carry information in brackets and after dashes, and the matcher has to know which parts change the recording. Each decoration is classified into one of four kinds:
- Neutral: "Remastered 2011", "Official Audio", "Lyric Video", "From the film…". Removed.
- Featuring credits: "feat.", "ft.", "with". Moved into the artist list.
- Explicit or clean: kept as a hint.
- Everything else, such as "Live" or "Chromatics Remix": kept as a version marker.
Parsing a title gives a key (the bare title), a sorted version string (empty for the original), the featured artists and the explicit hint. "Blinding Lights (Remastered)" and "Blinding Lights" share a key and version. "Blinding Lights (Chromatics Remix)" shares the key but not the version, so it stays separate.
The metadata gates
Without ISRCs on both sides, two tracks merge only if all of these hold, checked in order:
- The title keys are equal and not empty.
- The version markers are equal.
- Every artist on the shorter credit list appears on the longer one, counting featured artists from the title.
- Each side's featured artists appear somewhere in the other side's credits.
- Durations are within three seconds, tighter than the ISRC path.
- They do not disagree on explicit versus clean.
Why conservative wins
Every rule above exists because a looser version merged something it should not have. The verdict reasons make that visible in tests: when a pair fails to merge, the test says whether it was the version, the artist or the duration, and a fix for one case cannot silently break another.
Matching is also what lets playback work. Once a track is identified, Melodius finds playable copies and starts the fastest one, which I wrote about in making a track start fast. You can try the search itself at melodius.in.
