musikr.tag: handle compilation flag
This commit is contained in:
parent
3431e13cde
commit
fddd527975
2 changed files with 20 additions and 13 deletions
|
@ -205,18 +205,16 @@ internal fun Metadata.genreNames() = xiph["GENRE"] ?: mp4["©gen"] ?: mp4["gnre"
|
|||
// Compilation Flag
|
||||
internal fun Metadata.isCompilation() =
|
||||
// TCMP is a non-standard itunes extension
|
||||
// We also only look for tags that are actually valid
|
||||
// (i.e. 1 for true, 0 for false)
|
||||
(xiph["COMPILATION"]
|
||||
?: xiph["ITUNESCOMPILATION"]
|
||||
?: mp4["cpil"]
|
||||
?: mp4["----:COM.APPLE.ITUNES:COMPILATION"]
|
||||
?: mp4["----:COM.APPLE.ITUNES:ITUNESCOMPILATION"]
|
||||
?: id3v2["TCMP"]
|
||||
?: id3v2["TXXX:COMPILATION"]
|
||||
?: id3v2["TXXX:ITUNESCOMPILATION"])
|
||||
?.let {
|
||||
// Ignore invalid instances of this tag
|
||||
it == listOf("1")
|
||||
}
|
||||
?: xiph["ITUNESCOMPILATION"]
|
||||
?: mp4["cpil"]
|
||||
?: mp4["----:COM.APPLE.ITUNES:COMPILATION"]
|
||||
?: mp4["----:COM.APPLE.ITUNES:ITUNESCOMPILATION"]
|
||||
?: id3v2["TCMP"]
|
||||
?: id3v2["TXXX:COMPILATION"]
|
||||
?: id3v2["TXXX:ITUNESCOMPILATION"]) == listOf("1")
|
||||
|
||||
// ReplayGain information
|
||||
internal fun Metadata.replayGainTrackAdjustment() =
|
||||
|
|
|
@ -32,6 +32,7 @@ internal interface TagParser {
|
|||
|
||||
private data object TagParserImpl : TagParser {
|
||||
override fun parse(file: DeviceFile, metadata: Metadata): ParsedTags {
|
||||
val compilation = metadata.isCompilation()
|
||||
return ParsedTags(
|
||||
durationMs = metadata.properties.durationMs,
|
||||
replayGainTrackAdjustment = metadata.replayGainTrackAdjustment(),
|
||||
|
@ -46,12 +47,20 @@ private data object TagParserImpl : TagParser {
|
|||
albumMusicBrainzId = metadata.albumMusicBrainzId(),
|
||||
albumName = metadata.albumName(),
|
||||
albumSortName = metadata.albumSortName(),
|
||||
releaseTypes = metadata.releaseTypes() ?: listOf(),
|
||||
// Compilation flag implies a compilation release type in the case that
|
||||
// we don't have any other release types
|
||||
releaseTypes =
|
||||
metadata.releaseTypes() ?: listOf("compilation").takeIf { compilation } ?: listOf(),
|
||||
artistMusicBrainzIds = metadata.artistMusicBrainzIds() ?: listOf(),
|
||||
artistNames = metadata.artistNames() ?: listOf(),
|
||||
artistSortNames = metadata.artistSortNames() ?: listOf(),
|
||||
albumArtistMusicBrainzIds = metadata.albumArtistMusicBrainzIds() ?: listOf(),
|
||||
albumArtistNames = metadata.albumArtistNames() ?: listOf(),
|
||||
// Compilation pretty heavily implies various artists in the case that we don't
|
||||
// have any other album artists
|
||||
albumArtistNames =
|
||||
metadata.albumArtistNames()
|
||||
?: listOf("Various Artists").takeIf { compilation }
|
||||
?: listOf(),
|
||||
albumArtistSortNames = metadata.albumArtistSortNames() ?: listOf(),
|
||||
genreNames = metadata.genreNames() ?: listOf())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue