diff --git a/capabilities/default.json b/capabilities/default.json index 5774d21..a05d194 100644 --- a/capabilities/default.json +++ b/capabilities/default.json @@ -21,6 +21,8 @@ "core:window:allow-maximize", "core:window:allow-unmaximize", "core:window:allow-set-always-on-top", - "core:window:allow-set-min-size" + "core:window:allow-set-min-size", + "core:window:allow-set-maximizable", + "core:window:allow-set-max-size" ] } diff --git a/src/downloader.rs b/src/downloader.rs index 85da84a..73bdeb2 100644 --- a/src/downloader.rs +++ b/src/downloader.rs @@ -461,14 +461,14 @@ fn plan(entry: &Entry, save: &SaveOptions, has_ffmpeg: bool) -> Result { .best_codec .as_deref() .map(|c| match media.best_abr { - Some(a) => format!("{} {a} kbps", c.to_uppercase()), - None => c.to_uppercase(), + Some(a) => format!("{} {a} kbps", crate::media::codec_name(c)), + None => crate::media::codec_name(c), }) .unwrap_or_else(|| "best available".into()); let original_label = format!("original {}", media.original_ext.as_deref().unwrap_or("file").to_uppercase()); let src = if from_original { original_label.clone() } else { stream.clone() }; let lossless_source = from_original || media.lossless; - let source_format = if from_original { "download/bestaudio/best" } else { "bestaudio/best" }; + let source_format = if from_original { "download/bestaudio[format_id!*=drc]/bestaudio/best" } else { "bestaudio[format_id!*=drc]/bestaudio/best" }; let mut notes = Vec::new(); let needs_ffmpeg = |what: &str| -> Result<()> { if has_ffmpeg { @@ -490,18 +490,18 @@ fn plan(entry: &Entry, save: &SaveOptions, has_ffmpeg: bool) -> Result { Ok(match save.save_as { SaveAs::Original => { if media.original { - let mut p = audio("download/bestaudio/best"); + let mut p = audio("download/bestaudio[format_id!*=drc]/bestaudio/best"); p.extract = None; p.label = format!("Original file{}", media.original_ext.as_deref().map(|e| format!(" · {}", e.to_uppercase())).unwrap_or_default()); p } else { - let mut p = audio("bestaudio/best"); + let mut p = audio("bestaudio[format_id!*=drc]/bestaudio/best"); notes.push("The uploader hasn't offered an original file, so the best stream was saved instead.".into()); p.notes = notes; p } } - SaveAs::Best => audio("bestaudio/best"), + SaveAs::Best => audio("bestaudio[format_id!*=drc]/bestaudio/best"), SaveAs::Mp3 => { needs_ffmpeg("Saving as MP3")?; let kbps = snap_bitrate(save.mp3_bitrate, source_abr); @@ -510,7 +510,7 @@ fn plan(entry: &Entry, save: &SaveOptions, has_ffmpeg: bool) -> Result { } let floor = kbps.saturating_sub(8); Plan { - format: if from_original { source_format.into() } else { format!("bestaudio[acodec^=mp3][abr>={floor}]/bestaudio/best") }, + format: if from_original { source_format.into() } else { format!("bestaudio[acodec^=mp3][abr>={floor}][format_id!*=drc]/bestaudio[format_id!*=drc]/bestaudio/best") }, sort: None, extract: Some(("mp3".into(), Some(kbps))), merge: None, @@ -523,7 +523,7 @@ fn plan(entry: &Entry, save: &SaveOptions, has_ffmpeg: bool) -> Result { SaveAs::M4a => { needs_ffmpeg("Saving as M4A")?; Plan { - format: "bestaudio[acodec^=mp4a]/bestaudio/best".into(), + format: "bestaudio[acodec^=mp4a][format_id!*=drc]/bestaudio[format_id!*=drc]/bestaudio/best".into(), sort: None, extract: Some(("m4a".into(), source_abr.map(|a| a.max(128)))), merge: None, diff --git a/src/media.rs b/src/media.rs index 017c1c8..e503d47 100644 --- a/src/media.rs +++ b/src/media.rs @@ -205,9 +205,46 @@ fn best_thumbnail(v: &Value) -> Option { s(&v["thumbnail"]) } +static DASH: LazyLock = LazyLock::new(|| Regex::new(r"\s+[-–—]\s+").unwrap()); +static TITLE_JUNK: LazyLock = LazyLock::new(|| { + Regex::new(r"(?i)\s*[\(\[【][^)\]】]*\b(official|music\s*video|lyrics?|lyric\s*video|visuali[sz]er|audio|video\s*oficial|clipe\s*oficial|mv|m/v|hd|hq|4k|8k|explicit|clean\s*version|full\s*song|premiere)\b[^)\]】]*[\)\]】]").unwrap() +}); +static TITLE_TAIL: LazyLock = LazyLock::new(|| Regex::new(r"(?i)\s*[||]\s*.*$|\s+(official\s+(music\s+)?(video|audio)|lyric\s+video|music\s+video)\s*$").unwrap()); + +pub fn tidy_title(title: &str) -> String { + let t = TITLE_JUNK.replace_all(title.trim(), ""); + let t = TITLE_TAIL.replace_all(&t, ""); + let t = t.trim().trim_end_matches(['-', '–', '—', ':']).trim(); + if t.is_empty() { title.trim().to_string() } else { t.to_string() } +} + +pub fn tidy_channel(name: &str) -> String { + let n = name.trim(); + let n = n.strip_suffix(" - Topic").unwrap_or(n); + let n = n.strip_suffix("VEVO").filter(|r| !r.is_empty()).unwrap_or(n); + n.trim().to_string() +} + +pub fn codec_name(codec: &str) -> String { + match codec.to_ascii_lowercase().as_str() { + "opus" => "Opus".into(), + "vorbis" => "Vorbis".into(), + "mp4a" | "aac" => "AAC".into(), + "pcm" => "PCM".into(), + other => other.to_uppercase(), + } +} + +pub fn split_artist_title(title: &str) -> Option<(String, String)> { + let m = DASH.find(title)?; + let (artist, rest) = (title[..m.start()].trim(), title[m.end()..].trim()); + let numbering = artist.chars().all(|c| c.is_ascii_digit() || c == '.'); + (!artist.is_empty() && !rest.is_empty() && artist.chars().count() <= 100 && !numbering).then(|| (artist.to_string(), rest.to_string())) +} + pub fn entry_from_info(v: &Value, index: u32) -> Entry { let extractor = s(&v["extractor_key"]).or_else(|| s(&v["ie_key"])).unwrap_or_default(); - let uploader = s(&v["uploader"]).or_else(|| s(&v["channel"])).unwrap_or_default(); + let uploader = s(&v["uploader"]).or_else(|| s(&v["channel"])).map(|u| tidy_channel(&u)).unwrap_or_default(); let has_formats = v["formats"].is_array() || v["vcodec"].is_string() || v["acodec"].is_string(); let (media, mut availability) = if has_formats { let (m, a) = summarize_formats(v); @@ -226,15 +263,20 @@ pub fn entry_from_info(v: &Value, index: u32) -> Entry { .as_u64() .map(|y| y as u16) .or_else(|| release_date.as_deref().and_then(|d| d.get(..4)?.parse().ok())); + let raw_title = s(&v["track"]).or_else(|| s(&v["title"])).unwrap_or_else(|| "Untitled".into()); + let raw_artist = s(&v["artist"]).or_else(|| joined(&v["artists"])).or_else(|| s(&v["creator"])); + let real_artist = raw_artist.as_ref().is_some_and(|a| *a != uploader) && !extractor.to_ascii_lowercase().contains("soundcloud"); + let cleaned = tidy_title(&raw_title); + let (artist, title) = match (real_artist, split_artist_title(&cleaned)) { + (false, Some((a, t))) => (a, tidy_title(&t)), + _ => (raw_artist.map(|a| tidy_channel(&a)).unwrap_or_else(|| uploader.clone()), cleaned), + }; Entry { index, id: s(&v["id"]).unwrap_or_default(), url: s(&v["webpage_url"]).or_else(|| s(&v["original_url"])).or_else(|| s(&v["url"])).unwrap_or_default(), - title: s(&v["track"]).or_else(|| s(&v["title"])).unwrap_or_else(|| "Untitled".into()), - artist: s(&v["artist"]) - .or_else(|| joined(&v["artists"])) - .or_else(|| s(&v["creator"])) - .unwrap_or_else(|| uploader.clone()), + title, + artist, uploader, album: s(&v["album"]), album_artist: s(&v["album_artist"]).or_else(|| joined(&v["album_artists"])), @@ -609,33 +651,51 @@ impl Prober { self.running.lock().unwrap().insert(collection.id.clone(), stop.clone()); let this = self.clone(); tauri::async_runtime::spawn(async move { - let mut args = base_args(&settings, &tools); - args.extend(["-j", "--ignore-errors", "--yes-playlist", "--", &collection.url].map(String::from)); let mut entries = collection.entries.clone(); let mut failed = 0u32; - let spawned = engine::command(&tools.ytdlp).args(&args).stdout(Stdio::piped()).stderr(Stdio::null()).kill_on_drop(true).spawn(); - if let Ok(mut child) = spawned { - if let Some(stdout) = child.stdout.take() { - let mut lines = BufReader::new(stdout).lines(); - loop { - tokio::select! { - _ = stop.notified() => { let _ = child.kill().await; return; } - line = lines.next_line() => { - let Ok(Some(line)) = line else { break }; - let Ok(v) = serde_json::from_str::(&line) else { continue }; - let idx = v["playlist_index"].as_u64().map(|i| i as u32); - let vid = s(&v["id"]).unwrap_or_default(); - let slot = entries.iter().position(|e| Some(e.index) == idx).or_else(|| entries.iter().position(|e| e.id == vid)); - if let Some(pos) = slot { - let entry = entry_from_info(&v, entries[pos].index); - entries[pos] = entry.clone(); - let _ = app.emit(PROBE_EVENT, ProbeEvent::Entry { collection: collection.id.clone(), entry: Box::new(entry) }); + let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel::(); + let mut workers = Vec::new(); + for (a, b) in detail_ranges(entries.len()) { + let mut args = base_args(&settings, &tools); + args.extend(["-j".into(), "--ignore-errors".into(), "--yes-playlist".into(), "--playlist-items".into(), format!("{a}-{b}"), "--".into(), collection.url.clone()]); + let ytdlp = tools.ytdlp.clone(); + let tx = tx.clone(); + workers.push(tauri::async_runtime::spawn(async move { + let Ok(mut child) = engine::command(&ytdlp).args(&args).stdout(Stdio::piped()).stderr(Stdio::null()).kill_on_drop(true).spawn() else { return }; + if let Some(stdout) = child.stdout.take() { + let mut lines = BufReader::new(stdout).lines(); + while let Ok(Some(line)) = lines.next_line().await { + if let Ok(v) = serde_json::from_str::(&line) { + if tx.send(v).is_err() { + break; } } } } + let _ = child.wait().await; + })); + } + drop(tx); + loop { + tokio::select! { + _ = stop.notified() => { + for w in &workers { + w.abort(); + } + return; + } + next = rx.recv() => { + let Some(v) = next else { break }; + let idx = v["playlist_index"].as_u64().map(|i| i as u32); + let vid = s(&v["id"]).unwrap_or_default(); + let slot = entries.iter().position(|e| Some(e.index) == idx).or_else(|| entries.iter().position(|e| !vid.is_empty() && e.id == vid)); + if let Some(pos) = slot { + let entry = entry_from_info(&v, entries[pos].index); + entries[pos] = entry.clone(); + let _ = app.emit(PROBE_EVENT, ProbeEvent::Entry { collection: collection.id.clone(), entry: Box::new(entry) }); + } + } } - let _ = child.wait().await; } failed += entries.iter().filter(|e| !e.detailed).count() as u32; let extractor = s(&raw["extractor_key"]).unwrap_or_default(); @@ -653,11 +713,62 @@ impl Prober { } } +fn detail_ranges(n: usize) -> Vec<(usize, usize)> { + if n == 0 { + return Vec::new(); + } + let parts = n.div_ceil(5).clamp(1, 4); + let size = n.div_ceil(parts); + (0..parts).map(|p| (p * size + 1, ((p + 1) * size).min(n))).filter(|(a, b)| a <= b).collect() +} + #[cfg(test)] mod tests { use super::*; use serde_json::json; + #[test] + fn splits_details_into_up_to_four_ranges() { + assert_eq!(detail_ranges(0), vec![]); + assert_eq!(detail_ranges(3), vec![(1, 3)]); + assert_eq!(detail_ranges(6), vec![(1, 3), (4, 6)]); + assert_eq!(detail_ranges(20), vec![(1, 5), (6, 10), (11, 15), (16, 20)]); + let big = detail_ranges(101); + assert_eq!(big.len(), 4); + assert_eq!(big.last().unwrap().1, 101); + } + + #[test] + fn youtube_titles_lose_video_clutter() { + let v = json!({ "extractor_key": "Youtube", "id": "9", "title": "Westwood – Eyes (Official Music Video)", "uploader": "Westwood", "formats": [] }); + let e = entry_from_info(&v, 1); + assert_eq!((e.artist.as_str(), e.title.as_str()), ("Westwood", "Eyes")); + assert_eq!(tidy_title("Problems [Official Audio]"), "Problems"); + assert_eq!(tidy_title("Right Now | Official Video"), "Right Now"); + assert_eq!(tidy_title("Crying Alive (Lyric Video) (feat. Nova)"), "Crying Alive (feat. Nova)"); + assert_eq!(tidy_title("Glass (Night Remix)"), "Glass (Night Remix)"); + assert_eq!(tidy_title("OWN ME (prod. siem spark)"), "OWN ME (prod. siem spark)"); + assert_eq!(tidy_title("Love/Hate"), "Love/Hate"); + assert_eq!(tidy_channel("Westwood - Topic"), "Westwood"); + assert_eq!(tidy_channel("WestwoodVEVO"), "Westwood"); + assert_eq!(codec_name("opus"), "Opus"); + assert_eq!(codec_name("mp3"), "MP3"); + } + + #[test] + fn soundcloud_titles_carry_the_real_artist() { + let v = json!({ "extractor_key": "Soundcloud", "id": "1", "title": "CLV, Oscar Yuan & Luminate - Signal Code", "track": "CLV, Oscar Yuan & Luminate - Signal Code", "artist": "Monstercat", "uploader": "Monstercat", "formats": [] }); + let e = entry_from_info(&v, 1); + assert_eq!((e.artist.as_str(), e.title.as_str()), ("CLV, Oscar Yuan & Luminate", "Signal Code")); + let own = json!({ "extractor_key": "Soundcloud", "id": "2", "title": "OWN ME (prod. siem spark)", "uploader": "pvrz", "formats": [] }); + let e = entry_from_info(&own, 1); + assert_eq!((e.artist.as_str(), e.title.as_str()), ("pvrz", "OWN ME (prod. siem spark)")); + let music = json!({ "extractor_key": "Youtube", "id": "3", "title": "Daft Punk - Get Lucky (Official Video)", "track": "Get Lucky", "artist": "Daft Punk", "uploader": "DaftPunkVEVO", "formats": [] }); + assert_eq!(entry_from_info(&music, 1).title, "Get Lucky"); + assert!(split_artist_title("01 - Intro").is_none()); + assert!(split_artist_title("Self-Titled").is_none()); + } + fn e(artist: &str, album: Option<&str>, mins: u64, n: Option) -> Entry { Entry { artist: artist.into(), diff --git a/ui/app.js b/ui/app.js index 51d4677..1d5cfca 100644 --- a/ui/app.js +++ b/ui/app.js @@ -40,6 +40,7 @@ const PLATFORM_ICON = [ [/(^|\.)x\.com|twitter\.com/i, "brand-x", "X"], [/instagram\.com/i, "brand-instagram", "Instagram"], ]; +const codecName = (c) => ({ opus: "Opus", vorbis: "Vorbis", mp4a: "AAC", aac: "AAC", pcm: "PCM" })[(c || "").toLowerCase()] || (c || "").toUpperCase(); const platformIcon = (name) => (PLATFORM_ICON.find((p) => p[2] === name) || [0, "world"])[1]; const state = { @@ -600,7 +601,7 @@ function defaults(c, e) { isrc: "", bpm: null, key: "", - comment: "", + comment: [e.description?.trim(), e.url ? `Source: ${e.url}` : ""].filter(Boolean).join("\n\n"), lyrics: e.lyrics || "", artwork: rel || c.data.single ? c.album.artwork : { kind: "keep" }, }; @@ -999,7 +1000,7 @@ function inspector(c, e, inline) { function availabilityFlags(e) { if (!e.media) return [h("span", { class: "flag" }, e.detailed ? "Unknown formats" : "Checking…")]; const m = e.media, out = []; - if (m.bestCodec) out.push(h("span", { class: "flag" }, `${m.bestCodec.toUpperCase()}${m.bestAbr ? ` ${m.bestAbr} kbps` : ""} best audio`)); + if (m.bestCodec) out.push(h("span", { class: "flag" }, `${codecName(m.bestCodec)}${m.bestAbr ? ` ${m.bestAbr} kbps` : ""} best audio`)); if (m.original) out.push(h("span", { class: "flag" }, `Original ${m.originalExt ? m.originalExt.toUpperCase() : "file"}`)); if (m.lossless) out.push(h("span", { class: "flag" }, "Lossless source")); if (m.hasVideo) out.push(h("span", { class: "flag" }, m.heights.length ? `Video up to ${m.heights[0]}p` : "Video")); @@ -1020,7 +1021,7 @@ function selectionCaps(c) { const lossless = known.some((e) => e.media.lossless || (e.media.original && e.media.originalLossless)); const originals = known.filter((e) => e.media.original).length; const heights = [...new Set(known.flatMap((e) => e.media.heights || []))].sort((a, b) => b - a); - const codecs = [...new Set(known.map((e) => e.media.bestCodec && `${e.media.bestCodec.toUpperCase()}${e.media.bestAbr ? ` ${e.media.bestAbr} kbps` : ""}`).filter(Boolean))]; + const codecs = [...new Set(known.map((e) => e.media.bestCodec && `${codecName(e.media.bestCodec)}${e.media.bestAbr ? ` ${e.media.bestAbr} kbps` : ""}`).filter(Boolean))]; return { count: ents.length, unknown: known.length < ents.length, diff --git a/ui/library.js b/ui/library.js index fa94c15..fd2c424 100644 --- a/ui/library.js +++ b/ui/library.js @@ -19,8 +19,27 @@ const Lib = { }; const lnorm = (s) => (s || "").trim().toLowerCase(); -const primaryArtist = (s) => (s || "").split(/\s*(?:,|;|\bfeat\.?|\bft\.?|\bfeaturing\b)\s*/i)[0].trim() || "Unknown artist"; -const artistsOf = (t) => [...new Set([t.albumArtist, ...(t.artist || "").split(/\s*(?:,|;|\bfeat\.?|\bft\.?|\bfeaturing\b)\s*/i)].map((x) => (x || "").trim()).filter(Boolean))]; +function splitNames(s) { + const text = (s || "").trim(); + let parts = text.split(/\s*(?:,|;|\s(?:feat\.?|ft\.?|featuring)\s|^(?:feat\.?|ft\.?)\s)\s*/i); + if (/,/.test(text)) parts = parts.flatMap((p) => p.split(/\s+&\s+/)); + return parts.map((p) => p.trim()).filter(Boolean); +} +function titleCredits(title) { + const t = title || ""; + const inBrackets = [...t.matchAll(/[\(\[]\s*(?:feat\.?|ft\.?|featuring|with)\s+([^\)\]]+)[\)\]]/gi)].map((m) => m[1]); + const trailing = t.match(/\s(?:feat\.?|ft\.?|featuring)\s+([^\(\[]+)$/i); + return [...inBrackets, trailing?.[1]].filter(Boolean).flatMap((x) => splitNames(x.replace(/,?\s+&\s+/g, ", "))); +} +const primaryArtist = (s) => splitNames(s)[0] || "Unknown artist"; +const artistsOf = (t) => { + const seen = new Map(); + for (const n of [t.albumArtist, ...splitNames(t.artist), ...titleCredits(t.title)]) { + const k = lnorm(n); + if (k && !seen.has(k)) seen.set(k, n.trim()); + } + return [...seen.values()]; +}; const sig = (t) => `${lnorm(t.title)}|${lnorm(primaryArtist(t.artist))}|${Math.round((t.durationMs || 0) / 2000)}`; const albumKind = (a) => { const mins = a.duration / 60000; @@ -52,7 +71,7 @@ function buildIndexes(snap) { const artists = new Map(); const touch = (name) => { const k = lnorm(name); - if (!artists.has(k)) artists.set(k, { key: k, name, meta: metaByName.get(k) || null, albums: [], tracks: [], appearsOn: [] }); + if (!artists.has(k)) artists.set(k, { key: k, name, meta: metaByName.get(k) || null, albums: [], tracks: [], appearsOn: [], featured: [] }); return artists.get(k); }; for (const a of albums.values()) touch(a.artist).albums.push(a); @@ -63,7 +82,33 @@ function buildIndexes(snap) { if (ar && lnorm(a.artist) !== ar.key && !ar.appearsOn.includes(a)) ar.appearsOn.push(a); } } - for (const ar of artists.values()) ar.albums.sort((x, y) => (y.year || 0) - (x.year || 0)); + for (const a of albums.values()) { + const byArtist = new Map(); + for (const t of a.tracks) { + for (const n of artistsOf(t)) { + const k = lnorm(n); + if (k === lnorm(a.artist)) continue; + if (!byArtist.has(k)) byArtist.set(k, []); + byArtist.get(k).push(t); + } + } + for (const [k, tracks] of byArtist) { + const ar = artists.get(k); + if (ar) ar.featured.push({ kind: albumKind(a), title: a.title, by: a.artist, art: a.art, year: a.year, on: tracks.map((t) => t.title), album: a }); + } + } + for (const t of Lib.songs) { + if (t.album) continue; + const main = lnorm(primaryArtist(t.artist)); + for (const n of artistsOf(t)) { + const ar = artists.get(lnorm(n)); + if (ar && ar.key !== main) ar.featured.push({ kind: "Song", title: t.title, by: primaryArtist(t.artist), art: t.art, year: t.year, on: [], track: t }); + } + } + for (const ar of artists.values()) { + ar.albums.sort((x, y) => (y.year || 0) - (x.year || 0)); + ar.featured.sort((x, y) => (y.year || 0) - (x.year || 0) || x.title.localeCompare(y.title)); + } Lib.artists = artists; } @@ -561,6 +606,16 @@ function songsView(root) { requestAnimationFrame(draw); } +function featuredCard(f) { + const open = () => (f.album ? openLib("album", f.album.key) : playList([f.track])); + const onLine = f.on.length && !(f.on.length === 1 && lnorm(f.on[0]) === lnorm(f.title)) ? `on ${f.on.slice(0, 2).join(", ")}${f.on.length > 2 ? ` +${f.on.length - 2}` : ""}` : ""; + return h("div", { class: "card-tile", role: "button", tabindex: "0", "data-album": f.album?.key || null, onclick: open, onkeydown: (e) => { if (e.key === "Enter") open(); } }, + h("div", { class: "tile-art" }, cover(f.art, "tile-img", f.title), h("button", { class: "tile-play", "aria-label": `Play ${f.title}`, onclick: (e) => { e.stopPropagation(); playList(f.album ? f.album.tracks : [f.track]); } }, icon("player-play-filled"))), + h("div", { class: "tile-title" }, f.title), + h("div", { class: "tile-sub" }, h("span", { class: "tile-kind" }, f.kind), ` · ${f.by}`), + onLine ? h("div", { class: "tile-sub on" }, onLine) : null); +} + function albumCard(a) { return h("div", { class: "card-tile", role: "button", tabindex: "0", "data-album": a.key, onclick: () => openLib("album", a.key), onkeydown: (e) => { if (e.key === "Enter") openLib("album", a.key); } }, h("div", { class: "tile-art" }, cover(a.art, "tile-img", a.title), h("button", { class: "tile-play", "aria-label": `Play ${a.title}`, onclick: (e) => { e.stopPropagation(); playList(a.tracks); } }, icon("player-play-filled"))), @@ -641,7 +696,7 @@ function artistView(root, key) { body.append(h("section", {}, h("h2", { class: "sec" }, "Popular"), trackList(popular, { cover: true, list: popular }))); if (full.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Albums"), h("div", { class: "grid" }, ...full.map(albumCard)))); if (small.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Singles & EPs"), h("div", { class: "grid" }, ...small.map(albumCard)))); - if (ar.appearsOn.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Appears on"), h("div", { class: "grid" }, ...ar.appearsOn.map(albumCard)))); + 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"))); root.append(body); } diff --git a/ui/lyrics.js b/ui/lyrics.js index a85f8af..8dc488e 100644 --- a/ui/lyrics.js +++ b/ui/lyrics.js @@ -152,11 +152,12 @@ function openLyrics() { function renderLyricsAll() { renderLyricsPanel(); if (Lyr.tv) renderTv(); + if (typeof Mini !== "undefined" && Mini.on) renderMiniPanel(); } function tick() { Lyr.raf = 0; - const visible = !$("#lyricsPanel").hidden || Lyr.tv; + const visible = !$("#lyricsPanel").hidden || Lyr.tv || (typeof Mini !== "undefined" && Mini.on && Mini.panelShown && Mini.prefs.panel === "lyrics"); if (!visible) return; const l = Lyr.data; if (l?.synced) { diff --git a/ui/miniplayer.js b/ui/miniplayer.js index 87a74dc..4fbd99b 100644 --- a/ui/miniplayer.js +++ b/ui/miniplayer.js @@ -1,19 +1,27 @@ -// atmosphere · miniplayer.js · Compact always-on-top player with optional cover, blurred backdrop and an editable queue +// atmosphere · miniplayer.js · Compact always-on-top player that reflows by size: portrait card, wide strip or tiny, with a lyrics or queue panel when there's room const Mini = { on: false, restore: null, - prefs: { cover: true, blur: true, queue: false, pin: true }, + prefs: { cover: true, blur: true, panel: "none", pin: true }, dragFrom: null, + layout: "", + panelShown: false, + sizeTimer: 0, + lyricsFor: null, }; -const MINI_W = 340; -const MINI_BASE = 168; -const MINI_COVER = 300; -const MINI_QUEUE = 232; +const MINI_MIN = { w: 260, h: 96 }; +const MINI_MAX = { w: 900, h: 900 }; +const MINI_CORE = 168; +const MINI_STRIP = 112; +const MINI_PANEL = 232; function miniLoad() { try { - Object.assign(Mini.prefs, JSON.parse(localStorage.getItem("atmo.mini") || "{}")); + const saved = JSON.parse(localStorage.getItem("atmo.mini") || "{}"); + if (saved.queue && !saved.panel) saved.panel = "queue"; + delete saved.queue; + Object.assign(Mini.prefs, saved); } catch {} } @@ -23,19 +31,34 @@ function miniSave() { } catch {} } -const miniWin = () => window.__TAURI__?.window?.getCurrentWindow?.(); - -function miniHeight() { - return MINI_BASE + (Mini.prefs.cover ? MINI_COVER : 0) + (Mini.prefs.queue ? MINI_QUEUE : 0); +function miniSavedSize() { + try { + const s = JSON.parse(localStorage.getItem("atmo.miniSize") || "null"); + if (s && s.w >= MINI_MIN.w && s.h >= MINI_MIN.h) return s; + } catch {} + return null; } -async function miniResize() { +const miniWin = () => window.__TAURI__?.window?.getCurrentWindow?.(); + +function miniIdealHeight(w, wide) { + const panel = Mini.prefs.panel !== "none"; + if (wide) return MINI_STRIP + (panel ? MINI_PANEL : 0); + return MINI_CORE + (Mini.prefs.cover ? Math.min(w - 40, 300) : 0) + (panel ? MINI_PANEL : 0); +} + +async function miniSetSize(w, h) { const win = miniWin(); const dpi = window.__TAURI__?.dpi; if (!win || !dpi) return; - const min = MINI_BASE + (Mini.prefs.queue ? 120 : 0); - await win.setMinSize(new dpi.LogicalSize(300, min)).catch(() => {}); - await win.setSize(new dpi.LogicalSize(MINI_W, miniHeight())).catch(() => {}); + const cw = Math.max(MINI_MIN.w, Math.min(MINI_MAX.w, Math.round(w))); + const ch = Math.max(MINI_MIN.h, Math.min(MINI_MAX.h, Math.round(h))); + await win.setSize(new dpi.LogicalSize(cw, ch)).catch(() => {}); +} + +async function miniFit() { + const w = innerWidth; + await miniSetSize(w, miniIdealHeight(w, Mini.layout === "wide")); } async function openMini() { @@ -45,16 +68,22 @@ async function openMini() { closeFx(); Mini.on = true; document.body.classList.add("mini-mode"); - $("#mini").hidden = false; - $("#mini").classList.toggle("mac", isMac); + const box = $("#mini"); + box.hidden = false; + box.classList.toggle("mac", isMac); const win = miniWin(); - if (win) { + const dpi = window.__TAURI__?.dpi; + if (win && dpi) { Mini.restore = { pos: await win.outerPosition().catch(() => null), size: await win.outerSize().catch(() => null), max: await win.isMaximized().catch(() => false) }; if (Mini.restore.max) await win.unmaximize().catch(() => {}); - await miniResize(); + await win.setMaximizable(false).catch(() => {}); + await win.setMinSize(new dpi.LogicalSize(MINI_MIN.w, MINI_MIN.h)).catch(() => {}); + await win.setMaxSize(new dpi.LogicalSize(MINI_MAX.w, MINI_MAX.h)).catch(() => {}); + const saved = miniSavedSize(); + await miniSetSize(saved?.w || 340, saved?.h || miniIdealHeight(340, false)); await win.setAlwaysOnTop(!!Mini.prefs.pin).catch(() => {}); } - renderMini(); + buildMini(); } async function closeMini() { @@ -62,12 +91,16 @@ async function closeMini() { Mini.on = false; document.body.classList.remove("mini-mode"); $("#mini").hidden = true; + $("#mini").replaceChildren(); + Mini.lyricsFor = null; const win = miniWin(); const dpi = window.__TAURI__?.dpi; const r = Mini.restore; Mini.restore = null; if (!win || !dpi) return; await win.setAlwaysOnTop(false).catch(() => {}); + await win.setMaxSize(null).catch(() => {}); + await win.setMaximizable(true).catch(() => {}); await win.setMinSize(new dpi.LogicalSize(900, 620)).catch(() => {}); if (r?.size) await win.setSize(new dpi.PhysicalSize(r.size.width, r.size.height)).catch(() => {}); if (r?.pos) await win.setPosition(new dpi.PhysicalPosition(r.pos.x, r.pos.y)).catch(() => {}); @@ -75,15 +108,17 @@ async function closeMini() { } async function miniToggle(key) { - Mini.prefs[key] = !Mini.prefs[key]; + if (key === "lyrics" || key === "queue") { + Mini.prefs.panel = Mini.prefs.panel === key ? "none" : key; + } else Mini.prefs[key] = !Mini.prefs[key]; miniSave(); if (key === "pin") await miniWin()?.setAlwaysOnTop(Mini.prefs.pin).catch(() => {}); - if (key === "cover" || key === "queue") await miniResize(); - renderMini(); + const needsFit = key === "lyrics" || key === "queue" || (key === "cover" && Mini.layout !== "wide"); + buildMini(); + if (needsFit) await miniFit(); } -function miniButton(key, iconName, label) { - const on = !!Mini.prefs[key]; +function miniButton(key, iconName, label, on) { return h("button", { class: "icon-btn mini-opt", "aria-pressed": String(on), "aria-label": label, title: label, onclick: () => miniToggle(key) }, icon(iconName)); } @@ -129,56 +164,143 @@ function moveInQueue(from, to) { Player.persist(); } -function renderMini() { +function buildMini() { const box = $("#mini"); if (!box || !Mini.on) return; - const t = Player.current; - const art = t?.art ? artUrl(t.art) : null; - box.classList.toggle("with-cover", !!Mini.prefs.cover); - box.classList.toggle("with-blur", !!Mini.prefs.blur && !!art); - box.classList.toggle("with-queue", !!Mini.prefs.queue); - box.style.setProperty("--mini-art", art ? `url("${art}")` : "none"); - const playing = !Player.audio.paused; - const next = Player.queue.slice(Player.index + 1); - const parts = [ - h("div", { class: "mini-bg", "aria-hidden": "true" }), - h("div", { class: "mini-top", "data-tauri-drag-region": "" }, - h("span", { class: "mini-brand", "data-tauri-drag-region": "" }, "Atmosphere"), - h("div", { class: "mini-opts" }, - miniButton("cover", "photo", Mini.prefs.cover ? "Hide cover art" : "Show cover art"), - miniButton("blur", "droplet", Mini.prefs.blur ? "Turn off blurred backdrop" : "Blurred cover backdrop"), - miniButton("queue", "list", Mini.prefs.queue ? "Hide queue" : "Show queue"), - miniButton("pin", Mini.prefs.pin ? "pinned" : "pin", Mini.prefs.pin ? "Always on top: on" : "Always on top: off"), - h("button", { class: "icon-btn", "aria-label": "Back to full window", title: "Back to full window (P)", onclick: closeMini }, icon("arrows-maximize")))), - Mini.prefs.cover ? h("div", { class: "mini-art", "data-tauri-drag-region": "" }, art ? h("img", { src: art, alt: "", draggable: "false", "data-tauri-drag-region": "" }) : h("div", { class: "mini-art-empty" }, icon("music"))) : null, - h("div", { class: "mini-meta" }, - h("span", { class: "mini-title", title: t?.title || "" }, t?.title || "Nothing playing"), - h("span", { class: "mini-artist" }, t?.artist || "Pick something from your library")), - h("div", { class: "mini-seek" }, - h("span", { class: "mini-t", id: "miniCur" }, "0:00"), - h("input", { type: "range", class: "range", id: "miniSeek", min: "0", max: "1000", value: "0", "aria-label": "Seek" }), - h("span", { class: "mini-t", id: "miniDur" }, "0:00")), - h("div", { class: "mini-ctl" }, - h("button", { class: "icon-btn", "aria-label": "Previous", onclick: () => Player.prev() }, icon("player-skip-back-filled")), - h("button", { class: "mini-play", "aria-label": playing ? "Pause" : "Play", onclick: () => Player.toggle() }, icon(playing ? "player-pause-filled" : "player-play-filled")), - h("button", { class: "icon-btn", "aria-label": "Next", onclick: () => Player.next() }, icon("player-skip-forward-filled"))), - Mini.prefs.queue - ? h("div", { class: "mini-queue" }, - h("div", { class: "mq-head" }, h("span", {}, next.length ? `Up next · ${next.length}` : "Up next"), next.length ? h("button", { class: "btn small ghost", onclick: () => Player.clearUpNext() }, "Clear") : null), - next.length ? h("div", { class: "mq-list" }, ...next.slice(0, 200).map((q, k) => miniQueueRow(q, Player.index + 1 + k))) : h("p", { class: "mq-empty" }, "Nothing queued. Add songs from your library.")) - : null, - ]; - box.replaceChildren(...parts.filter(Boolean)); - const seek = $("#miniSeek"); + const p = Mini.prefs; + box.classList.toggle("with-cover", !!p.cover); + const art = h("div", { class: "mini-art", "data-tauri-drag-region": "" }); + const seek = h("input", { type: "range", class: "range", id: "miniSeek", min: "0", max: "1000", value: "0", "aria-label": "Seek" }); seek.addEventListener("input", () => { rangeFill(seek); const d = Player.audio.duration; if (isFinite(d)) $("#miniCur").textContent = fmtDur((seek.value / 1000) * d * 1000); }); seek.addEventListener("change", () => Player.seek((seek.value / 1000) * Player.audio.duration)); + box.replaceChildren( + h("div", { class: "mini-bg", "aria-hidden": "true" }), + h("div", { class: "mini-top", "data-tauri-drag-region": "" }, + h("span", { class: "mini-brand", "data-tauri-drag-region": "" }, "Atmosphere"), + h("div", { class: "mini-opts" }, + miniButton("cover", "photo", p.cover ? "Hide cover art" : "Show cover art", p.cover), + miniButton("blur", "droplet", p.blur ? "Turn off blurred backdrop" : "Blurred cover backdrop", p.blur), + miniButton("lyrics", "microphone", p.panel === "lyrics" ? "Hide lyrics" : "Show lyrics", p.panel === "lyrics"), + miniButton("queue", "list", p.panel === "queue" ? "Hide queue" : "Show queue", p.panel === "queue"), + miniButton("pin", p.pin ? "pinned" : "pin", p.pin ? "Always on top: on" : "Always on top: off", p.pin), + h("button", { class: "icon-btn", "aria-label": "Back to full window", title: "Back to full window (P)", onclick: closeMini }, icon("arrows-maximize")))), + h("div", { class: "mini-body", "data-tauri-drag-region": "" }, + art, + h("div", { class: "mini-info", "data-tauri-drag-region": "" }, + h("div", { class: "mini-meta", "data-tauri-drag-region": "" }, + h("span", { class: "mini-title", id: "miniTitle", "data-tauri-drag-region": "" }), + h("span", { class: "mini-artist", id: "miniArtist", "data-tauri-drag-region": "" })), + h("div", { class: "mini-seek" }, h("span", { class: "mini-t", id: "miniCur" }, "0:00"), seek, h("span", { class: "mini-t", id: "miniDur" }, "0:00"))), + h("div", { class: "mini-ctl" }, + h("button", { class: "icon-btn", "aria-label": "Previous", onclick: () => Player.prev() }, icon("player-skip-back-filled")), + h("button", { class: "mini-play", id: "miniPlay", onclick: () => Player.toggle() }), + h("button", { class: "icon-btn", "aria-label": "Next", onclick: () => Player.next() }, icon("player-skip-forward-filled")))), + h("div", { class: "mini-panel", id: "miniPanel" }) + ); + Mini.lyricsFor = null; + Mini.layout = ""; + miniLayout(); + updateMini(); + renderMiniPanel(); +} + +function updateMini() { + const box = $("#mini"); + if (!box || !Mini.on || !$("#miniTitle")) return; + const t = Player.current; + const art = t?.art ? artUrl(t.art) : null; + box.classList.toggle("with-blur", !!Mini.prefs.blur && !!art); + box.style.setProperty("--mini-art", art ? `url("${art}")` : "none"); + $("#miniTitle").textContent = t?.title || "Nothing playing"; + $("#miniTitle").title = t?.title || ""; + $("#miniArtist").textContent = t?.artist || "Pick something from your library"; + const artBox = box.querySelector(".mini-art"); + const img = artBox.querySelector("img"); + if (art && img?.getAttribute("src") !== art) artBox.replaceChildren(h("img", { src: art, alt: "", draggable: "false", "data-tauri-drag-region": "" })); + else if (!art && !artBox.querySelector(".mini-art-empty")) artBox.replaceChildren(h("div", { class: "mini-art-empty", "data-tauri-drag-region": "" }, icon("music"))); + const playing = !Player.audio.paused; + const pb = $("#miniPlay"); + pb.setAttribute("aria-label", playing ? "Pause" : "Play"); + pb.replaceChildren(icon(playing ? "player-pause-filled" : "player-play-filled")); miniTime(); } +function renderMiniPanel() { + const panel = $("#miniPanel"); + if (!panel || !Mini.on) return; + const kind = Mini.panelShown ? Mini.prefs.panel : "none"; + panel.dataset.kind = kind; + if (kind === "queue") { + Mini.lyricsFor = null; + const next = Player.queue.slice(Player.index + 1); + panel.replaceChildren( + h("div", { class: "mq-head" }, h("span", {}, next.length ? `Up next · ${next.length}` : "Up next"), next.length ? h("button", { class: "btn small ghost", onclick: () => Player.clearUpNext() }, "Clear") : null), + next.length ? h("div", { class: "mq-list" }, ...next.slice(0, 200).map((q, k) => miniQueueRow(q, Player.index + 1 + k))) : h("p", { class: "mq-empty" }, "Nothing queued. Add songs from your library.")); + return; + } + if (kind !== "lyrics") { + Mini.lyricsFor = null; + panel.replaceChildren(); + return; + } + const t = Player.current; + if (t && Lyr.trackId !== t.id) loadLyrics(); + const key = `${t?.id || ""}|${Lyr.loading}|${!!Lyr.data}|${Lyr.data?.synced}`; + if (Mini.lyricsFor === key) return; + Mini.lyricsFor = key; + let content; + if (!t) content = h("p", { class: "mini-lyr-note" }, "Play something to see its lyrics."); + else if (Lyr.loading) content = h("p", { class: "mini-lyr-note" }, "Finding lyrics…"); + else if (!Lyr.data) content = h("p", { class: "mini-lyr-note" }, "No lyrics found for this song."); + else { + content = h("div", { class: "mini-lyr-scroll" }, lyricLines(Lyr.data, false)); + Lyr.active = -1; + startTick(); + } + panel.replaceChildren(content); +} + +function miniLayout() { + const box = $("#mini"); + if (!box || !Mini.on) return; + const w = innerWidth; + const ht = innerHeight; + const tiny = w < 290 || ht < 132; + const wide = !tiny && w >= 400 && w >= ht * 1.3; + const layout = tiny ? "tiny" : wide ? "wide" : "portrait"; + const panelWant = Mini.prefs.panel !== "none"; + let panelShown = false; + let artSize = 0; + if (layout === "wide") { + panelShown = panelWant && ht >= MINI_STRIP + 120; + const strip = panelShown ? MINI_STRIP : ht; + artSize = Math.max(56, Math.min(strip - 24, Math.round(w * 0.32), 300)); + } else if (layout === "portrait") { + const room = ht - MINI_CORE; + panelShown = panelWant && room - (Mini.prefs.cover ? 120 : 0) >= 120; + const forArt = room - (panelShown ? Math.max(MINI_PANEL, room * 0.45) : 0); + artSize = Mini.prefs.cover ? Math.max(0, Math.min(w - 40, forArt - 14, 420)) : 0; + if (artSize < 96) artSize = 0; + } + box.classList.toggle("wide", layout === "wide"); + box.classList.toggle("tiny", layout === "tiny"); + box.classList.toggle("portrait", layout === "portrait"); + box.classList.toggle("has-panel", panelShown); + box.classList.toggle("no-art", !Mini.prefs.cover || (layout === "portrait" && !artSize) || layout === "tiny"); + box.style.setProperty("--art", `${artSize}px`); + const changed = layout !== Mini.layout || panelShown !== Mini.panelShown; + Mini.layout = layout; + Mini.panelShown = panelShown; + if (changed) { + Mini.lyricsFor = null; + renderMiniPanel(); + } +} + function miniTime() { if (!Mini.on) return; const seek = $("#miniSeek"); @@ -191,6 +313,13 @@ function miniTime() { $("#miniDur").textContent = d ? fmtDur(d * 1000) : "0:00"; } +function renderMini() { + if (!Mini.on) return; + if (!$("#miniTitle")) return buildMini(); + updateMini(); + renderMiniPanel(); +} + function bindMini() { miniLoad(); $("#miniBtn")?.addEventListener("click", () => (Mini.on ? closeMini() : openMini())); @@ -199,7 +328,23 @@ function bindMini() { const type = e.detail.type; if (type === "time") return miniTime(); if (type === "volume" || type === "fx") return; - renderMini(); + updateMini(); + if (type === "queue" || type === "track") { + if (Mini.prefs.panel === "queue" || type === "track") Mini.lyricsFor = null; + renderMiniPanel(); + } + }); + window.addEventListener("resize", () => { + if (!Mini.on) return; + miniLayout(); + clearTimeout(Mini.sizeTimer); + Mini.sizeTimer = setTimeout(async () => { + const win = miniWin(); + if (win && (await win.isMaximized().catch(() => false))) await win.unmaximize().catch(() => {}); + try { + localStorage.setItem("atmo.miniSize", JSON.stringify({ w: innerWidth, h: innerHeight })); + } catch {} + }, 300); }); document.addEventListener("keydown", (e) => { if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey || e.ctrlKey || e.metaKey) return; diff --git a/ui/styles.css b/ui/styles.css index 41222af..af16ace 100644 --- a/ui/styles.css +++ b/ui/styles.css @@ -903,38 +903,44 @@ img { user-select: none; } /* mini player */ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { display: none !important; } -.mini { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--text); overflow: hidden; } +.mini { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--text); overflow: hidden; --art: 0px; } .mini[hidden] { display: none; } .mini-bg { position: absolute; inset: -60px; background: var(--mini-art) center / cover no-repeat; filter: blur(46px) saturate(1.35) brightness(0.5); opacity: 0; transition: opacity 320ms var(--ease); pointer-events: none; z-index: 0; } .mini.with-blur .mini-bg { opacity: 1; } .mini > :not(.mini-bg) { position: relative; z-index: 1; } -.mini.with-blur { color: #f4f5f8; --text-2: rgba(244, 245, 248, 0.74); --text-3: rgba(244, 245, 248, 0.52); --hover: rgba(255, 255, 255, 0.09); --hairline: rgba(255, 255, 255, 0.1); } -.mini-top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; } +.mini.with-blur { color: #f4f5f8; --text: #f4f5f8; --text-2: rgba(244, 245, 248, 0.74); --text-3: rgba(244, 245, 248, 0.52); --hover: rgba(255, 255, 255, 0.09); --hairline: rgba(255, 255, 255, 0.1); } +.mini-top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 38px; padding: 0 6px 0 14px; z-index: 3; transition: opacity 140ms var(--ease); } .mini-brand { font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: lowercase; color: var(--text-3); } .mini-opts { display: flex; gap: 2px; } .mini-opt[aria-pressed="true"] { color: var(--accent); } .mini.with-blur .mini-opt[aria-pressed="true"] { color: #fff; background: rgba(255, 255, 255, 0.12); } -.mini-art { flex: none; display: grid; place-items: center; padding: 2px 20px 14px; } -.mini-art img, .mini-art-empty { width: 100%; max-width: 268px; aspect-ratio: 1; border-radius: 12px; object-fit: cover; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6); } + +.mini-body { flex: none; display: flex; flex-direction: column; align-items: center; min-height: 0; } +.mini-art { flex: none; width: var(--art); height: var(--art); margin: 2px auto 14px; } +.mini.no-art .mini-art { display: none; } +.mini-art img, .mini-art-empty { display: block; width: 100%; height: 100%; border-radius: 12px; object-fit: cover; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6); } .mini-art-empty { display: grid; place-items: center; background: var(--surface); color: var(--text-3); } -.mini-art-empty .i svg { width: 48px; height: 48px; } -.mini-meta { flex: none; display: grid; gap: 2px; padding: 0 20px; text-align: center; min-width: 0; } +.mini-art-empty .i svg { width: 40%; height: 40%; } +.mini-info { width: 100%; min-width: 0; display: grid; gap: 10px; } +.mini-meta { display: grid; gap: 2px; padding: 0 20px; text-align: center; min-width: 0; } .mini-title { font: 650 15px/1.3 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .mini-artist { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.mini-seek { flex: none; display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 8px; align-items: center; padding: 10px 14px 0; } +.mini-seek { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 8px; align-items: center; padding: 0 14px; } .mini-t { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; text-align: center; } .mini-ctl { flex: none; display: flex; justify-content: center; align-items: center; gap: 22px; padding: 6px 0 12px; } .mini-ctl .icon-btn { width: 36px; height: 36px; color: var(--text-2); } .mini-ctl .icon-btn:hover { color: var(--text); } -.mini-play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: transform 120ms var(--ease); } +.mini-play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: transform 120ms var(--ease); flex: none; } .mini.with-blur .mini-play { background: #fff; color: #111318; } .mini-play:hover { transform: scale(1.05); } .mini-play:active { transform: scale(0.96); } .mini-play .i svg { width: 20px; height: 20px; } -.mini-queue { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--hairline); } + +.mini-panel { flex: 1; min-height: 0; display: none; flex-direction: column; border-top: 1px solid var(--hairline); } +.mini.has-panel .mini-panel { display: flex; } .mq-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 4px 16px; font-size: 12px; font-weight: 600; color: var(--text-2); min-height: 34px; } .mq-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; } -.mq-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 28px; gap: 6px; align-items: center; padding: 4px 4px 4px 4px; border-radius: 8px; cursor: grab; } +.mq-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 28px; gap: 6px; align-items: center; padding: 4px; border-radius: 8px; cursor: grab; } .mq-row:hover { background: var(--hover); } .mq-row .icon-btn { opacity: 0; } .mq-row:hover .icon-btn, .mq-row:focus-within .icon-btn { opacity: 1; } @@ -944,9 +950,50 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa .mq-row.drop-above { box-shadow: inset 0 2px 0 var(--accent); } .mq-row.drop-below { box-shadow: inset 0 -2px 0 var(--accent); } .mq-empty { margin: 0; padding: 6px 16px 12px; color: var(--text-3); font-size: 12.5px; } -@media (prefers-reduced-motion: reduce) { .mini-bg, .mini-play { transition: none; } } -.mini.mac .mini-top { padding-left: 78px; } -.mini.mac .mini-brand { display: none; } +.mini-lyr-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 80%, transparent); mask-image: linear-gradient(transparent, #000 14%, #000 80%, transparent); } +.mini-lyr-scroll::-webkit-scrollbar { display: none; } +.mini .lyr { gap: 6px; padding: 26px 18px 70%; } +.mini .lyr.plain { padding: 14px 18px; } +.mini .lyr-line { font-size: 15.5px; line-height: 1.35; } +.mini .lyr.plain .lyr-line { font-size: 13.5px; } +.mini .lyr-tr { font-size: 12px; } +.mini-lyr-note { margin: auto; padding: 16px; color: var(--text-3); font-size: 12.5px; text-align: center; } + +.mini.wide .mini-top, .mini.tiny .mini-top { position: absolute; top: 0; right: 0; height: 34px; padding: 0 4px; opacity: 0; } +.mini.wide:hover .mini-top, .mini.tiny:hover .mini-top, .mini .mini-top:focus-within { opacity: 1; } +.mini.wide .mini-brand, .mini.tiny .mini-brand { display: none; } +.mini.wide .mini-opts .icon-btn, .mini.tiny .mini-opts .icon-btn { width: 26px; height: 26px; } +.mini.wide .mini-body { flex: 1 1 auto; flex-direction: row; align-items: center; gap: 14px; padding: 12px 14px; } +.mini.wide.has-panel .mini-body { flex: none; height: 112px; } +.mini.wide .mini-art { margin: 0; } +.mini.wide .mini-art img, .mini.wide .mini-art-empty { border-radius: 8px; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6); } +.mini.wide .mini-info { flex: 1; gap: 8px; padding-top: 6px; } +.mini.wide .mini-meta { text-align: left; padding: 0; } +.mini.wide .mini-title { font-size: 14.5px; } +.mini.wide .mini-seek { padding: 0; grid-template-columns: auto minmax(0, 1fr) auto; } +.mini.wide .mini-t { min-width: 30px; } +.mini.wide .mini-ctl { gap: 4px; padding: 6px 0 0; } +.mini.wide .mini-ctl .icon-btn { width: 30px; height: 30px; } +.mini.wide .mini-play { width: 38px; height: 38px; } +.mini.wide .mini-play .i svg { width: 17px; height: 17px; } + +.mini.tiny .mini-body { flex: 1 1 auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px 12px; } +.mini.tiny .mini-info { flex: 1; gap: 0; } +.mini.tiny .mini-meta { text-align: left; padding: 0; } +.mini.tiny .mini-title { font-size: 13px; } +.mini.tiny .mini-artist { font-size: 11.5px; } +.mini.tiny .mini-seek { position: absolute; left: 0; right: 0; bottom: 0; padding: 0; display: block; } +.mini.tiny .mini-seek .mini-t { display: none; } +.mini.tiny .mini-seek .range { display: block; width: 100%; height: 4px; margin: 0; } +.mini.tiny .mini-ctl { gap: 0; padding: 0; } +.mini.tiny .mini-ctl .icon-btn { width: 28px; height: 28px; } +.mini.tiny .mini-play { width: 32px; height: 32px; } +.mini.tiny .mini-play .i svg { width: 15px; height: 15px; } + +.mini.mac.portrait .mini-top { padding-left: 78px; } +.mini.mac.portrait .mini-brand { display: none; } +.mini.mac.wide .mini-body, .mini.mac.tiny .mini-body { padding-top: 30px; } +@media (prefers-reduced-motion: reduce) { .mini-bg, .mini-play, .mini-top { transition: none; } } /* linked playlist folders */ .nav-item.missing { color: var(--text-3); } @@ -1014,3 +1061,7 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa .side-tip { position: fixed; z-index: 120; transform: translate(-4px, -50%); opacity: 0; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 550; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; transition: opacity 100ms var(--ease), transform 100ms var(--ease); } .side-tip.on { opacity: 1; transform: translate(0, -50%); } @media (prefers-reduced-motion: reduce) { .shell, .titlebar, .side-tip { transition: none; } } + +/* featured on */ +.tile-kind { font-weight: 600; color: var(--text-2); } +.tile-sub.on { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }