feat(subsonic): artist pictures in Subsonic apps
release / go (push) Successful in 1m47s
release / web (push) Successful in 1m10s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m3s
release / android (push) Successful in 4m27s
release / Build signed APK (push) Successful in 5m2s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 17s
release / Verify release artifacts (tag releases only) (push) Skipped

getCoverArt now answers an artist's id: the artist picture Minstrel
fetched, when its file is there, or else the cover of the artist's most
recently added album that has one, which is what Minstrel's own artist
cards show. Every artist entry carries its id as coverArt, so apps ask.

The lookup is coverart.ResolveArtistPath, beside the album one, and looks
through at most ten of an artist's albums for a cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 18:20:30 -05:00
co-authored by Claude Opus 5.5
parent 6dfa7b25fb
commit 1965e82013
6 changed files with 149 additions and 17 deletions
+35
View File
@@ -7,9 +7,11 @@
package coverart
import (
"cmp"
"context"
"os"
"path/filepath"
"slices"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
)
@@ -57,3 +59,36 @@ func ResolveAlbumPath(ctx context.Context, q *dbq.Queries, album dbq.Album) stri
}
return FindSidecar(filepath.Dir(tracks[0].FilePath))
}
// artistAlbumsTried bounds how many of an artist's albums ResolveArtistPath
// looks through for a cover, so an artist with many coverless albums costs a
// few lookups rather than one per album.
const artistAlbumsTried = 10
// ResolveArtistPath returns the image file to show for an artist: the
// artist picture the artist-art providers fetched, if its file is there, or
// else the cover of the artist's most recently added album that has one,
// which is what Minstrel's artist cards show. "" means no image was found.
func ResolveArtistPath(ctx context.Context, q *dbq.Queries, artist dbq.Artist) string {
if artist.ArtistThumbPath != nil && *artist.ArtistThumbPath != "" {
if _, err := os.Stat(*artist.ArtistThumbPath); err == nil {
return *artist.ArtistThumbPath
}
}
albums, err := q.ListAlbumsByArtist(ctx, artist.ID)
if err != nil {
return ""
}
slices.SortStableFunc(albums, func(a, b dbq.Album) int {
return cmp.Compare(b.CreatedAt.Time.UnixNano(), a.CreatedAt.Time.UnixNano())
})
for i, album := range albums {
if i == artistAlbumsTried {
break
}
if path := ResolveAlbumPath(ctx, q, album); path != "" {
return path
}
}
return ""
}