Web: keep real playlist art in downloads, hide quota on HTTPS
The group art fetch now falls back to the raw composite when the Plex transcode fails, and the Downloads card uses any stored group art. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ef4c650d1
commit
536de29e4d
2 files changed
+11
-5
No files matched your search
+6
-4
@@ -817,6 +817,8 @@ function trackMenu(x, y, listId, i) {
|
||||
]);
|
||||
}
|
||||
async function leaves(srv, key) { return ((await px(srv, `/library/metadata/${key}/allLeaves`)).Metadata || []).map(m => track(srv, m)); }
|
||||
// The image's current src plus its fallback (Plex playlist composites often fail to transcode).
|
||||
const artUrls = im => im ? [im.src, im.getAttribute("data-fb")].filter(u => u && !u.startsWith("data:")) : [];
|
||||
function listMenu(x, y, get, group = null) {
|
||||
const run = fn => async () => { try { fn(visible(await get())); } catch (e) { toast(e.message); } };
|
||||
Menu.open(x, y, [
|
||||
@@ -971,7 +973,7 @@ function dlGroups(recs) {
|
||||
const blobUrl = b => b instanceof Blob ? (dlUrls.push(URL.createObjectURL(b)), dlUrls.at(-1)) : "";
|
||||
const tile = ({ g, recs, n }) => {
|
||||
const t = recs[0].track, h = g.href, songs = plural(recs.length, "song");
|
||||
const art = blobUrl(g.art) || blobUrl(recs.find(r => r.art)?.art) || artOf(recs.find(r => r.track.thumb)?.track, 300);
|
||||
const art = blobUrl(g.art) || blobUrl(recs.find(r => r.group?.art instanceof Blob)?.group.art) || blobUrl(recs.find(r => r.art)?.art) || artOf(recs.find(r => r.track.thumb)?.track, 300);
|
||||
const s = h.startsWith("#/album/") ? t.artist || "" : h.startsWith("#/artist/") ? songs : `Playlist · ${songs}`;
|
||||
return card({ href: esc(h), img: art, t: g.title, s, round: h.startsWith("#/artist/"), dl: n });
|
||||
};
|
||||
@@ -1169,7 +1171,7 @@ const routes = {
|
||||
const est = await navigator.storage?.estimate?.().catch(() => null);
|
||||
lists["dl:all"] = recs.map(r => r.track);
|
||||
view.innerHTML = bar("Downloads", { filter: false, extra: recs.length ? `<button class="chip" data-dlclear>Remove all</button>` : "" })
|
||||
+ `<p class="note">${plural(recs.length, "song")} · ${fmtBytes(total)} stored in this browser${est?.quota ? ` (${fmtBytes(est.usage)} of ${fmtBytes(est.quota)} used)` : ""}.
|
||||
+ `<p class="note">${plural(recs.length, "song")} · ${fmtBytes(total)} stored in this browser${est?.quota && !isSecureContext ? ` (${fmtBytes(est.usage)} of ${fmtBytes(est.quota)} used)` : ""}.
|
||||
Downloads play without the network. ${isSecureContext ? "" : "This page isn't on HTTPS, so the browser may clear them when space runs low."}</p>`
|
||||
+ (recs.length ? actions("dl:all") + dlGroups(recs) : `<p class="empty-msg">Nothing downloaded. Right-click any playlist, album or artist and choose Download for offline.</p>`);
|
||||
count(recs.length, "track");
|
||||
@@ -1227,7 +1229,7 @@ view.addEventListener("click", async ev => {
|
||||
if (!tracks.length) return toast(!all.length ? "Still loading…" : S.stemFilter === "nostems" ? "All of these have stems" : "None of these have stems yet");
|
||||
return Q.playList(tracks, ds.mode === "shuffle" ? -1 : 0, ds.mode === "shuffle");
|
||||
}
|
||||
if (ds.listmenu) { const r = el.getBoundingClientRect(); return listMenu(r.left, r.bottom, async () => listItems[ds.listmenu] || lists[ds.listmenu] || [], { title: $(".hero h1", view)?.textContent || "", href: location.hash, art: $(".hero img.art", view)?.src || "" }); }
|
||||
if (ds.listmenu) { const r = el.getBoundingClientRect(); return listMenu(r.left, r.bottom, async () => listItems[ds.listmenu] || lists[ds.listmenu] || [], { title: $(".hero h1", view)?.textContent || "", href: location.hash, art: artUrls($(".hero img.art", view)) }); }
|
||||
if (ds.station) {
|
||||
try {
|
||||
let ts;
|
||||
@@ -1350,7 +1352,7 @@ view.addEventListener("contextmenu", ev => {
|
||||
const row = ev.target.closest("tr[data-list]"), c = ev.target.closest(".card[data-kind]"), d = ev.target.closest(".card[data-dl]");
|
||||
if (d) { ev.preventDefault(); dlMenu(ev.clientX, ev.clientY, d.dataset.dl, $(".t", d).textContent); }
|
||||
else if (row) { ev.preventDefault(); trackMenu(ev.clientX, ev.clientY, row.dataset.list, +row.dataset.i); }
|
||||
else if (c) { ev.preventDefault(); listMenu(ev.clientX, ev.clientY, () => cardTracks(c), { title: $(".t", c).textContent, href: c.getAttribute("href"), art: $("img", c)?.src || "" }); }
|
||||
else if (c) { ev.preventDefault(); listMenu(ev.clientX, ev.clientY, () => cardTracks(c), { title: $(".t", c).textContent, href: c.getAttribute("href"), art: artUrls($("img", c)) }); }
|
||||
});
|
||||
|
||||
// ---- settings -----------------------------------------------------------------------------------
|
||||
|
||||
+5
-1
@@ -551,7 +551,11 @@ export const Radio = {
|
||||
const artBlob = url => url && !url.startsWith("data:") ? fetch(url).then(r => r.ok ? r.blob() : null).catch(() => null) : null;
|
||||
export async function saveOffline(tracks, onStatus, group = null) {
|
||||
let n = 0;
|
||||
if (typeof group?.art === "string") group = { ...group, art: await artBlob(group.art) };
|
||||
if (group?.art && !(group.art instanceof Blob)) {
|
||||
let blob = null;
|
||||
for (const u of [group.art].flat()) if ((blob = await artBlob(u))) break;
|
||||
group = { ...group, art: blob };
|
||||
}
|
||||
for (const t of tracks) {
|
||||
if (Offline.has(t.id)) continue;
|
||||
onStatus?.(`Downloading ${++n} of ${tracks.length}: ${t.title}`);
|
||||
|
||||
Reference in new issue
Block a user