Genrekort: bara Utforska + YT; popupen visar kortrutnät med artister och låtar
All checks were successful
build-and-push / build (push) Successful in 13s

Utforska-popupen renderar två MusicCard-grids (bilder, Hämta, ▶ YT) —
genrens låtar berikas nu också med artist-mbid/omslag i backend
(cachade uppslag så samma artist inte slås upp dubbelt). Äldre
batcher normaliseras i modalen.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01824ZrvG2mDYYrmwqypLNup
This commit is contained in:
2026-08-01 03:06:04 +02:00
parent 43a41b300e
commit dca6d3ab24
4 changed files with 112 additions and 116 deletions

View File

@@ -282,15 +282,50 @@ export function suggestEngine({ config, store, lidarr, fetchImpl = fetch }) {
async function enrichGenres(rawItems, count, library, likedTitles) {
const libSet = new Set(library.map((n) => n.toLowerCase()))
const likedSet = new Set(likedTitles.map((t) => t.toLowerCase()))
// samma artist slås ofta upp flera gånger (toppartist + låtarnas artister)
const hitCache = new Map()
const cachedHit = async (name) => {
const key = (name ?? '').toLowerCase()
if (!hitCache.has(key)) hitCache.set(key, await lidarrArtistHit(name))
return hitCache.get(key)
}
const out = []
for (const it of rawItems.slice(0, count)) {
const topArtists = []
for (const name of (it.topArtists ?? []).slice(0, 5)) {
if (libSet.has((name ?? '').toLowerCase())) continue
const hit = await lidarrArtistHit(name)
const hit = await cachedHit(name)
if (hit?.inLibrary) continue
topArtists.push({ name, mbid: hit?.mbid ?? null, poster: hit?.poster ?? null })
topArtists.push({
kind: 'artist',
name,
secondary: '',
motivation: '',
year: '',
mbid: hit?.mbid ?? null,
poster: hit?.poster ?? null,
inLibrary: false,
})
}
const topTracks = []
for (const t of (it.topTracks ?? []).filter((t) => !likedSet.has((t.name ?? '').toLowerCase())).slice(0, 5)) {
const hit = await cachedHit(t.artist ?? t.name)
topTracks.push({
kind: 'track',
name: t.name,
secondary: t.artist ?? '',
motivation: '',
year: '',
mbid: hit?.mbid ?? null,
artistMbid: hit?.mbid ?? null,
albumMbid: null,
poster: hit?.poster ?? null,
inLibrary: false,
})
}
out.push({
kind: 'genre',
name: it.name,
@@ -301,10 +336,7 @@ export function suggestEngine({ config, store, lidarr, fetchImpl = fetch }) {
poster: topArtists.find((a) => a.poster)?.poster ?? null,
inLibrary: false,
topArtists,
topTracks: (it.topTracks ?? [])
.filter((t) => !likedSet.has((t.name ?? '').toLowerCase()))
.slice(0, 5)
.map((t) => ({ name: t.name, artist: t.artist ?? '' })),
topTracks,
})
}
return out