feat: artist pictures in the web and Android apps
release / web (push) Successful in 1m59s
release / go (push) Successful in 2m23s
release / govulncheck (push) Successful in 22s
release / integration (push) Successful in 4m59s
release / android (push) Successful in 5m29s
release / Build signed APK (push) Successful in 6m26s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 31s
release / Verify release artifacts (tag releases only) (push) Skipped
release / web (push) Successful in 1m59s
release / go (push) Successful in 2m23s
release / govulncheck (push) Successful in 22s
release / integration (push) Successful in 4m59s
release / android (push) Successful in 5m29s
release / Build signed APK (push) Successful in 6m26s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 31s
release / Verify release artifacts (tag releases only) (push) Skipped
Minstrel fetched artist pictures but showed them only to Subsonic apps.
GET /api/artists/{id}/image now serves the picture, or else the artist's
newest album cover, the same image Subsonic apps get. Artist listings
point at it when the artist has a picture and keep the album cover
otherwise; the artist page points at it whenever the artist has albums,
and the web artist page shows it beside the name.
Android shows the picture for cached artists that have one, and the
album cover for the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import com.fabledsword.minstrel.cache.db.entities.CachedTrackEntity
|
||||
import com.fabledsword.minstrel.models.AlbumRef
|
||||
import com.fabledsword.minstrel.models.ArtistRef
|
||||
import com.fabledsword.minstrel.models.TrackRef
|
||||
import com.fabledsword.minstrel.models.artistImagePath
|
||||
import com.fabledsword.minstrel.models.wire.AlbumDetailWire
|
||||
import com.fabledsword.minstrel.models.wire.AlbumWire
|
||||
import com.fabledsword.minstrel.models.wire.ArtistDetailWire
|
||||
@@ -66,11 +67,14 @@ fun AlbumDetailWire.toAlbumEntity(): CachedAlbumEntity =
|
||||
// source of truth for cache-first reads; mapping to a domain type here
|
||||
// keeps Room types out of the UI layer.
|
||||
|
||||
// An artist whose picture the server fetched shows it; the rest fall back
|
||||
// to an album cover through [coverAlbumId].
|
||||
fun CachedArtistEntity.toDomain(coverAlbumId: String = ""): ArtistRef =
|
||||
ArtistRef(
|
||||
id = id,
|
||||
name = name,
|
||||
sortName = sortName,
|
||||
coverUrl = if (artistThumbPath.isNullOrEmpty()) "" else artistImagePath(id),
|
||||
coverAlbumId = coverAlbumId,
|
||||
)
|
||||
|
||||
|
||||
@@ -9,3 +9,11 @@ package com.fabledsword.minstrel.models
|
||||
*/
|
||||
fun albumCoverPath(albumId: String): String =
|
||||
if (albumId.isEmpty()) "" else "http://placeholder.invalid/api/albums/$albumId/cover"
|
||||
|
||||
/**
|
||||
* Absolute URL of an artist's image, or "" when [artistId] is blank. The
|
||||
* server answers with the artist's picture, or else their newest album
|
||||
* cover, through the same placeholder host as [albumCoverPath].
|
||||
*/
|
||||
fun artistImagePath(artistId: String): String =
|
||||
if (artistId.isEmpty()) "" else "http://placeholder.invalid/api/artists/$artistId/image"
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.fabledsword.minstrel.library.data
|
||||
|
||||
import com.fabledsword.minstrel.cache.db.entities.CachedArtistEntity
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class LibraryMappersTest {
|
||||
@Test
|
||||
fun `a cached artist with a fetched picture shows the artist image`() {
|
||||
val artist = CachedArtistEntity(
|
||||
id = "r1",
|
||||
name = "Tin Orchard",
|
||||
sortName = "Tin Orchard",
|
||||
artistThumbPath = "/data/artist-art/r1/thumb.jpg",
|
||||
).toDomain(coverAlbumId = "a1")
|
||||
assertEquals("http://placeholder.invalid/api/artists/r1/image", artist.displayCoverUrl)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a cached artist without a picture falls back to an album cover`() {
|
||||
val artist = CachedArtistEntity(id = "r1", name = "Tin Orchard", sortName = "Tin Orchard")
|
||||
.toDomain(coverAlbumId = "a1")
|
||||
assertEquals("http://placeholder.invalid/api/albums/a1/cover", artist.displayCoverUrl)
|
||||
}
|
||||
}
|
||||
@@ -13,4 +13,14 @@ class CoverUrlsTest {
|
||||
fun `albumCoverPath is empty for a blank id`() {
|
||||
assertEquals("", albumCoverPath(""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `artistImagePath builds the placeholder artist image URL`() {
|
||||
assertEquals("http://placeholder.invalid/api/artists/r1/image", artistImagePath("r1"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `artistImagePath is empty for a blank id`() {
|
||||
assertEquals("", artistImagePath(""))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user