Metadata TrackNumber Inclusion when Available

This commit is contained in:
shabinder 2021-07-11 11:17:36 +05:30
parent f323021bac
commit 67a07dba49
3 changed files with 7 additions and 0 deletions

View File

@ -30,6 +30,7 @@ data class TrackDetails(
var albumName: String? = null,
var albumArtists: List<String> = emptyList(),
var genre: List<String> = emptyList(),
var trackNumber: Int? = null,
var year: String? = null,
var comment: String? = null,
var lyrics: String? = null,

View File

@ -40,6 +40,8 @@ fun Mp3File.setId3v1Tags(track: TrackDetails): Mp3File {
album = track.albumName
year = track.year
comment = "Genres:${track.comment}"
if(track.trackNumber != null)
this.track = track.trackNumber.toString()
}
this.id3v1Tag = id3v1Tag
return this
@ -53,10 +55,13 @@ suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails) {
title = track.title
album = track.albumName
year = track.year
genreDescription = "Genre: " + track.genre.joinToString(", ")
comment = track.comment
lyrics = track.lyrics ?: ""
url = track.trackUrl
if(track.trackNumber != null)
this.track = track.trackNumber.toString()
}
try {
val art = File(track.albumArtPath)

View File

@ -200,6 +200,7 @@ class SpotifyProvider(
private fun List<Track>.toTrackDetailsList(type: String, subFolder: String) = this.map {
TrackDetails(
title = it.name.toString(),
trackNumber = it.track_number,
genre = it.album?.genres?.filterNotNull() ?: emptyList(),
artists = it.artists?.map { artist -> artist?.name.toString() } ?: listOf(),
albumArtists = it.album?.artists?.mapNotNull { artist -> artist?.name } ?: emptyList(),