Album covers, logos and descriptions from the web

- Search online from an album's Edit dialog: covers from TheAudioDB,
  Deezer, Apple Music and the Cover Art Archive, logos from Wikidata,
  Wikimedia Commons and the artist's TheAudioDB logo, and a Wikipedia
  page for the description
- Album pages show the logo and an About section, looked up
  automatically when "Find artist and album info" is on
- Your own logo file and About text, kept in albums.json
- Clean no longer deletes artist or album logos; backups include them
- Artist pages credit the real bio source
- Home shelves show exactly one row instead of peeking into a second
- Window buttons use the native Windows icon font so they stay sharp
  at any display scale
- Web requests identify Atmosphere with its repo link
This commit is contained in:
Christian
2026-11-20 17:25:42 -05:00
parent c5c3357666
commit 6430c1ffc1
11 changed files with 792 additions and 36 deletions
+1 -3
View File
@@ -206,12 +206,10 @@ function bindWindow() {
const api = window.__TAURI__.window;
if (!api?.getCurrentWindow) return;
const win = api.getCurrentWindow();
const restoreSvg = '<svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2.5 2.5V0.5h7v7h-2" /><rect x="0.5" y="2.5" width="7" height="7" /></svg>';
const maxSvg = '<svg viewBox="0 0 10 10" aria-hidden="true"><rect x="0.5" y="0.5" width="9" height="9" /></svg>';
const syncMax = async () => {
const maxed = await win.isMaximized().catch(() => false);
const b = $("#winMax");
b.innerHTML = maxed ? restoreSvg : maxSvg;
b.firstElementChild.textContent = maxed ? "\uE923" : "\uE922";
b.setAttribute("aria-label", maxed ? "Restore" : "Maximize");
b.title = maxed ? "Restore" : "Maximize";
};
+4 -4
View File
@@ -11,9 +11,9 @@
<header class="titlebar" id="titlebar" data-tauri-drag-region>
<div class="tb-drag" data-tauri-drag-region></div>
<div class="tb-controls" id="winControls">
<button class="tb-btn" id="winMin" aria-label="Minimize" title="Minimize"><svg viewBox="0 0 10 10" aria-hidden="true"><path d="M0 5.5h10" /></svg></button>
<button class="tb-btn" id="winMax" aria-label="Maximize" title="Maximize"><svg viewBox="0 0 10 10" aria-hidden="true"><rect x="0.5" y="0.5" width="9" height="9" /></svg></button>
<button class="tb-btn close" id="winClose" aria-label="Close" title="Close"><svg viewBox="0 0 10 10" aria-hidden="true"><path d="M0.5 0.5l9 9M9.5 0.5l-9 9" /></svg></button>
<button class="tb-btn" id="winMin" aria-label="Minimize" title="Minimize"><span class="tb-glyph" aria-hidden="true">&#xE921;</span></button>
<button class="tb-btn" id="winMax" aria-label="Maximize" title="Maximize"><span class="tb-glyph" aria-hidden="true">&#xE922;</span></button>
<button class="tb-btn close" id="winClose" aria-label="Close" title="Close"><span class="tb-glyph" aria-hidden="true">&#xE8BB;</span></button>
</div>
</header>
<div class="shell" id="shell" inert>
@@ -281,7 +281,7 @@
<div class="group" id="libFolders"></div>
<div class="group gap-top">
<div class="setting"><div><strong>Playlist folders live in</strong><span id="playlistsDir"></span></div></div>
<label class="setting"><div><strong>Find artist photos, bios and logos</strong><span>Looks up artist names on Deezer, Wikipedia, Wikidata and TheAudioDB, which need no account or key. Nothing else is sent, and you can change or remove anything on an artist's page.</span></div><input type="checkbox" class="switch" data-key="artistInfo" /></label>
<label class="setting"><div><strong>Find artist and album info</strong><span>Looks up artist photos, bios and logos, and album descriptions and logos, on Deezer, Wikipedia, Wikidata and TheAudioDB, which need no account or key. Only artist and album names are sent. Covers are never changed unless you pick one, and you can edit or remove anything.</span></div><input type="checkbox" class="switch" data-key="artistInfo" /></label>
<div class="setting" id="hiddenSongs"></div>
<label class="setting"><div><strong>Copy songs into playlists</strong><span>Off: songs are hard-linked, so they appear in the folder without using extra space (same drive only). On: real copies, which are best for syncing to phones and USB drives.</span></div><input type="checkbox" class="switch" data-key="playlistCopy" /></label>
</div>
+139 -9
View File
@@ -72,6 +72,8 @@ function buildIndexes(snap) {
a.year ||= t.year;
}
for (const a of albums.values()) a.tracks.sort((x, y) => (x.discNo || 1) - (y.discNo || 1) || (x.trackNo || 999) - (y.trackNo || 999) || x.title.localeCompare(y.title));
const albumMeta = new Map(Object.values(snap.albums || {}).map((m) => [`${lnorm(m.artist)}|${lnorm(m.title)}`, m]));
for (const a of albums.values()) a.meta = albumMeta.get(a.key) || null;
Lib.albums = albums;
const metaByName = new Map(Object.values(snap.artists || {}).map((m) => [lnorm(m.name), m]));
const artists = new Map();
@@ -545,13 +547,56 @@ async function editTracks(tracks, opts = {}) {
const showPreview = (src) => preview.replaceChildren(src ? h("img", { src, alt: "" }) : h("div", { class: "edit-cover-ph" }, icon("photo")));
showPreview(currentArt ? artUrl(currentArt) : null);
const coverNote = h("p", { class: "muted small" }, currentArt ? "Current cover." : tracks.some((t) => t.art) ? "These songs have different covers." : "No cover yet.");
const al = opts.album;
let ameta = al?.meta || {};
const about = al ? h("textarea", { class: "text area", rows: "5", placeholder: `A few lines about this ${kindWord(al)}…` }, ameta.bio || "") : null;
const logoBox = h("div", { class: "edit-logo" });
const drawLogo = () => logoBox.replaceChildren(ameta.logo ? h("img", { class: `artist-logo ${ameta.logoDark ? "dark" : ""}`, src: artUrl(ameta.logo), alt: "" }) : h("span", { class: "muted small" }, "No logo. The title is shown as text."));
const logoAct = (pick) => async () => {
try {
ameta = await invoke("album_media", { artist: al.artist, title: al.title, kind: "logo", pick });
setAlbumMeta(al, ameta);
drawLogo();
} catch (e) {
if (errText(e) !== "cancelled") toast(errText(e), "err");
}
};
const searchFor = (focus) => async () => {
const r = await searchAlbumOnline(al, focus);
if (!r) return;
if (r.cover) {
artwork = { kind: "file", path: r.cover.path };
showPreview(r.cover.dataUrl);
coverNote.textContent = `New cover from ${r.cover.source} for all ${plural(tracks.length, "song")}. It's written into the files when you save.`;
}
if (r.meta) {
ameta = r.meta;
about.value = ameta.bio || "";
drawLogo();
}
};
const searchOnline = al ? h("button", { class: "btn small", type: "button", onclick: searchFor("cover") }, icon("search"), "Search online…") : null;
const coverBox = h("div", { class: "edit-cover-row" }, preview, h("div", { class: "stack" },
h("strong", {}, "Cover art"), coverNote,
h("div", { class: "row" },
h("div", { class: "row wrap" },
searchOnline,
h("button", { class: "btn small", type: "button", onclick: async () => { const p = await invoke("pick_image").catch((x) => (toast(errText(x), "err"), null)); if (p) { artwork = { kind: "file", path: p.path }; showPreview(p.dataUrl); coverNote.textContent = `New cover for all ${plural(tracks.length, "song")}.`; } } }, "Choose image…"),
h("button", { class: "btn small ghost", type: "button", onclick: () => { artwork = { kind: "none" }; showPreview(null); coverNote.textContent = "The cover will be removed from every song."; } }, "Remove"))));
const ok = await modal(title, h("div", { class: "stack" }, coverBox, grid, h("p", { class: "muted small" }, "Changes are written into each file's tags. Fields you leave untouched aren't changed.")), [{ label: "Cancel", value: false }, { label: "Save", value: true, primary: true }]);
drawLogo();
const albumExtras = al ? [
h("div", { class: "stack" }, h("strong", {}, "Logo"), logoBox,
h("div", { class: "row wrap" }, h("button", { class: "btn small", type: "button", onclick: searchFor("logo") }, icon("search"), "Search online…"), h("button", { class: "btn small", type: "button", onclick: logoAct(true) }, "Choose logo…"), h("button", { class: "btn small ghost", type: "button", onclick: logoAct(false) }, "Remove"))),
h("label", { class: "field" }, h("span", {}, "About"), about),
] : [];
const ok = await modal(title, h("div", { class: "stack" }, coverBox, grid, ...albumExtras, h("p", { class: "muted small" }, al ? "Cover and fields are written into each file's tags; fields you leave untouched aren't changed. The logo and description stay in Atmosphere." : "Changes are written into each file's tags. Fields you leave untouched aren't changed.")), [{ label: "Cancel", value: false }, { label: "Save", value: true, primary: true }]);
if (!ok) return;
if (al && about.value !== (ameta.bio || "")) {
try {
setAlbumMeta(al, await invoke("album_update", { artist: al.artist, title: al.title, bio: about.value }));
} catch (e) {
toast(errText(e), "err");
}
}
const meta = { artwork };
for (const [k, , v] of fields) {
const nv = inputs[k].value.trim();
@@ -712,6 +757,85 @@ async function searchArtistOnline(ar) {
}
}
const creditFor = (url) => (/wikipedia\.org/.test(url || "") ? "From Wikipedia, under CC BY-SA" : /theaudiodb\.com/.test(url || "") ? "From TheAudioDB" : "Source");
const AlbumFetch = { asked: new Set() };
function setAlbumMeta(a, meta) {
if (!meta) return;
a.meta = meta;
const al = Lib.albums.get(a.key);
if (al) al.meta = meta;
const r = Lib.route;
if (state.view === "library" && r.name === "album" && r.id === a.key) renderLib(true);
}
async function fetchAlbumInfo(a) {
if (state.settings?.artistInfo === false || a.meta?.checked || AlbumFetch.asked.has(a.key)) return;
AlbumFetch.asked.add(a.key);
try {
setAlbumMeta(a, await invoke("album_fetch", { artist: a.artist, title: a.title, force: false }));
} catch {}
}
async function searchAlbumOnline(a, focus) {
let pick = { cover: null, page: null, logo: null };
const input = h("input", { class: "text wide", type: "search", value: `${a.title} ${a.artist}`, "aria-label": "Search for this album", spellcheck: "false" });
const covers = h("div", { class: "pick-covers" });
const pages = h("div", { class: "pick-pages" });
const logos = h("div", { class: "pick-logos" });
const logoHead = h("strong", { class: "pick-head" }, "Logos from Wikimedia Commons, Wikidata and TheAudioDB");
const status = h("p", { class: "muted small" }, "Searching…");
const run = async () => {
status.textContent = "Searching…";
pick = { cover: null, page: null, logo: null };
const r = await invoke("album_choices", { query: input.value, artist: a.artist, title: a.title }).catch((e) => (status.textContent = errText(e), null));
if (!r) return;
covers.replaceChildren(...r.covers.map((c) => {
const el = h("button", { class: "pick-cover", type: "button", title: `${c.title} · ${c.artist} (${c.source})`, onclick: () => { pick.cover = pick.cover === c ? null : c; $$(".pick-cover", covers).forEach((x) => x.classList.toggle("on", x === el && !!pick.cover)); } },
h("img", { src: c.thumb, alt: "" }), h("span", {}, c.title), h("small", {}, c.source));
return el;
}));
pages.replaceChildren(...r.pages.map((p) => {
const el = h("button", { class: `pick-page ${p.music ? "" : "dim"}`, type: "button", onclick: () => { pick.page = pick.page === p.key ? null : p.key; $$(".pick-page", pages).forEach((x) => x.classList.toggle("on", x === el && !!pick.page)); } },
h("strong", {}, p.title), h("span", {}, p.description || "No description"));
return el;
}));
logos.replaceChildren(...(r.logos.length ? r.logos.map((l) => {
const el = h("button", { class: "pick-logo", type: "button", title: `${l.name} (${l.source})`, onclick: () => { pick.logo = pick.logo === l ? null : l; $$(".pick-logo", logos).forEach((x) => x.classList.toggle("on", x === el && !!pick.logo)); } },
h("img", { src: l.thumb, alt: "" }), h("span", {}, l.name), h("small", {}, l.source));
return el;
}) : [h("p", { class: "muted small" }, "No logos found for this one. You can still choose your own file.")]));
if (focus === "logo") logoHead.scrollIntoView({ block: "start" });
status.textContent = r.covers.length || r.pages.length || r.logos.length ? "Pick a cover, a logo, a Wikipedia page for the description, or any mix." : "Nothing found. Try a different spelling.";
};
input.addEventListener("keydown", (e) => { if (e.key === "Enter") { e.preventDefault(); run(); } });
const body = h("div", { class: "stack" },
h("div", { class: "row" }, input, h("button", { class: "btn", type: "button", onclick: run }, icon("search"), "Search")),
status,
h("strong", { class: "pick-head" }, "Covers from TheAudioDB, Deezer, Apple Music and the Cover Art Archive"), covers,
logoHead, logos,
h("strong", { class: "pick-head" }, "Wikipedia page (for the description)"), pages);
run();
const ok = await modal(`Find ${a.title} online`, body, [{ label: "Cancel", value: false }, { label: "Use these", value: true, primary: true }]);
if (!ok || (!pick.cover && !pick.page && !pick.logo)) return null;
const out = {};
try {
if (pick.cover) out.cover = { ...(await invoke("album_cover_get", { url: pick.cover.full })), source: pick.cover.source };
if (pick.page) {
out.meta = await invoke("album_apply", { artist: a.artist, title: a.title, page: pick.page });
setAlbumMeta(a, out.meta);
}
if (pick.logo) {
out.meta = await invoke("album_logo_set", { artist: a.artist, title: a.title, url: pick.logo.full });
setAlbumMeta(a, out.meta);
}
} catch (e) {
toast(errText(e), "err");
}
return out.cover || out.meta ? out : null;
}
async function editArtist(ar) {
let meta = ar.meta || {};
const bio = h("textarea", { class: "text area", rows: "6", placeholder: "A few lines about this artist…" }, meta.bio || "");
@@ -888,20 +1012,26 @@ function albumView(root, key) {
cover(a.art, "hero-cover", a.title),
h("div", { class: "hero-meta" },
h("div", { class: "kind-line" }, h("span", { class: "kind-btn", style: "cursor:default" }, albumKind(a)), a.year ? h("span", {}, String(a.year)) : null, a.tracks[0]?.genre ? h("span", { class: "sep" }, "·") : null, a.tracks[0]?.genre || null),
h("h1", { class: "hero-title" }, a.title),
a.meta?.logo ? h("h1", { class: "hero-title has-logo" }, h("img", { class: `artist-logo album-logo ${a.meta.logoDark ? "dark" : ""}`, src: artUrl(a.meta.logo), alt: a.title })) : h("h1", { class: "hero-title" }, a.title),
h("button", { class: "link hero-artist", onclick: () => openLib("artist", lnorm(a.artist)) }, a.artist),
h("p", { class: "view-sub" }, `${plural(a.tracks.length, "song")} · ${fmtLong(a.duration)}`),
h("div", { class: "row" }, ...playBtns(a.tracks), h("button", { class: "btn ghost", onclick: (e) => menuAt(e.clientX, e.clientY, playlistItems(a.tracks)()) }, icon("playlist-add"), "Add to playlist"), h("button", { class: "btn ghost", onclick: () => editAlbum(a) }, icon("pencil"), "Edit"))))
);
if (Lib.back.length) root.firstChild.prepend(h("button", { class: "icon-btn back on-hero", "aria-label": "Back", onclick: libBack }, icon("arrow-left")));
const ctx = { hideAlbum: true, hideArtist: !multiArtist, showArtistFor: (t) => lnorm(primaryArtist(t.artist)) !== lnorm(a.artist), numbers: (t, i) => t.trackNo || i + 1 };
if (!discs) return root.append(h("div", { class: "pad-x" }, trackList(a.tracks, ctx)));
const body = h("div", { class: "pad-x" });
for (const d of [...new Set(a.tracks.map((t) => t.discNo || 1))]) {
body.append(h("h3", { class: "disc" }, icon("disc"), `Disc ${d}`));
body.append(trackList(a.tracks.filter((t) => (t.discNo || 1) === d), { ...ctx, list: a.tracks, numbers: (t) => t.trackNo || a.tracks.indexOf(t) + 1 }));
}
if (!discs) body.append(trackList(a.tracks, ctx));
else
for (const d of [...new Set(a.tracks.map((t) => t.discNo || 1))]) {
body.append(h("h3", { class: "disc" }, icon("disc"), `Disc ${d}`));
body.append(trackList(a.tracks.filter((t) => (t.discNo || 1) === d), { ...ctx, list: a.tracks, numbers: (t) => t.trackNo || a.tracks.indexOf(t) + 1 }));
}
const m = a.meta;
body.append(h("section", { class: "about album-about" }, h("h2", { class: "sec" }, "About"),
m?.bio ? h("p", { class: "bio" }, m.bio) : h("button", { class: "link muted", onclick: () => editAlbum(a) }, `Add a description for this ${kindWord(a)}`),
m?.bio && m?.bioSource ? h("button", { class: "link muted small source", onclick: () => invoke("open_link", { url: m.bioSource }).catch(() => {}) }, creditFor(m.bioSource)) : null));
root.append(body);
fetchAlbumInfo(a);
}
function artistCard(ar) {
@@ -945,7 +1075,7 @@ function artistView(root, key) {
if (ar.featured.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Featured on"), h("div", { class: "grid" }, ...ar.featured.map(featuredCard))));
body.append(h("section", { class: "about" }, h("h2", { class: "sec" }, "About"),
ar.meta?.bio ? h("p", { class: "bio" }, ar.meta.bio) : h("button", { class: "link muted", onclick: () => editArtist(ar) }, "Add a bio and photo for this artist"),
ar.meta?.bio && ar.meta?.bioSource ? h("button", { class: "link muted small source", onclick: () => invoke("open_link", { url: ar.meta.bioSource }).catch(() => {}) }, "From Wikipedia, under CC BY-SA") : null));
ar.meta?.bio && ar.meta?.bioSource ? h("button", { class: "link muted small source", onclick: () => invoke("open_link", { url: ar.meta.bioSource }).catch(() => {}) }, creditFor(ar.meta.bioSource)) : null));
if (!ar.meta?.checked) queueArtistInfo([ar.name], true);
root.append(body);
}
+31 -2
View File
@@ -776,7 +776,7 @@ label.setting { cursor: pointer; }
.tb-drag { min-width: 0; }
.tb-controls { display: flex; }
.tb-btn { width: 46px; height: var(--titlebar); display: grid; place-items: center; color: var(--text-2); transition: background-color 100ms var(--ease), color 100ms var(--ease); }
.tb-btn svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1; shape-rendering: crispEdges; }
.tb-glyph { font: 10px/1 "Segoe Fluent Icons", "Segoe MDL2 Assets"; }
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn:active { background: var(--press); }
.tb-btn.close:hover { background: #c42b1c; color: #fff; }
@@ -1115,7 +1115,19 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
.home-hint { margin: 0; }
.sec-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.sec-row .sec { margin: 0; }
.grid.shelf { grid-template-rows: auto; grid-auto-rows: 0; overflow: hidden; row-gap: 0; padding: var(--s2); margin: calc(var(--s2) * -1); }
.shelf-sec { container-type: inline-size; min-width: 0; }
.grid.shelf { padding: var(--s2); margin: calc(var(--s2) * -1); }
@container (width < 2192px) { .grid.shelf > :nth-child(n+12) { display: none; } }
@container (width < 2008px) { .grid.shelf > :nth-child(n+11) { display: none; } }
@container (width < 1824px) { .grid.shelf > :nth-child(n+10) { display: none; } }
@container (width < 1640px) { .grid.shelf > :nth-child(n+9) { display: none; } }
@container (width < 1456px) { .grid.shelf > :nth-child(n+8) { display: none; } }
@container (width < 1272px) { .grid.shelf > :nth-child(n+7) { display: none; } }
@container (width < 1088px) { .grid.shelf > :nth-child(n+6) { display: none; } }
@container (width < 904px) { .grid.shelf > :nth-child(n+5) { display: none; } }
@container (width < 720px) { .grid.shelf > :nth-child(n+4) { display: none; } }
@container (width < 536px) { .grid.shelf > :nth-child(n+3) { display: none; } }
@container (width < 352px) { .grid.shelf > :nth-child(n+2) { display: none; } }
.tile-mosaic { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.tile-mosaic img, .tile-mosaic .cover { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.tile-img.ph { display: grid; place-items: center; background: var(--surface); color: var(--text-3); }
@@ -1239,6 +1251,23 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
.pick-logo img { width: 100%; height: 56px; object-fit: contain; }
.pick-logo.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
/* album cover picker, logo and about */
.row.wrap { flex-wrap: wrap; }
.modal:has(.pick-covers) { max-width: 760px; }
.pick-covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s2); }
.pick-cover { display: grid; gap: 3px; padding: 6px; border-radius: 10px; border: 2px solid transparent; text-align: left; min-width: 0; }
.pick-cover:hover { background: var(--hover); }
.pick-cover.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pick-cover img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.pick-cover span { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-cover small { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-logos > p { grid-column: 1 / -1; margin: 0; }
.pick-logo { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.pick-logo span, .pick-logo small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-logo small { margin-top: -4px; font-size: 11px; color: var(--text-3); }
.album-logo { max-height: 88px; }
.album-about { margin-top: var(--s8); }
/* update notice */
.update-notice { position: fixed; right: var(--s5); bottom: 100px; z-index: 95; width: min(380px, calc(100vw - 32px)); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s2) var(--s3); align-items: start; padding: var(--s4); border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: menuIn 200ms var(--ease); }
.update-notice.out { opacity: 0; transform: translateY(6px); transition: opacity 180ms var(--ease), transform 180ms var(--ease); }