Kodi Music Processing Phase 2: Compilations
2,710 Total views across this article’s versions; includes the historical baseline where available.
This article is Part 2 of a 10-part series exploring the Kodi multi-media player's music file scanning and metadata scraping processes via logic flow diagrams.
Discovering Compilations (Part 1)
This historical explanation is checked against Kodi 18.5 (Leia), commit 37f51f6e63cb. The pinned MusicInfoScanner.cpp source is the reference for the branches below. The original research checkout was not recorded; this pin identifies the version checked for this revision.
The tests below are in FileItemsToAlbums(), lines 654–742. They operate on the album-name fallback group for songs without a MusicBrainz album ID. Songs with that ID take the earlier ID-based route. “Various Artists” and “anthology” describe two branches of this code; they are not an exhaustive definition of musical compilations.
For each album-name group, Kodi sorts the songs by their internal track value, checks for duplicates, and records whether all songs carry the compilation flag. A song’s primary artist is the first album-artist name when available, otherwise the first song artist. hasAlbumArtist becomes true if any song has album-artist metadata.
The Various Artists branch requires a nonempty album name and either no overlapping track values or all songs flagged as compilations. It additionally requires one of these artist conditions:
- Exactly one primary-artist key, recognized case-insensitively as “various,” “various artists,” or the localized Various Artists name.
- More than one primary-artist key and no album-artist metadata on any song in the group.
Only that branch replaces the song album-artist lists with the localized Various Artists value. If it fails, a nonempty album name and compilation flags on all songs can still make the album a compilation. That second branch leaves artist determination to the ordinary logic, supporting examples such as a single-artist anthology.
| Illustrative fallback group | Compilation? | Assign Various Artists? |
|---|---|---|
| Named album; every song flagged; one ordinary artist A | Yes — second branch | No; keep ordinary artist determination |
| Named album; distinct track values; artists A and B; no album-artist tags; flags absent | Yes — Various Artists branch | Yes |
| Named album; overlapping track values; artists A and B; no album-artist tags; flags absent | No | No |
| Empty album name; all songs flagged | No in this fallback logic | No |
The original diagram is preserved for comparison. Its immediate “all tracks flagged → Various Artists” path is incorrect: the additional artist conditions still apply. The first example above is a counterexample.
The next article is Phase 3: Common Album Artist Determination.