feat(web): cache cover art + dedupe Recently Pressed
- Cover art now loads through GET /api/cover/[rgMbid], which fetches from the Cover Art Archive once, caches the image on disk (LYRA_COVER_CACHE, default /tmp/lyra-covers), and serves it with a 30-day Cache-Control — so the browser stops re-fetching it on every Library / Recently-Pressed render. Missing covers get a negative marker (re-checked daily). CoverArt points at the endpoint. - Recently Pressed dedupes by artist+album (re-requesting/re-downloading an album left multiple completed Requests showing the same album repeatedly); newest of each is kept. web 164 tests, tsc + build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
/** Album art from the Cover Art Archive (keyed by release-group MBID), loaded straight from
|
||||
* their CDN by the browser — no backend, no MB API rate limit. Falls back to a placeholder
|
||||
* when there's no MBID or no art. */
|
||||
/** Album art keyed by release-group MBID, served through /api/cover (which caches it on disk +
|
||||
* sends a long Cache-Control, so it isn't re-fetched from the Cover Art Archive on every
|
||||
* Library / Recently-Pressed render). Falls back to a placeholder when there's no MBID or art. */
|
||||
export function CoverArt({
|
||||
rgMbid,
|
||||
alt,
|
||||
@@ -29,7 +29,7 @@ export function CoverArt({
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
className={cls}
|
||||
src={`https://coverartarchive.org/release-group/${rgMbid}/front-${size}`}
|
||||
src={`/api/cover/${rgMbid}?size=${size}`}
|
||||
alt={alt}
|
||||
loading="lazy"
|
||||
onError={() => setFailed(true)}
|
||||
|
||||
Reference in New Issue
Block a user