mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-12-22 20:57:54 +01:00
Metadata Inclusion Fixes
This commit is contained in:
parent
92fb11a252
commit
f323021bac
@ -28,6 +28,8 @@ data class TrackDetails(
|
||||
var artists: List<String>,
|
||||
var durationSec: Int,
|
||||
var albumName: String? = null,
|
||||
var albumArtists: List<String> = emptyList(),
|
||||
var genre: List<String> = emptyList(),
|
||||
var year: String? = null,
|
||||
var comment: String? = null,
|
||||
var lyrics: String? = null,
|
||||
|
@ -48,13 +48,14 @@ fun Mp3File.setId3v1Tags(track: TrackDetails): Mp3File {
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails) {
|
||||
val id3v2Tag = ID3v24Tag().apply {
|
||||
|
||||
albumArtist = track.albumArtists.joinToString(", ")
|
||||
artist = track.artists.joinToString(", ")
|
||||
title = track.title
|
||||
album = track.albumName
|
||||
year = track.year
|
||||
comment = "Genres:${track.comment}"
|
||||
lyrics = "Gonna Implement Soon"
|
||||
genreDescription = "Genre: " + track.genre.joinToString(", ")
|
||||
comment = track.comment
|
||||
lyrics = track.lyrics ?: ""
|
||||
url = track.trackUrl
|
||||
}
|
||||
try {
|
||||
|
@ -126,6 +126,7 @@ class GaanaProvider(
|
||||
durationSec = it.duration,
|
||||
albumArtPath = dir.imageCacheDir() + (it.artworkLink.substringBeforeLast('/').substringAfterLast('/')) + ".jpeg",
|
||||
albumName = it.album_title,
|
||||
genre = it.genre?.mapNotNull { genre -> genre?.name } ?: emptyList(),
|
||||
year = it.release_date,
|
||||
comment = "Genres:${it.genre?.map { genre -> genre?.name }?.reduceOrNull { acc, s -> acc + s }}",
|
||||
trackUrl = it.lyrics_url,
|
||||
|
@ -30,8 +30,6 @@ import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.SpotiFlyerException
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
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.Source
|
||||
import com.shabinder.common.models.spotify.Track
|
||||
@ -133,15 +131,7 @@ class SpotifyProvider(
|
||||
val albumObject = getAlbum(link)
|
||||
folderType = "Albums"
|
||||
subFolder = albumObject.name.toString()
|
||||
albumObject.tracks?.items?.forEach {
|
||||
it.album = Album(
|
||||
images = listOf(
|
||||
Image(
|
||||
url = albumObject.images?.elementAtOrNull(0)?.url
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
albumObject.tracks?.items?.forEach { it.album = albumObject }
|
||||
|
||||
albumObject.tracks?.items?.toTrackDetailsList(folderType, subFolder).let {
|
||||
if (it.isNullOrEmpty()) {
|
||||
@ -210,7 +200,9 @@ class SpotifyProvider(
|
||||
private fun List<Track>.toTrackDetailsList(type: String, subFolder: String) = this.map {
|
||||
TrackDetails(
|
||||
title = it.name.toString(),
|
||||
genre = it.album?.genres?.filterNotNull() ?: emptyList(),
|
||||
artists = it.artists?.map { artist -> artist?.name.toString() } ?: listOf(),
|
||||
albumArtists = it.album?.artists?.mapNotNull { artist -> artist?.name } ?: emptyList(),
|
||||
durationSec = (it.duration_ms / 1000).toInt(),
|
||||
albumArtPath = dir.imageCacheDir() + (it.album?.images?.firstOrNull()?.url.toString()).substringAfterLast('/') + ".jpeg",
|
||||
albumName = it.album?.name,
|
||||
|
Loading…
Reference in New Issue
Block a user