Metadata Inclusion Fixes

This commit is contained in:
shabinder 2021-07-11 11:04:51 +05:30
parent 92fb11a252
commit f323021bac
4 changed files with 10 additions and 14 deletions

View File

@ -28,6 +28,8 @@ data class TrackDetails(
var artists: List<String>, var artists: List<String>,
var durationSec: Int, var durationSec: Int,
var albumName: String? = null, var albumName: String? = null,
var albumArtists: List<String> = emptyList(),
var genre: List<String> = emptyList(),
var year: String? = null, var year: String? = null,
var comment: String? = null, var comment: String? = null,
var lyrics: String? = null, var lyrics: String? = null,

View File

@ -48,13 +48,14 @@ fun Mp3File.setId3v1Tags(track: TrackDetails): Mp3File {
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails) { suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails) {
val id3v2Tag = ID3v24Tag().apply { val id3v2Tag = ID3v24Tag().apply {
albumArtist = track.albumArtists.joinToString(", ")
artist = track.artists.joinToString(", ") artist = track.artists.joinToString(", ")
title = track.title title = track.title
album = track.albumName album = track.albumName
year = track.year year = track.year
comment = "Genres:${track.comment}" genreDescription = "Genre: " + track.genre.joinToString(", ")
lyrics = "Gonna Implement Soon" comment = track.comment
lyrics = track.lyrics ?: ""
url = track.trackUrl url = track.trackUrl
} }
try { try {

View File

@ -126,6 +126,7 @@ class GaanaProvider(
durationSec = it.duration, durationSec = it.duration,
albumArtPath = dir.imageCacheDir() + (it.artworkLink.substringBeforeLast('/').substringAfterLast('/')) + ".jpeg", albumArtPath = dir.imageCacheDir() + (it.artworkLink.substringBeforeLast('/').substringAfterLast('/')) + ".jpeg",
albumName = it.album_title, albumName = it.album_title,
genre = it.genre?.mapNotNull { genre -> genre?.name } ?: emptyList(),
year = it.release_date, year = it.release_date,
comment = "Genres:${it.genre?.map { genre -> genre?.name }?.reduceOrNull { acc, s -> acc + s }}", comment = "Genres:${it.genre?.map { genre -> genre?.name }?.reduceOrNull { acc, s -> acc + s }}",
trackUrl = it.lyrics_url, trackUrl = it.lyrics_url,

View File

@ -30,8 +30,6 @@ import com.shabinder.common.models.PlatformQueryResult
import com.shabinder.common.models.SpotiFlyerException import com.shabinder.common.models.SpotiFlyerException
import com.shabinder.common.models.TrackDetails import com.shabinder.common.models.TrackDetails
import com.shabinder.common.models.event.coroutines.SuspendableEvent import com.shabinder.common.models.event.coroutines.SuspendableEvent
import com.shabinder.common.models.spotify.Album
import com.shabinder.common.models.spotify.Image
import com.shabinder.common.models.spotify.PlaylistTrack import com.shabinder.common.models.spotify.PlaylistTrack
import com.shabinder.common.models.spotify.Source import com.shabinder.common.models.spotify.Source
import com.shabinder.common.models.spotify.Track import com.shabinder.common.models.spotify.Track
@ -133,15 +131,7 @@ class SpotifyProvider(
val albumObject = getAlbum(link) val albumObject = getAlbum(link)
folderType = "Albums" folderType = "Albums"
subFolder = albumObject.name.toString() subFolder = albumObject.name.toString()
albumObject.tracks?.items?.forEach { albumObject.tracks?.items?.forEach { it.album = albumObject }
it.album = Album(
images = listOf(
Image(
url = albumObject.images?.elementAtOrNull(0)?.url
)
)
)
}
albumObject.tracks?.items?.toTrackDetailsList(folderType, subFolder).let { albumObject.tracks?.items?.toTrackDetailsList(folderType, subFolder).let {
if (it.isNullOrEmpty()) { if (it.isNullOrEmpty()) {
@ -210,7 +200,9 @@ class SpotifyProvider(
private fun List<Track>.toTrackDetailsList(type: String, subFolder: String) = this.map { private fun List<Track>.toTrackDetailsList(type: String, subFolder: String) = this.map {
TrackDetails( TrackDetails(
title = it.name.toString(), title = it.name.toString(),
genre = it.album?.genres?.filterNotNull() ?: emptyList(),
artists = it.artists?.map { artist -> artist?.name.toString() } ?: listOf(), artists = it.artists?.map { artist -> artist?.name.toString() } ?: listOf(),
albumArtists = it.album?.artists?.mapNotNull { artist -> artist?.name } ?: emptyList(),
durationSec = (it.duration_ms / 1000).toInt(), durationSec = (it.duration_ms / 1000).toInt(),
albumArtPath = dir.imageCacheDir() + (it.album?.images?.firstOrNull()?.url.toString()).substringAfterLast('/') + ".jpeg", albumArtPath = dir.imageCacheDir() + (it.album?.images?.firstOrNull()?.url.toString()).substringAfterLast('/') + ".jpeg",
albumName = it.album?.name, albumName = it.album?.name,