store playlist duration from the server

This commit is contained in:
austinried
2026-10-04 00:29:53 +00:00
parent fb06653149
commit 9ff1cfa1da
6 changed files with 777 additions and 4 deletions
@@ -45,4 +45,11 @@ val MIGRATION_3_4 =
}
}
val MIGRATIONS: Array<Migration> = arrayOf(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4)
val MIGRATION_4_5 =
object : Migration(4, 5) {
override suspend fun migrate(connection: SQLiteConnection) {
connection.execSQL("ALTER TABLE `playlists` ADD COLUMN `duration` INTEGER NOT NULL DEFAULT 0")
}
}
val MIGRATIONS: Array<Migration> = arrayOf(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5)
@@ -30,7 +30,7 @@ import com.subtracks.data.model.SubsonicSource
PlaybackCursor::class,
ArtworkSeed::class,
],
version = 4,
version = 5,
exportSchema = true,
)
@ColumnTypeConverters(QueueKindConverter::class)
@@ -110,6 +110,7 @@ data class Playlist(
val coverArt: String?,
val songCount: Long,
val created: Long,
@ColumnInfo(defaultValue = "0") val duration: Long = 0,
)
@Entity(
@@ -94,6 +94,7 @@ object SubsonicXml {
coverArt = element.attr("coverArt").ifEmpty { null },
songCount = element.longAttr("songCount") ?: 0L,
created = element.dateAttr("created") ?: 0L,
duration = element.longAttr("duration") ?: 0L,
)
fun playlistSongs(
@@ -119,7 +119,7 @@ private val songColumns =
"genre",
)
private val playlistColumns = listOf("sourceId", "id", "name", "comment", "coverArt", "songCount", "created")
private val playlistColumns = listOf("sourceId", "id", "name", "comment", "coverArt", "songCount", "created", "duration")
private val playlistSongColumns = listOf("sourceId", "playlistId", "songId", "position")
@@ -132,7 +132,7 @@ private fun Album.values() =
private fun Song.values() = listOf<Any?>(sourceId, id, albumId, artistId, title, album, artist, duration, track, disc, starred, genre)
private fun Playlist.values() = listOf<Any?>(sourceId, id, name, comment, coverArt, songCount, created)
private fun Playlist.values() = listOf<Any?>(sourceId, id, name, comment, coverArt, songCount, created, duration)
private fun PlaylistSong.values() = listOf<Any?>(sourceId, playlistId, songId, position)