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:
+27
-7
@@ -90,17 +90,37 @@ func (h *handlers) handleGetCover(w http.ResponseWriter, r *http.Request) {
|
||||
writeErr(w, apiErr)
|
||||
return
|
||||
}
|
||||
path := resolveAlbumCoverPath(r.Context(), q, album)
|
||||
h.serveArt(w, r, resolveAlbumCoverPath(r.Context(), q, album))
|
||||
}
|
||||
|
||||
// handleGetArtistImage implements GET /api/artists/{id}/image: the picture
|
||||
// the artist-art providers fetched, or else the cover of the artist's most
|
||||
// recently added album that has one (coverart.ResolveArtistPath). Subsonic
|
||||
// apps get the same image from getCoverArt.
|
||||
func (h *handlers) handleGetArtistImage(w http.ResponseWriter, r *http.Request) {
|
||||
q := dbq.New(h.pool)
|
||||
artist, apiErr := resolveByID(r, "id", q.GetArtistByID, "artist")
|
||||
if apiErr != nil {
|
||||
writeErr(w, apiErr)
|
||||
return
|
||||
}
|
||||
h.serveArt(w, r, coverart.ResolveArtistPath(r.Context(), q, artist))
|
||||
}
|
||||
|
||||
// serveArt serves the image file at path, or 404 when path is "" or the
|
||||
// file is gone. http.ServeContent gives clients Range, If-Modified-Since and
|
||||
// ETag handling.
|
||||
func (h *handlers) serveArt(w http.ResponseWriter, r *http.Request, path string) {
|
||||
if path == "" {
|
||||
writeErr(w, &apierror.Error{Status: 404, Code: "not_found", Message: "cover not found"})
|
||||
return
|
||||
}
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
// resolveAlbumCoverPath saw the file a moment ago; if it vanished
|
||||
// between stat and open, treat it the same as no-art — the user
|
||||
// experience (404) matches, and 500 would misleadingly imply a server
|
||||
// bug rather than a filesystem race.
|
||||
// The resolver saw the file a moment ago; if it vanished between
|
||||
// stat and open, treat it the same as no art: the user experience
|
||||
// (404) matches, and 500 would misleadingly imply a server bug
|
||||
// rather than a filesystem race.
|
||||
writeErr(w, &apierror.Error{Status: 404, Code: "not_found", Message: "cover not found"})
|
||||
return
|
||||
}
|
||||
@@ -112,8 +132,8 @@ func (h *handlers) handleGetCover(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", imageContentType(path))
|
||||
// Cover bytes change rarely (cover-source enrichment, manual rescan,
|
||||
// rare MBID-driven re-fetch). One-day max-age + must-revalidate means
|
||||
// Art changes rarely (cover-source enrichment, manual rescan, rare
|
||||
// MBID-driven re-fetch). One-day max-age + must-revalidate means
|
||||
// clients skip the conditional GET for the bulk of a session, but
|
||||
// stale art clears within 24h after a re-scan. ServeContent below
|
||||
// still emits Last-Modified for the conditional path when needed.
|
||||
|
||||
Reference in New Issue
Block a user