diff --git a/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt b/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt index d2a614be7..9654cb187 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt @@ -152,6 +152,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son rawArtists = rawAlbumArtists .ifEmpty { rawIndividualArtists } + .distinctBy { it.key } .ifEmpty { listOf(RawArtist(null, null)) }) /** @@ -160,7 +161,10 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son * [RawArtist]. This can be used to group up [Song]s into an [Artist]. */ val rawArtists = - rawIndividualArtists.ifEmpty { rawAlbumArtists }.ifEmpty { listOf(RawArtist()) } + rawIndividualArtists + .ifEmpty { rawAlbumArtists } + .distinctBy { it.key } + .ifEmpty { listOf(RawArtist()) } /** * The [RawGenre] instances collated by the [Song]. This can be used to group up [Song]s into a @@ -170,6 +174,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son rawSong.genreNames .parseId3GenreNames(musicSettings) .map { RawGenre(it) } + .distinctBy { it.key } .ifEmpty { listOf(RawGenre()) } /** @@ -208,6 +213,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son checkNotNull(_album) { "Malformed song: No album" } check(_artists.isNotEmpty()) { "Malformed song: No artists" } + check(_artists.size == rawArtists.size) { "Malformed song: Artist grouping mismatch" } for (i in _artists.indices) { // Non-destructively reorder the linked artists so that they align with // the artist ordering within the song metadata. @@ -218,7 +224,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son } check(_genres.isNotEmpty()) { "Malformed song: No genres" } - logD("$this $rawGenres $_genres]") + check(_genres.size == rawGenres.size) { "Malformed song: Genre grouping mismatch"} for (i in _genres.indices) { // Non-destructively reorder the linked genres so that they align with // the genre ordering within the song metadata. @@ -336,6 +342,7 @@ class AlbumImpl( fun finalize(): Album { check(songs.isNotEmpty()) { "Malformed album: Empty" } check(_artists.isNotEmpty()) { "Malformed album: No artists" } + check(_artists.size == rawArtists.size) { "Malformed song: Artist grouping mismatch" } for (i in _artists.indices) { // Non-destructively reorder the linked artists so that they align with // the artist ordering within the song metadata.