all: reformat
This commit is contained in:
parent
5c779f6d89
commit
aa140bebaa
2 changed files with 40 additions and 39 deletions
|
@ -70,9 +70,10 @@ sealed interface Name : Comparable<Name> {
|
|||
final override fun compareTo(other: Name) =
|
||||
when (other) {
|
||||
is Known -> {
|
||||
val result = sortTokens.zip(other.sortTokens).fold(0) { acc, (token, otherToken) ->
|
||||
acc.takeIf { it != 0 } ?: token.compareTo(otherToken)
|
||||
}
|
||||
val result =
|
||||
sortTokens.zip(other.sortTokens).fold(0) { acc, (token, otherToken) ->
|
||||
acc.takeIf { it != 0 } ?: token.compareTo(otherToken)
|
||||
}
|
||||
if (result != 0) result else sortTokens.size.compareTo(other.sortTokens.size)
|
||||
}
|
||||
is Unknown -> 1
|
||||
|
|
|
@ -155,7 +155,7 @@ private class TagWorkerImpl(
|
|||
// Song
|
||||
logD(textFrames)
|
||||
(textFrames["TXXX:musicbrainz release track id"]
|
||||
?: textFrames["TXXX:musicbrainz_releasetrackid"])
|
||||
?: textFrames["TXXX:musicbrainz_releasetrackid"])
|
||||
?.let { rawSong.musicBrainzId = it.first() }
|
||||
textFrames["TIT2"]?.let { rawSong.name = it.first() }
|
||||
textFrames["TSOT"]?.let { rawSong.sortName = it.first() }
|
||||
|
@ -180,9 +180,9 @@ private class TagWorkerImpl(
|
|||
// TODO: Handle dates that are in "January" because the actual specific release date
|
||||
// isn't known?
|
||||
(textFrames["TDOR"]?.run { Date.from(first()) }
|
||||
?: textFrames["TDRC"]?.run { Date.from(first()) }
|
||||
?: textFrames["TDRL"]?.run { Date.from(first()) }
|
||||
?: parseId3v23Date(textFrames))
|
||||
?: textFrames["TDRC"]?.run { Date.from(first()) }
|
||||
?: textFrames["TDRL"]?.run { Date.from(first()) }
|
||||
?: parseId3v23Date(textFrames))
|
||||
?.let { rawSong.date = it }
|
||||
|
||||
// Album
|
||||
|
@ -192,36 +192,38 @@ private class TagWorkerImpl(
|
|||
textFrames["TALB"]?.let { rawSong.albumName = it.first() }
|
||||
textFrames["TSOA"]?.let { rawSong.albumSortName = it.first() }
|
||||
(textFrames["TXXX:musicbrainz album type"]
|
||||
?: textFrames["TXXX:releasetype"] ?:
|
||||
// This is a non-standard iTunes extension
|
||||
textFrames["GRP1"])
|
||||
?: textFrames["TXXX:releasetype"] ?:
|
||||
// This is a non-standard iTunes extension
|
||||
textFrames["GRP1"])
|
||||
?.let { rawSong.releaseTypes = it }
|
||||
|
||||
// Artist
|
||||
(textFrames["TXXX:musicbrainz artist id"] ?: textFrames["TXXX:musicbrainz_artistid"])?.let {
|
||||
rawSong.artistMusicBrainzIds = it
|
||||
}
|
||||
(textFrames["TXXX:artists"] ?: textFrames["TPE1"]
|
||||
?: textFrames["TXXX:artist"])?.let { rawSong.artistNames = it }
|
||||
(textFrames["TXXX:artists"] ?: textFrames["TPE1"] ?: textFrames["TXXX:artist"])?.let {
|
||||
rawSong.artistNames = it
|
||||
}
|
||||
(textFrames["TXXX:artistssort"]
|
||||
?: textFrames["TXXX:artists_sort"] ?: textFrames["TXXX:artists sort"]
|
||||
?: textFrames["TSOP"] ?: textFrames["artistsort"] ?: textFrames["TXXX:artist sort"])
|
||||
?: textFrames["TXXX:artists_sort"] ?: textFrames["TXXX:artists sort"]
|
||||
?: textFrames["TSOP"] ?: textFrames["artistsort"]
|
||||
?: textFrames["TXXX:artist sort"])
|
||||
?.let { rawSong.artistSortNames = it }
|
||||
|
||||
// Album artist
|
||||
(textFrames["TXXX:musicbrainz album artist id"]
|
||||
?: textFrames["TXXX:musicbrainz_albumartistid"])
|
||||
?: textFrames["TXXX:musicbrainz_albumartistid"])
|
||||
?.let { rawSong.albumArtistMusicBrainzIds = it }
|
||||
(textFrames["TXXX:albumartists"]
|
||||
?: textFrames["TXXX:album_artists"] ?: textFrames["TXXX:album artists"]
|
||||
?: textFrames["TPE2"] ?: textFrames["TXXX:albumartist"]
|
||||
?: textFrames["TXXX:album artist"])
|
||||
?: textFrames["TXXX:album_artists"] ?: textFrames["TXXX:album artists"]
|
||||
?: textFrames["TPE2"] ?: textFrames["TXXX:albumartist"]
|
||||
?: textFrames["TXXX:album artist"])
|
||||
?.let { rawSong.albumArtistNames = it }
|
||||
(textFrames["TXXX:albumartistssort"]
|
||||
?: textFrames["TXXX:albumartists_sort"] ?: textFrames["TXXX:albumartists sort"]
|
||||
?: textFrames["TXXX:albumartistsort"]
|
||||
// This is a non-standard iTunes extension
|
||||
?: textFrames["TSO2"] ?: textFrames["TXXX:album artist sort"])
|
||||
?: textFrames["TXXX:albumartists_sort"] ?: textFrames["TXXX:albumartists sort"]
|
||||
?: textFrames["TXXX:albumartistsort"]
|
||||
// This is a non-standard iTunes extension
|
||||
?: textFrames["TSO2"] ?: textFrames["TXXX:album artist sort"])
|
||||
?.let { rawSong.albumArtistSortNames = it }
|
||||
|
||||
// Genre
|
||||
|
@ -229,7 +231,7 @@ private class TagWorkerImpl(
|
|||
|
||||
// Compilation Flag
|
||||
(textFrames["TCMP"] // This is a non-standard itunes extension
|
||||
?: textFrames["TXXX:compilation"] ?: textFrames["TXXX:itunescompilation"])
|
||||
?: textFrames["TXXX:compilation"] ?: textFrames["TXXX:itunescompilation"])
|
||||
?.let {
|
||||
// Ignore invalid instances of this tag
|
||||
if (it.size != 1 || it[0] != "1") return@let
|
||||
|
@ -291,16 +293,14 @@ private class TagWorkerImpl(
|
|||
|
||||
// Track.
|
||||
parseVorbisPositionField(
|
||||
comments["tracknumber"]?.first(),
|
||||
(comments["totaltracks"] ?: comments["tracktotal"] ?: comments["trackc"])?.first()
|
||||
)
|
||||
comments["tracknumber"]?.first(),
|
||||
(comments["totaltracks"] ?: comments["tracktotal"] ?: comments["trackc"])?.first())
|
||||
?.let { rawSong.track = it }
|
||||
|
||||
// Disc and it's subtitle name.
|
||||
parseVorbisPositionField(
|
||||
comments["discnumber"]?.first(),
|
||||
(comments["totaldiscs"] ?: comments["disctotal"] ?: comments["discc"])?.first()
|
||||
)
|
||||
comments["discnumber"]?.first(),
|
||||
(comments["totaldiscs"] ?: comments["disctotal"] ?: comments["discc"])?.first())
|
||||
?.let { rawSong.disc = it }
|
||||
comments["discsubtitle"]?.let { rawSong.subtitle = it.first() }
|
||||
|
||||
|
@ -311,8 +311,8 @@ private class TagWorkerImpl(
|
|||
// 3. Year, as old vorbis tags tended to use this (I know this because it's the only
|
||||
// date tag that android supports, so it must be 15 years old or more!)
|
||||
(comments["originaldate"]?.run { Date.from(first()) }
|
||||
?: comments["date"]?.run { Date.from(first()) }
|
||||
?: comments["year"]?.run { Date.from(first()) })
|
||||
?: comments["date"]?.run { Date.from(first()) }
|
||||
?: comments["year"]?.run { Date.from(first()) })
|
||||
?.let { rawSong.date = it }
|
||||
|
||||
// Album
|
||||
|
@ -331,8 +331,8 @@ private class TagWorkerImpl(
|
|||
}
|
||||
(comments["artists"] ?: comments["artist"])?.let { rawSong.artistNames = it }
|
||||
(comments["artistssort"]
|
||||
?: comments["artists_sort"] ?: comments["artists sort"] ?: comments["artistsort"]
|
||||
?: comments["artist sort"])
|
||||
?: comments["artists_sort"] ?: comments["artists sort"] ?: comments["artistsort"]
|
||||
?: comments["artist sort"])
|
||||
?.let { rawSong.artistSortNames = it }
|
||||
|
||||
// Album artist
|
||||
|
@ -340,12 +340,12 @@ private class TagWorkerImpl(
|
|||
rawSong.albumArtistMusicBrainzIds = it
|
||||
}
|
||||
(comments["albumartists"]
|
||||
?: comments["album_artists"] ?: comments["album artists"]
|
||||
?: comments["albumartist"] ?: comments["album artist"])
|
||||
?: comments["album_artists"] ?: comments["album artists"] ?: comments["albumartist"]
|
||||
?: comments["album artist"])
|
||||
?.let { rawSong.albumArtistNames = it }
|
||||
(comments["albumartistssort"]
|
||||
?: comments["albumartists_sort"] ?: comments["albumartists sort"]
|
||||
?: comments["albumartistsort"] ?: comments["album artist sort"])
|
||||
?: comments["albumartists_sort"] ?: comments["albumartists sort"]
|
||||
?: comments["albumartistsort"] ?: comments["album artist sort"])
|
||||
?.let { rawSong.albumArtistSortNames = it }
|
||||
|
||||
// Genre
|
||||
|
@ -369,10 +369,10 @@ private class TagWorkerImpl(
|
|||
// normally the only tag used for opus files, but some software still writes replay gain
|
||||
// tags anyway.
|
||||
(comments["r128_track_gain"]?.parseR128Adjustment()
|
||||
?: comments["replaygain_track_gain"]?.parseReplayGainAdjustment())
|
||||
?: comments["replaygain_track_gain"]?.parseReplayGainAdjustment())
|
||||
?.let { rawSong.replayGainTrackAdjustment = it }
|
||||
(comments["r128_album_gain"]?.parseR128Adjustment()
|
||||
?: comments["replaygain_album_gain"]?.parseReplayGainAdjustment())
|
||||
?: comments["replaygain_album_gain"]?.parseReplayGainAdjustment())
|
||||
?.let { rawSong.replayGainAlbumAdjustment = it }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue