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