Mini player, direct file links, backups and polish

- Mini player with optional cover art, blurred backdrop, reorderable queue and always-on-top
- Direct .mp3/.wav/.flac/.mp4 links are verified and read for real bitrate, tags and cover
- Lyrics soften with distance from the sung line; hovering brings a line into focus
- Browser sign-in check with clear guidance, plus cookies.txt file support
- Backup and restore of settings, stats, liked songs and artist photos
- Uninstaller keeps data by default and offers a backup before deleting it
- Stalled partial downloads clear automatically when downloads finish
- Window border follows the app theme; images can no longer be dragged out
- Fix search results rendering as [object Object]
This commit is contained in:
Christian
2026-11-18 20:17:39 -05:00
parent 1fcd3a85f7
commit 7329bd673b
24 changed files with 1105 additions and 32 deletions
Generated
+1
View File
@@ -262,6 +262,7 @@ dependencies = [
"trash",
"url",
"walkdir",
"windows-sys 0.61.2",
"zip",
]
+4 -1
View File
@@ -42,5 +42,8 @@ url = "2.5.8"
walkdir = "2.5.0"
zip = { version = "9.7.0", default-features = false, features = ["deflate"] }
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Graphics_Dwm"] }
[build-dependencies]
tauri-build = "2"
tauri-build = { version = "2", features = [] }
+10 -2
View File
@@ -65,9 +65,11 @@ It's built for media you **own or have the rights to keep**, such as your own up
- **Pitch** (±12 semitones) and **tempo** (0.5×–2×), changed independently, or linked in **Vinyl** mode.
- An Effects on/off switch for instant comparison.
- **TV mode** (`F`): full-screen with the cover-art backdrop and big synced lyrics, or a visualizer when there are none. Sends to a second screen when one is connected.
- **Mini player** (`P`): a small window with optional cover art, a blurred-cover backdrop, a queue you can drag to reorder, and always-on-top.
### Lyrics
- Synced line by line, plus **word by word** when the source supports it. Click a line to jump, nudge the timing, and save `.lrc` files.
- **Soft focus:** lines blur gently the further they are from the one being sung, and hovering any line brings it into focus. You can turn this off in Settings.
- **Free sources:** no key needed and on by default.
| Source | Key | Notes |
@@ -84,6 +86,7 @@ It's built for media you **own or have the rights to keep**, such as your own up
### Downloads
- One bar for links and search (YouTube and SoundCloud). Paste anywhere, drag links in, or accept the "Use copied link" offer.
- **Direct file links** ending in `.mp3`, `.wav`, `.flac`, `.mp4` and similar are checked first to make sure they're real media, then read for their actual bitrate, length, tags and cover art.
- **Release detection:** Album, EP, Single, LP, Compilation, Mixtape, Playlist, Profile and Channel. This drives track numbering, album tags and folder names.
- **Save as** describes outcomes:
- Original file
@@ -96,7 +99,7 @@ It's built for media you **own or have the rights to keep**, such as your own up
**Bitrates never exceed the source.** Matching codecs are copied rather than re-encoded.
- Metadata editing per release and per track: composer, ISRC, BPM, key, cover art and trimming.
- Downloads run in **track order**, with progress, retry, history, and skipping of anything downloaded before.
- Extras: chapters, subtitles, SponsorBlock, a speed limit, a proxy, and browser sign-in for your own private uploads.
- Extras: chapters, subtitles, SponsorBlock, a speed limit, a proxy, and sign-in for your own private uploads, either from your browser or from a `cookies.txt` file. **Check** confirms it works and explains what to do if it doesn't. For example, Chromium browsers lock their sign-in while they're open.
### Stats
- Week, month, year or all time: listening time, plays, songs, artists, time in the app, a by-day chart, and top songs, artists and albums.
@@ -112,7 +115,9 @@ It's built for media you **own or have the rights to keep**, such as your own up
### The app itself
- **About 8 MB**, native on each OS. Custom title bar and right-click menus throughout. Light and dark themes.
- **Portable:** `atmosphere.exe` runs from any folder. Put an empty file named `portable` next to it, and all data stays beside it.
- **Tidy:** temp files are wiped on every launch and exit, and stalled downloads are cleaned up. **Settings → Storage** shows what Atmosphere keeps and lets you clean it up.
- **Tidy:** temp files and stalled partial downloads are cleared automatically on launch, whenever downloads finish, and on exit. **Settings → Storage** shows what Atmosphere keeps and lets you clean it up.
- **Back up and restore** your settings, stats, liked songs and artist photos as a single `.zip` from **Settings → Storage**.
- **Clean uninstall:** the Windows uninstaller keeps your data by default. If you choose to delete it, you're offered a backup first. Your music files are never touched.
## Get started
@@ -161,6 +166,7 @@ cargo tauri build
| `L` | Lyrics |
| `Q` | Queue |
| `F` | TV mode |
| `P` | Mini player |
| `Ctrl K` | Link or search bar |
| `Ctrl F` | Search the current view |
| `Delete` | Delete the selected songs (with confirmation) |
@@ -187,6 +193,8 @@ Atmosphere is for media you own or are allowed to keep.
| `src/library.rs`, `src/libcmd.rs` | Library, artwork, folder playlists, stats, the file watcher, and the `atmo://` media protocol |
| `src/lyrics.rs` | Lyrics providers, LRC and word-timing parsing, cache |
| `src/storage.rs` | Temp-file cleanup and the Storage report |
| `src/direct.rs` | Checks and reads direct audio and video file links |
| `src/backup.rs` | Backup and restore of settings, stats and liked songs |
| `src/tagging.rs` | Writes tags, cover art and lyrics into files |
| `ui/` | The interface in plain HTML, CSS and JS (no build step) |
| `branding/`, `tools/` | The logo, wordmark lockups and installer art, all generated from code |
+3 -1
View File
@@ -19,6 +19,8 @@
"core:window:allow-available-monitors",
"core:window:allow-current-monitor",
"core:window:allow-maximize",
"core:window:allow-unmaximize"
"core:window:allow-unmaximize",
"core:window:allow-set-always-on-top",
"core:window:allow-set-min-size"
]
}
+35
View File
@@ -0,0 +1,35 @@
; atmosphere · hooks.nsh · Uninstaller hooks: offer a backup before removing data, and remove Atmosphere's own data folders only when asked
!macro NSIS_HOOK_PREUNINSTALL
${If} $UpdateMode <> 1
${AndIf} $DeleteAppDataCheckboxState = 1
SetShellVarContext current
MessageBox MB_YESNO|MB_ICONQUESTION "Atmosphere will remove your settings, listening stats, liked songs and artist photos.$\r$\n$\r$\nSave a backup to your Documents folder first? You can restore it later from Settings, Storage.$\r$\n$\r$\nYour music files are never touched." /SD IDNO IDNO atmo_skip_backup
StrCpy $R0 "$DOCUMENTS\Atmosphere backup.zip"
StrCpy $R1 1
atmo_name_loop:
IfFileExists "$R0" 0 atmo_name_done
IntOp $R1 $R1 + 1
StrCpy $R0 "$DOCUMENTS\Atmosphere backup ($R1).zip"
Goto atmo_name_loop
atmo_name_done:
ExecWait '"$INSTDIR\${MAINBINARYNAME}.exe" --backup "$R0"' $R2
${If} $R2 = 0
${AndIf} ${FileExists} "$R0"
MessageBox MB_OK|MB_ICONINFORMATION "Backup saved to:$\r$\n$R0" /SD IDOK
${Else}
MessageBox MB_YESNO|MB_ICONEXCLAMATION "The backup couldn't be saved. Keep your Atmosphere data instead of removing it?" /SD IDYES IDNO atmo_skip_backup
StrCpy $DeleteAppDataCheckboxState 0
${EndIf}
atmo_skip_backup:
${EndIf}
!macroend
!macro NSIS_HOOK_POSTUNINSTALL
${If} $UpdateMode <> 1
${AndIf} $DeleteAppDataCheckboxState = 1
SetShellVarContext current
RmDir /r "$APPDATA\atmosphere"
RmDir /r "$LOCALAPPDATA\atmosphere"
${EndIf}
!macroend
+128
View File
@@ -0,0 +1,128 @@
// atmosphere · backup.rs · Saves and restores settings, library, stats, liked songs and artist photos as one .zip
use crate::engine::data_dir;
use anyhow::{anyhow, bail, Context, Result};
use serde_json::Value;
use std::io::{Read, Write};
use std::path::Path;
const DATA_FILES: &[&str] = &["library.json", "stats.json", "artists.json", "hidden.json", "history.json", "archive.txt"];
const MARKER: &str = "atmosphere-backup.json";
fn artist_photos(data: &Path) -> Vec<String> {
let Ok(bytes) = std::fs::read(data.join("artists.json")) else { return Vec::new() };
let v: Value = serde_json::from_slice(&bytes).unwrap_or_default();
v.as_object()
.map(|m| m.values().filter_map(|a| a["image"].as_str().map(|s| format!("{s}.jpg"))).collect())
.unwrap_or_default()
}
fn safe_name(name: &str) -> bool {
!name.is_empty() && !name.contains("..") && !name.contains('\\') && !name.starts_with('/') && !name.contains(':')
}
pub fn create(dest: &Path) -> Result<usize> {
create_from(&data_dir(), &crate::settings::path(), dest)
}
pub fn restore(src: &Path) -> Result<usize> {
restore_into(&data_dir(), &crate::settings::path(), src)
}
fn create_from(data: &Path, settings: &Path, dest: &Path) -> Result<usize> {
let tmp = dest.with_extension("zip.part");
let file = std::fs::File::create(&tmp).with_context(|| format!("Couldn't write to {}", dest.display()))?;
let mut zip = zip::ZipWriter::new(file);
let opts = zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated);
let put = |zip: &mut zip::ZipWriter<std::fs::File>, name: &str, data: &[u8]| -> Result<()> {
zip.start_file(name, opts)?;
zip.write_all(data)?;
Ok(())
};
let mut count = 0;
let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0);
put(&mut zip, MARKER, serde_json::json!({ "app": "atmosphere", "version": env!("CARGO_PKG_VERSION"), "created": stamp }).to_string().as_bytes())?;
if let Ok(bytes) = std::fs::read(settings) {
put(&mut zip, "settings.json", &bytes)?;
count += 1;
}
for name in DATA_FILES {
if let Ok(bytes) = std::fs::read(data.join(name)) {
put(&mut zip, name, &bytes)?;
count += 1;
}
}
for photo in artist_photos(data) {
if let Ok(bytes) = std::fs::read(data.join("art").join(&photo)) {
put(&mut zip, &format!("art/{photo}"), &bytes)?;
count += 1;
}
}
zip.finish()?;
std::fs::rename(&tmp, dest).or_else(|_| std::fs::copy(&tmp, dest).map(|_| ()).and_then(|_| std::fs::remove_file(&tmp)))?;
Ok(count)
}
fn restore_into(data: &Path, settings: &Path, src: &Path) -> Result<usize> {
let file = std::fs::File::open(src).context("Couldn't open that backup")?;
let mut zip = zip::ZipArchive::new(file).map_err(|_| anyhow!("That file isn't an Atmosphere backup."))?;
if zip.by_name(MARKER).is_err() {
bail!("That file isn't an Atmosphere backup.");
}
let mut count = 0;
for i in 0..zip.len() {
let mut entry = zip.by_index(i)?;
let name = entry.name().map(|n| n.to_string()).unwrap_or_default();
if !entry.is_file() || !safe_name(&name) || name == MARKER {
continue;
}
let target = if name == "settings.json" {
settings.to_path_buf()
} else if DATA_FILES.contains(&name.as_str()) {
data.join(&name)
} else if let Some(photo) = name.strip_prefix("art/").filter(|p: &&str| !p.contains('/') && p.ends_with(".jpg")) {
data.join("art").join(photo)
} else {
continue;
};
let mut bytes = Vec::new();
entry.read_to_end(&mut bytes)?;
if let Some(dir) = target.parent() {
std::fs::create_dir_all(dir)?;
}
std::fs::write(&target, bytes)?;
count += 1;
}
Ok(count)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn backup_round_trips_and_rejects_strangers() {
let root = std::env::temp_dir().join(format!("atmo-backup-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&root);
std::fs::create_dir_all(root.join("art")).unwrap();
std::fs::write(root.join("stats.json"), br#"{"liked":["a"]}"#).unwrap();
std::fs::write(root.join("artists.json"), br#"{"x":{"name":"X","image":"p1"}}"#).unwrap();
std::fs::write(root.join("art").join("p1.jpg"), b"jpg").unwrap();
std::fs::write(root.join("art").join("cover.jpg"), b"thumb").unwrap();
let zip_path = root.join("b.zip");
let set = root.join("cfg").join("settings.json");
std::fs::create_dir_all(set.parent().unwrap()).unwrap();
std::fs::write(&set, b"{}").unwrap();
assert!(create_from(&root, &set, &zip_path).unwrap() >= 4);
std::fs::remove_file(&set).unwrap();
std::fs::remove_file(root.join("stats.json")).unwrap();
std::fs::remove_file(root.join("art").join("p1.jpg")).unwrap();
assert!(restore_into(&root, &set, &zip_path).unwrap() >= 4);
assert!(set.exists());
assert_eq!(std::fs::read(root.join("stats.json")).unwrap(), br#"{"liked":["a"]}"#);
assert!(root.join("art").join("p1.jpg").exists());
std::fs::write(root.join("not.zip"), b"nope").unwrap();
assert!(restore_into(&root, &set, &root.join("not.zip")).is_err());
assert!(!safe_name("../x") && !safe_name("C:x") && safe_name("art/p.jpg"));
let _ = std::fs::remove_dir_all(&root);
}
}
+198
View File
@@ -0,0 +1,198 @@
// atmosphere · direct.rs · Reads real details from direct audio/video file links using ffprobe
use crate::engine::{self, Tools};
use crate::media::{Entry, MediaInfo};
use crate::settings::Settings;
use anyhow::{bail, Result};
use base64::Engine as _;
use serde_json::Value;
use std::path::{Path, PathBuf};
use std::process::Stdio;
use std::time::Duration;
const UA: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36";
const NOT_MEDIA: &str = "That link didn't open as an audio or video file. Make sure it points straight at the file and that anyone can open it without signing in.";
pub fn is_direct(v: &Value) -> bool {
v["direct"].as_bool().unwrap_or(false) && v["_type"].as_str().is_none_or(|t| t == "video")
}
fn ffprobe(tools: &Tools) -> Option<PathBuf> {
let exe = if cfg!(windows) { "ffprobe.exe" } else { "ffprobe" };
tools.ffmpeg.as_ref().and_then(|f| f.parent()).map(|d| d.join(exe)).filter(|p| p.is_file()).or_else(|| engine::find_tool("ffprobe"))
}
fn net_args(settings: &Settings) -> Vec<String> {
let mut a: Vec<String> = ["-user_agent", UA, "-rw_timeout", "20000000"].map(String::from).into();
let proxy = settings.proxy.trim();
if proxy.starts_with("http://") {
a.extend(["-http_proxy".into(), proxy.into()]);
}
a
}
fn tag(tags: &[&Value], key: &str) -> Option<String> {
tags.iter().find_map(|t| {
t.as_object()?
.iter()
.find(|(k, _)| k.eq_ignore_ascii_case(key))
.and_then(|(_, v)| v.as_str())
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
})
}
fn leading_num(s: &str) -> Option<u32> {
s.split(['/', ' ']).next()?.trim().parse().ok()
}
fn kbps(v: &Value) -> Option<u32> {
v.as_str().and_then(|b| b.parse::<f64>().ok()).filter(|b| *b > 0.0).map(|b| (b / 1000.0).round() as u32)
}
fn is_lossless(codec: &str) -> bool {
codec.starts_with("pcm_") || ["flac", "alac", "wavpack", "ape", "tta", "mlp", "truehd"].contains(&codec)
}
fn codec_label(codec: &str) -> String {
match codec {
c if c.starts_with("pcm_") => "pcm".into(),
"mp3" | "mp3float" => "mp3".into(),
"aac" => "aac".into(),
c => c.to_string(),
}
}
async fn run(program: &Path, args: &[String]) -> Option<Vec<u8>> {
let child = engine::command(program).args(args).stdout(Stdio::piped()).stderr(Stdio::null()).kill_on_drop(true).output();
match tokio::time::timeout(Duration::from_secs(45), child).await {
Ok(Ok(out)) if out.status.success() && !out.stdout.is_empty() => Some(out.stdout),
_ => None,
}
}
async fn cover(tools: &Tools, settings: &Settings, url: &str) -> Option<String> {
let ff = tools.ffmpeg.as_ref()?;
let mut args = vec!["-v".into(), "error".into()];
args.extend(net_args(settings));
args.extend(["-i", url, "-map", "0:v:0", "-frames:v", "1", "-c:v", "mjpeg", "-q:v", "3", "-f", "image2pipe", "pipe:1"].map(String::from));
let jpg = run(ff, &args).await?;
let img = image::load_from_memory(&jpg).ok()?;
let img = if img.width() > 600 { img.thumbnail(600, 600) } else { img };
let mut out = Vec::new();
img.to_rgb8().write_to(&mut std::io::Cursor::new(&mut out), image::ImageFormat::Jpeg).ok()?;
Some(format!("data:image/jpeg;base64,{}", base64::engine::general_purpose::STANDARD.encode(out)))
}
pub async fn enrich(tools: &Tools, settings: &Settings, v: &Value, entry: &mut Entry) -> Result<()> {
let url = entry.url.clone();
let Some(probe) = ffprobe(tools) else {
entry.platform = "File link".into();
return Ok(());
};
let mut args = vec!["-v".into(), "error".into(), "-print_format".into(), "json".into(), "-show_format".into(), "-show_streams".into()];
args.extend(net_args(settings));
args.push(url.clone());
let Some(out) = run(&probe, &args).await else { bail!(NOT_MEDIA) };
let info: Value = serde_json::from_slice(&out).unwrap_or_default();
let streams = info["streams"].as_array().cloned().unwrap_or_default();
let is_pic = |s: &Value| s["disposition"]["attached_pic"].as_i64() == Some(1);
let audio = streams.iter().find(|s| s["codec_type"] == "audio");
let video: Vec<&Value> = streams.iter().filter(|s| s["codec_type"] == "video" && !is_pic(s)).collect();
let has_art = streams.iter().any(|s| s["codec_type"] == "video" && is_pic(s));
if audio.is_none() && video.is_empty() {
bail!(NOT_MEDIA);
}
let format = &info["format"];
let mut tag_sources = vec![&format["tags"]];
if let Some(a) = audio {
tag_sources.push(&a["tags"]);
}
let codec = audio.and_then(|a| a["codec_name"].as_str()).unwrap_or("");
let lossless = !codec.is_empty() && is_lossless(codec);
let abr = if lossless {
None
} else {
audio.and_then(|a| kbps(&a["bit_rate"])).or_else(|| video.is_empty().then(|| kbps(&format["bit_rate"])).flatten())
};
let mut heights: Vec<u32> = video.iter().filter_map(|s| s["height"].as_u64().map(|h| h as u32)).collect();
heights.sort_unstable_by(|a, b| b.cmp(a));
heights.dedup();
let ext = v["ext"].as_str().map(str::to_string).or_else(|| url.rsplit('.').next().map(|e| e.split(['?', '#']).next().unwrap_or(e).to_ascii_lowercase()));
entry.media = Some(MediaInfo {
has_video: !video.is_empty(),
heights,
best_abr: abr,
best_codec: (!codec.is_empty()).then(|| codec_label(codec)),
lossless,
original: true,
original_lossless: lossless,
original_ext: ext,
});
entry.detailed = true;
entry.availability = "ok".into();
entry.platform = "File link".into();
if let Some(d) = format["duration"].as_str().and_then(|d| d.parse::<f64>().ok()) {
entry.duration_ms = Some((d * 1000.0) as u64);
}
if let Some(t) = tag(&tag_sources, "title") {
entry.title = t;
}
if let Some(a) = tag(&tag_sources, "artist") {
entry.artist = a.clone();
entry.uploader = a;
}
entry.album = tag(&tag_sources, "album").or(entry.album.take());
entry.album_artist = tag(&tag_sources, "album_artist").or_else(|| tag(&tag_sources, "albumartist")).or(entry.album_artist.take());
entry.genre = tag(&tag_sources, "genre").or(entry.genre.take());
entry.composer = tag(&tag_sources, "composer").or(entry.composer.take());
entry.track_number = tag(&tag_sources, "track").as_deref().and_then(leading_num).or(entry.track_number);
entry.disc_number = tag(&tag_sources, "disc").as_deref().and_then(leading_num).or(entry.disc_number);
if let Some(date) = tag(&tag_sources, "date").or_else(|| tag(&tag_sources, "year")) {
entry.year = date.get(..4).and_then(|y| y.parse().ok()).or(entry.year);
if date.len() >= 10 {
entry.release_date = Some(date[..10].to_string());
}
}
if entry.lyrics.is_none() {
entry.lyrics = tag(&tag_sources, "lyrics").or_else(|| tag(&tag_sources, "unsyncedlyrics"));
}
if entry.thumbnail.is_none() && has_art {
entry.thumbnail = cover(tools, settings, &url).await;
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn reads_tags_case_insensitively_and_numbers() {
let t = serde_json::json!({ "TITLE": "Song", "Track": "3/12" });
assert_eq!(tag(&[&t], "title").as_deref(), Some("Song"));
assert_eq!(tag(&[&t], "track").as_deref().and_then(leading_num), Some(3));
assert!(is_lossless("pcm_s16le") && is_lossless("flac") && !is_lossless("mp3"));
assert_eq!(kbps(&serde_json::json!("320000")), Some(320));
}
#[tokio::test]
#[ignore]
async fn live_direct_mp3_reports_its_real_bitrate() {
let tools = engine::locate("", "").unwrap();
let settings = Settings::default();
let mut e = Entry { url: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3".into(), ..Default::default() };
enrich(&tools, &settings, &serde_json::json!({ "ext": "mp3" }), &mut e).await.unwrap();
let m = e.media.unwrap();
assert_eq!((m.best_abr, m.best_codec.as_deref(), m.original), (Some(192), Some("mp3"), true));
assert!(e.duration_ms.unwrap() > 370_000);
let mut bad = Entry { url: "https://example.com/".into(), ..Default::default() };
assert!(enrich(&tools, &settings, &serde_json::json!({}), &mut bad).await.is_err());
}
#[test]
fn detects_direct_files_only() {
assert!(is_direct(&serde_json::json!({ "direct": true, "_type": "video" })));
assert!(!is_direct(&serde_json::json!({ "_type": "video" })));
assert!(!is_direct(&serde_json::json!({ "direct": true, "_type": "playlist" })));
}
}
+10 -3
View File
@@ -204,7 +204,15 @@ impl Downloader {
Err(e) => job.emit("error", Some(format!("{e:#}")), None),
}
this.flags.lock().unwrap().remove(&p.id);
this.queue.lock().unwrap().running -= 1;
let idle = {
let mut q = this.queue.lock().unwrap();
q.running -= 1;
q.running == 0 && q.pending.is_empty()
};
if idle {
let s = this.settings.lock().unwrap().clone();
let _ = tauri::async_runtime::spawn_blocking(move || crate::storage::clear_stalled(&s)).await;
}
this.pump();
});
}
@@ -758,8 +766,7 @@ mod tests {
#[test]
fn builds_stems_and_escapes_templates() {
let mut settings = Settings::default();
settings.output_dir = "out".into();
let settings = Settings { output_dir: "out".into(), ..Default::default() };
let meta = TagFields { title: "100% Night".into(), track_number: Some(3), track_total: Some(120), ..Default::default() };
let req = JobRequest { entry: entry(None, false, vec![]), meta, folder: Some("Nova - Glass: Vol 1".into()), trim: None, playlist: None };
let stem = file_stem(&settings, &req);
+4
View File
@@ -82,6 +82,10 @@ fn resolve(custom: &str, name: &str) -> (Option<PathBuf>, bool) {
(on_path(name), false)
}
pub fn find_tool(name: &str) -> Option<PathBuf> {
resolve("", name).0
}
pub fn command(program: &Path) -> Command {
let mut cmd = Command::new(program);
cmd.stdin(Stdio::null()).env("PYTHONIOENCODING", "utf-8").env("PYTHONUTF8", "1");
+1 -2
View File
@@ -573,8 +573,7 @@ mod tests {
println!("{title}: provider={:?} synced={:?} words={:?} lines={:?} tried={:?}", l.map(|x| &x.provider), l.map(|x| x.synced), l.map(|x| x.word_synced), l.map(|x| x.lines.len()), f.tried.iter().map(|t| format!("{}: {}", t.provider, t.outcome)).collect::<Vec<_>>());
assert!(l.is_some_and(|x| x.synced));
}
let mut only_netease = Settings::default();
only_netease.lyrics_providers = vec![ProviderCfg { id: "netease".into(), enabled: true }];
let only_netease = Settings { lyrics_providers: vec![ProviderCfg { id: "netease".into(), enabled: true }], ..Default::default() };
let q = Query { title: "Get Lucky".into(), artist: "Daft Punk".into(), duration_ms: Some(248_000), ..Default::default() };
let f = find(&http, &only_netease, &q, true).await.unwrap();
let l = f.lyrics.as_ref();
+94
View File
@@ -1,6 +1,8 @@
// atmosphere · main.rs · App entry point: shared state, the rights gate and every command the UI can call.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
mod backup;
mod direct;
mod downloader;
mod engine;
mod history;
@@ -279,11 +281,88 @@ fn storage_clean(state: State<'_, AppState>, ids: Vec<String>) -> Cleaned {
Cleaned { files, bytes }
}
#[tauri::command]
async fn backup_save(app: AppHandle, name: String) -> CmdResult<Option<(String, usize)>> {
let a = app.clone();
let picked = tauri::async_runtime::spawn_blocking(move || {
let mut d = a.dialog().file().set_title("Back up Atmosphere").set_file_name(&name).add_filter("Atmosphere backup", &["zip"]);
if let Some(docs) = dirs::document_dir() {
d = d.set_directory(docs);
}
d.blocking_save_file()
})
.await
.map_err(|e| e.to_string())?;
let Some(path) = picked.and_then(|p| p.into_path().ok()) else { return Ok(None) };
let p = path.clone();
let n = tauri::async_runtime::spawn_blocking(move || backup::create(&p)).await.map_err(|e| e.to_string())?.map_err(err)?;
Ok(Some((path.to_string_lossy().into_owned(), n)))
}
#[tauri::command]
async fn backup_pick(app: AppHandle) -> CmdResult<Option<String>> {
let picked = tauri::async_runtime::spawn_blocking(move || app.dialog().file().set_title("Restore from a backup").add_filter("Atmosphere backup", &["zip"]).blocking_pick_file())
.await
.map_err(|e| e.to_string())?;
Ok(picked.and_then(|p| p.into_path().ok()).map(|p| p.to_string_lossy().into_owned()))
}
#[tauri::command]
async fn backup_restore(app: AppHandle, state: State<'_, AppState>, path: String) -> CmdResult<()> {
if state.dl.busy() {
return Err("Wait for downloads to finish before restoring.".into());
}
tauri::async_runtime::spawn_blocking(move || backup::restore(std::path::Path::new(&path))).await.map_err(|e| e.to_string())?.map_err(err)?;
app.restart();
}
fn parse_hex(color: &str) -> Option<(u8, u8, u8)> {
let c = color.trim().trim_start_matches('#');
if c.len() != 6 {
return None;
}
let v = u32::from_str_radix(c, 16).ok()?;
Some(((v >> 16) as u8, (v >> 8) as u8, v as u8))
}
#[tauri::command]
fn frame_color(window: tauri::WebviewWindow, color: String) {
let Some((r, g, b)) = parse_hex(&color) else { return };
#[cfg(windows)]
if let Ok(hwnd) = window.hwnd() {
use windows_sys::Win32::Graphics::Dwm::{DwmSetWindowAttribute, DWMWA_BORDER_COLOR};
let colorref: u32 = (r as u32) | ((g as u32) << 8) | ((b as u32) << 16);
unsafe {
DwmSetWindowAttribute(hwnd.0 as _, DWMWA_BORDER_COLOR as _, &colorref as *const u32 as _, 4);
}
}
#[cfg(not(windows))]
let _ = (window, r, g, b);
}
#[tauri::command]
fn startup_cleanup(state: State<'_, AppState>) -> Option<Cleaned> {
state.startup_cleanup.lock().unwrap().take().filter(|(n, _)| *n > 0).map(|(files, bytes)| Cleaned { files, bytes })
}
#[tauri::command]
async fn signin_check(state: State<'_, AppState>, browser: String, file: String) -> CmdResult<String> {
let mut s = state.snapshot();
s.cookies_browser = browser;
s.cookies_file = file;
media::check_signin(&s).await.map_err(err)
}
#[tauri::command]
async fn pick_cookies_file(app: AppHandle) -> CmdResult<Option<String>> {
let picked = tauri::async_runtime::spawn_blocking(move || {
app.dialog().file().set_title("Choose a cookies.txt file").add_filter("Cookies", &["txt"]).blocking_pick_file()
})
.await
.map_err(|e| e.to_string())?;
Ok(picked.and_then(|p| p.into_path().ok()).map(|p| p.to_string_lossy().into_owned()))
}
#[tauri::command]
async fn pick_text_file(app: AppHandle) -> CmdResult<Option<String>> {
let picked = tauri::async_runtime::spawn_blocking(move || {
@@ -320,6 +399,14 @@ fn read_clipboard(app: AppHandle, state: State<'_, AppState>) -> Option<String>
}
fn main() {
let args: Vec<String> = std::env::args().collect();
if let Some(i) = args.iter().position(|a| a == "--backup") {
let code = match args.get(i + 1) {
Some(dest) => i32::from(backup::create(std::path::Path::new(dest)).is_err()),
None => 2,
};
std::process::exit(code);
}
let settings = Arc::new(Mutex::new(settings::load()));
let http = reqwest::Client::builder()
.user_agent(concat!("atmosphere/", env!("CARGO_PKG_VERSION")))
@@ -347,6 +434,12 @@ fn main() {
Ok(())
})
.invoke_handler(tauri::generate_handler![
signin_check,
frame_color,
backup_save,
backup_pick,
backup_restore,
pick_cookies_file,
get_settings,
accept_rights,
revoke_rights,
@@ -409,6 +502,7 @@ fn main() {
if let tauri::RunEvent::Exit = event {
if let Some(state) = app.try_state::<AppState>() {
state.dl.cancel_all();
storage::clear_stalled(&state.snapshot());
}
storage::wipe_temp();
}
+123 -4
View File
@@ -387,7 +387,45 @@ fn release_artist(kind: &str, fallback: &str, entries: &[Entry]) -> String {
fallback.to_string()
}
fn browser_label(id: &str) -> String {
match id.to_ascii_lowercase().as_str() {
"chrome" => "Chrome".into(),
"chromium" => "Chromium".into(),
"edge" => "Edge".into(),
"firefox" => "Firefox".into(),
"brave" => "Brave".into(),
"opera" => "Opera".into(),
"vivaldi" => "Vivaldi".into(),
"safari" => "Safari".into(),
"whale" => "Whale".into(),
_ => "your browser".into(),
}
}
pub fn cookie_error(stderr: &str) -> Option<String> {
let lower = stderr.to_lowercase();
if !lower.contains("cookie") {
return None;
}
static FROM: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)extracting cookies from (\w+)").unwrap());
let b = FROM.captures(stderr).map(|c| browser_label(&c[1])).unwrap_or_else(|| "your browser".into());
if lower.contains("could not copy") || lower.contains("permission denied") || lower.contains("database is locked") {
Some(format!("{b} keeps its sign-in locked while it's running. Quit {b} completely (check the system tray too), then try again. Firefox can stay open, or use a cookies.txt file instead."))
} else if lower.contains("could not find") && lower.contains("cookies database") {
Some(format!("Couldn't find a {b} profile on this computer. Choose the browser you actually sign in with."))
} else if lower.contains("decrypt") || lower.contains("dpapi") || lower.contains("app-bound") || lower.contains("keyring") {
Some(format!("{b} encrypts its sign-in so other apps can't read it. Firefox works, or export a cookies.txt file from {b} and choose it here."))
} else if lower.contains("netscape") || lower.contains("cookiefile") || (lower.contains("cookies") && lower.contains("no such file")) {
Some("That cookies file couldn't be read. It needs to be a cookies.txt export in Netscape format.".into())
} else {
None
}
}
pub fn humanize(stderr: &str) -> String {
if let Some(c) = cookie_error(stderr) {
return c;
}
let err = stderr
.lines()
.rev()
@@ -418,9 +456,18 @@ pub fn base_args(settings: &Settings, tools: &Tools) -> Vec<String> {
args.push("--ffmpeg-location".into());
args.push(ff.to_string_lossy().into_owned());
}
if !settings.cookies_browser.trim().is_empty() {
match settings.cookies_browser.trim() {
"" => {}
"file" => {
if !settings.cookies_file.trim().is_empty() {
args.push("--cookies".into());
args.push(settings.cookies_file.trim().into());
}
}
browser => {
args.push("--cookies-from-browser".into());
args.push(settings.cookies_browser.trim().into());
args.push(browser.into());
}
}
if !settings.proxy.trim().is_empty() {
args.push("--proxy".into());
@@ -504,7 +551,17 @@ impl Prober {
args.extend(["-J", "--flat-playlist", "--", link].map(String::from));
let v = run_json(&tools, args).await?;
let id = format!("c{}", NEXT_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst));
let collection = collection_from(&v, id.clone(), link);
let mut collection = collection_from(&v, id.clone(), link);
if crate::direct::is_direct(&v) {
if let Some(entry) = collection.entries.first_mut() {
crate::direct::enrich(&tools, settings, &v, entry).await?;
collection.title = entry.title.clone();
collection.artist = entry.artist.clone();
collection.thumbnail = entry.thumbnail.clone();
collection.platform = entry.platform.clone();
collection.year = entry.year;
}
}
if collection.enriching {
self.enrich(app.clone(), settings.clone(), tools, collection.clone(), v);
}
@@ -533,7 +590,12 @@ impl Prober {
let tools = engine::locate(&settings.ytdlp_path, &settings.ffmpeg_path)?;
let mut args = base_args(settings, &tools);
args.extend(["-J", "--no-playlist", "--", url].map(String::from));
Ok(entry_from_info(&run_json(&tools, args).await?, index))
let v = run_json(&tools, args).await?;
let mut entry = entry_from_info(&v, index);
if crate::direct::is_direct(&v) {
crate::direct::enrich(&tools, settings, &v, &mut entry).await?;
}
Ok(entry)
}
pub fn cancel(&self, id: &str) {
@@ -673,3 +735,60 @@ mod tests {
assert!(humanize("ERROR: [youtube] abc: Private video. Sign in").contains("browser sign-in"));
}
}
pub fn count_cookie_lines(text: &str) -> usize {
text.lines()
.map(|l| l.strip_prefix("#HttpOnly_").unwrap_or(l))
.filter(|l| !l.starts_with('#') && l.split('\t').count() == 7)
.count()
}
pub async fn check_signin(settings: &Settings) -> Result<String> {
match settings.cookies_browser.trim() {
"" => bail!("Choose a browser or a cookies file first."),
"file" => {
let path = settings.cookies_file.trim();
if path.is_empty() {
bail!("Choose your cookies.txt file first.");
}
let text = tokio::fs::read_to_string(path).await.map_err(|_| anyhow!("That cookies file couldn't be opened."))?;
match count_cookie_lines(&text) {
0 => bail!("That file has no cookies in it. Export a cookies.txt file in Netscape format while you're signed in."),
n => Ok(format!("Found {n} cookies in that file. You're set.")),
}
}
browser => {
let tools = engine::locate(&settings.ytdlp_path, &settings.ffmpeg_path)?;
let mut args = base_args(settings, &tools);
args.extend(["--simulate", "--no-playlist", "--", "https://example.com/"].map(String::from));
let run = engine::command(&tools.ytdlp).args(&args).stdout(Stdio::null()).stderr(Stdio::piped()).kill_on_drop(true).output();
let out = tokio::time::timeout(std::time::Duration::from_secs(60), run).await.map_err(|_| anyhow!("Checking took too long. Try again."))??;
let err = String::from_utf8_lossy(&out.stderr);
static OK: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?i)extracted (\d+) cookies from").unwrap());
if let Some(c) = OK.captures(&err) {
return Ok(format!("Read your {} sign-in ({} cookies). You're set.", browser_label(browser), &c[1]));
}
bail!(cookie_error(&err).unwrap_or_else(|| format!("Couldn't read the {} sign-in. {}", browser_label(browser), humanize(&err))))
}
}
}
#[cfg(test)]
mod signin_tests {
use super::*;
#[test]
fn explains_locked_and_encrypted_browsers() {
let locked = "Extracting cookies from brave\nERROR: Could not copy Chrome cookie database. See https://github.com/yt-dlp/yt-dlp/issues/7271";
assert!(humanize(locked).starts_with("Brave keeps its sign-in locked"));
let enc = "Extracting cookies from chrome\nERROR: Failed to decrypt with DPAPI";
assert!(cookie_error(enc).unwrap().starts_with("Chrome encrypts"));
assert!(cookie_error("ERROR: Unsupported URL").is_none());
}
#[test]
fn counts_netscape_cookie_lines() {
let t = "# Netscape HTTP Cookie File\n.example.com\tTRUE\t/\tTRUE\t0\ta\tb\n#HttpOnly_.x.com\tTRUE\t/\tTRUE\t0\tc\td\nnot a cookie";
assert_eq!(count_cookie_lines(t), 2);
}
}
+5 -2
View File
@@ -59,6 +59,7 @@ pub struct Settings {
pub subtitle_langs: String,
pub embed_chapters: bool,
pub cookies_browser: String,
pub cookies_file: String,
pub proxy: String,
pub rate_limit: String,
pub ytdlp_path: String,
@@ -98,6 +99,7 @@ impl Default for Settings {
subtitle_langs: "en".into(),
embed_chapters: true,
cookies_browser: String::new(),
cookies_file: String::new(),
proxy: String::new(),
rate_limit: String::new(),
ytdlp_path: String::new(),
@@ -135,6 +137,7 @@ pub struct SettingsPatch {
pub subtitle_langs: Option<String>,
pub embed_chapters: Option<bool>,
pub cookies_browser: Option<String>,
pub cookies_file: Option<String>,
pub proxy: Option<String>,
pub rate_limit: Option<String>,
pub ytdlp_path: Option<String>,
@@ -171,7 +174,7 @@ impl Settings {
($($f:ident),*) => { $( if let Some(v) = p.$f { self.$f = v; } )* };
}
set!(save_as, embed_metadata, collection_folders, number_tracks, skip_downloaded, sponsorblock, embed_subtitles, embed_chapters, watch_clipboard);
set!(cookies_browser, proxy, rate_limit, ytdlp_path, ffmpeg_path, subtitle_langs, musixmatch_key, playlist_copy, lyrics_on_download, custom_lyrics, fx_presets);
set!(cookies_browser, cookies_file, proxy, rate_limit, ytdlp_path, ffmpeg_path, subtitle_langs, musixmatch_key, playlist_copy, lyrics_on_download, custom_lyrics, fx_presets);
if let Some(v) = p.library_folders {
let mut seen = std::collections::HashSet::new();
self.library_folders = v.into_iter().map(|f| f.trim().to_string()).filter(|f| !f.is_empty() && seen.insert(f.clone())).collect();
@@ -211,7 +214,7 @@ impl Settings {
}
}
fn path() -> PathBuf {
pub fn path() -> PathBuf {
match crate::engine::portable_root() {
Some(root) => root.join("settings.json"),
None => dirs::config_dir().unwrap_or_else(|| PathBuf::from(".")).join("atmosphere").join("settings.json"),
+6 -4
View File
@@ -67,16 +67,14 @@ fn mb(bytes: u64) -> String {
format!("{:.1} MB", bytes as f64 / 1_048_576.0)
}
pub fn report(settings: &Settings, lib: &Snapshot, busy: bool) -> Vec<Item> {
pub fn report(_settings: &Settings, lib: &Snapshot, busy: bool) -> Vec<Item> {
let temp = all_files(&temp_root());
let stall = if busy { Vec::new() } else { stalled(settings) };
let orphans = orphan_art(lib);
let lyrics = all_files(&data_dir().join("lyrics"));
let art = all_files(&data_dir().join("art"));
let engine = all_files(&bin_dir());
vec![
Item { id: "temp".into(), label: "Temporary files".into(), detail: "Pieces of downloads in progress. Wiped automatically on launch and exit.".into(), bytes: size(&temp), count: temp.len(), cleanable: !busy },
Item { id: "stalled".into(), label: "Stalled partial downloads".into(), detail: if busy { "Checked when no downloads are running.".into() } else { "Unfinished pieces left in your download or playlist folders.".into() }, bytes: size(&stall), count: stall.len(), cleanable: !busy },
Item { id: "temp".into(), label: "Temporary files".into(), detail: "Pieces of downloads in progress. Wiped automatically, along with any stalled partial downloads.".into(), bytes: size(&temp), count: temp.len(), cleanable: !busy },
Item { id: "orphan-art".into(), label: "Unused cover art".into(), detail: "Artwork for songs no longer in your library.".into(), bytes: size(&orphans), count: orphans.len(), cleanable: true },
Item { id: "lyrics".into(), label: "Lyrics cache".into(), detail: "Lyrics fetched online; they're fetched again when needed.".into(), bytes: size(&lyrics), count: lyrics.len(), cleanable: true },
Item { id: "art".into(), label: "Cover art in use".into(), detail: format!("Thumbnails for your library ({}).", mb(size(&art).saturating_sub(size(&orphans)))), bytes: size(&art).saturating_sub(size(&orphans)), count: art.len().saturating_sub(orphans.len()), cleanable: false },
@@ -122,6 +120,10 @@ pub fn clean(settings: &Settings, lib: &Snapshot, ids: &[String], busy: bool) ->
total
}
pub fn clear_stalled(settings: &Settings) -> (usize, u64) {
remove_all(&stalled(settings))
}
pub fn startup(settings: &Settings) -> (usize, u64) {
let a = wipe_temp();
let b = remove_all(&stalled(settings));
+3 -2
View File
@@ -17,7 +17,7 @@
"minWidth": 900,
"minHeight": 620,
"center": true,
"backgroundColor": "#0b0d14",
"backgroundColor": "#0f1117",
"dragDropEnabled": false,
"decorations": false,
"shadow": true
@@ -54,7 +54,8 @@
"installerIcon": "icons/icon.ico",
"headerImage": "installer/nsis-header.bmp",
"sidebarImage": "installer/nsis-sidebar.bmp",
"displayLanguageSelector": false
"displayLanguageSelector": false,
"installerHooks": "installer/hooks.nsh"
},
"wix": {
"bannerPath": "installer/wix-banner.bmp",
+29
View File
@@ -0,0 +1,29 @@
// atmosphere · ui_globals.rs · Fails if two UI scripts declare the same global name, since a later script silently replaces the earlier one
use std::collections::HashMap;
#[test]
fn ui_scripts_share_no_global_names() {
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("ui");
let mut seen: HashMap<String, String> = HashMap::new();
let mut clashes = Vec::new();
for entry in std::fs::read_dir(&dir).unwrap().flatten() {
let path = entry.path();
if path.extension().and_then(|e| e.to_str()) != Some("js") {
continue;
}
let file = path.file_name().unwrap().to_string_lossy().to_string();
for line in std::fs::read_to_string(&path).unwrap().lines() {
let line = line.strip_prefix("async ").unwrap_or(line);
let rest = ["function ", "const ", "let ", "class "].iter().find_map(|k| line.strip_prefix(k));
let Some(rest) = rest else { continue };
let name: String = rest.chars().take_while(|c| c.is_alphanumeric() || *c == '_' || *c == '$').collect();
if name.is_empty() {
continue;
}
if let Some(prev) = seen.insert(name.clone(), file.clone()) {
clashes.push(format!("{name} in {prev} and {file}"));
}
}
}
assert!(clashes.is_empty(), "duplicate globals: {clashes:?}");
}
+76 -2
View File
@@ -30,6 +30,7 @@ const SOURCE = { title: "Detected from the title", metadata: "Detected from trac
const FINAL = new Set(["done", "skipped", "error", "cancelled"]);
const ACTIVE = new Set(["queued", "preparing", "downloading", "processing", "tagging"]);
const PLATFORM_ICON = [
[/^\S+\.(mp3|wav|flac|m4a|aac|ogg|oga|opus|aiff?|wma|alac|mp4|m4v|mov|webm|mkv)(?:[?#]\S*)?$/i, "file-music", "File link"],
[/soundcloud\.com|snd\.sc/i, "brand-soundcloud", "SoundCloud"],
[/youtube\.com|youtu\.be|music\.youtube/i, "brand-youtube", "YouTube"],
[/bandcamp\.com/i, "brand-bandcamp", "Bandcamp"],
@@ -105,6 +106,12 @@ function applyTheme() {
const t = state.settings.theme;
if (t === "light" || t === "dark") document.documentElement.dataset.theme = t;
else delete document.documentElement.dataset.theme;
syncFrame();
}
function syncFrame() {
const color = getComputedStyle(document.documentElement).getPropertyValue("--border").trim();
if (/^#[0-9a-f]{6}$/i.test(color)) invoke("frame_color", { color }).catch(() => {});
}
/* window chrome */
@@ -127,6 +134,7 @@ function bindWindow() {
$("#winMax").addEventListener("click", () => win.toggleMaximize());
$("#winClose").addEventListener("click", () => win.close());
win.onResized?.(() => syncMax());
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", syncFrame);
window.addEventListener("focus", () => bar.classList.remove("blur"));
window.addEventListener("blur", () => bar.classList.add("blur"));
syncMax();
@@ -146,6 +154,8 @@ async function init() {
bindPlayer();
bindLibrary();
bindLyrics();
bindBackup();
bindMini();
bindStats();
await listen("atmosphere://job", (e) => onJob(e.payload));
await listen("atmosphere://probe", (e) => onProbe(e.payload));
@@ -305,6 +315,10 @@ function bindShell() {
fetchText(text);
}
});
document.addEventListener("dragstart", (e) => {
const t = e.target;
if (t.nodeType !== 1 || (t.getAttribute("draggable") !== "true" && !t.closest?.('[draggable="true"]'))) e.preventDefault();
});
document.addEventListener("dragover", (e) => e.preventDefault());
document.addEventListener("drop", (e) => {
e.preventDefault();
@@ -763,7 +777,7 @@ function sheetBody(c) {
)
);
const list = h("ul", { class: "tracklist", role: "listbox", "aria-label": "Tracks", "aria-multiselectable": "true" });
d.entries.forEach((e, i) => list.append(trackRow(c, e, i)));
d.entries.forEach((e, i) => list.append(sheetRow(c, e, i)));
body.append(list);
if (c.inspected != null) {
const e = entryOf(c, c.inspected);
@@ -779,7 +793,7 @@ function unavailableNote(entries) {
return h("span", { class: "warn-note", title: drm ? "If these are your own tracks, enable downloads on them in the platform's track settings, then choose Original file." : "The platform only offers a short preview of these." }, `${parts}, can't be downloaded`);
}
function trackRow(c, e, i) {
function sheetRow(c, e, i) {
const ok = selectable(e);
const m = finalMeta(c, e);
const box = h("input", { type: "checkbox", class: "tl-check", disabled: !ok, "aria-label": `Include ${m.title}` });
@@ -1314,6 +1328,7 @@ function bindSettings() {
const key = el.dataset.key;
el.addEventListener("change", () => patch({ [key]: el.type === "checkbox" ? el.checked : el.value.trim() }));
});
bindSignin();
$("#templateInput").addEventListener("input", renderTemplatePreview);
$("#tokens").replaceChildren(
...TOKENS.map((t) =>
@@ -1371,12 +1386,71 @@ function renderSettings() {
const at = s.rightsAcceptedAt ? new Intl.DateTimeFormat(undefined, { dateStyle: "long" }).format(new Date(s.rightsAcceptedAt * 1000)) : "";
$("#rightsInfo").textContent = at ? `You confirmed it on ${at}. Withdrawing it cancels downloads and asks again.` : "Not confirmed yet.";
renderTemplatePreview();
renderSignin();
renderToolSettings();
renderLibrarySettings();
renderLyricsSettings();
renderStorage();
}
const OS = isMac ? "mac" : /Linux|X11/.test(navigator.userAgent) ? "linux" : "windows";
function signinStatus(text, kind) {
const el = $("#signinStatus");
if (!el) return;
el.hidden = !text;
el.textContent = text || "";
el.dataset.kind = kind || "";
}
function renderSignin() {
const s = state.settings;
const sel = $("#signinSelect");
if (!s || !sel) return;
$$("option[data-os]", sel).forEach((o) => (o.hidden = o.dataset.os !== OS && o.value !== s.cookiesBrowser));
const isFile = s.cookiesBrowser === "file";
$("#cookiesFileRow").hidden = !isFile;
$("#signinCheck").hidden = !s.cookiesBrowser;
$("#cookiesFilePath").textContent = s.cookiesFile || "Export one in Netscape format from a browser you're signed in to, using a cookies.txt extension.";
$("#cookiesFilePath").title = s.cookiesFile || "";
}
async function checkSignin() {
const b = $("#signinCheck");
b.classList.add("loading");
b.disabled = true;
signinStatus("Checking…", "");
try {
signinStatus(await invoke("signin_check", { browser: state.settings.cookiesBrowser, file: state.settings.cookiesFile || "" }), "ok");
} catch (e) {
signinStatus(errText(e), "err");
} finally {
b.disabled = false;
b.classList.remove("loading");
}
}
function bindSignin() {
$("#signinSelect")?.addEventListener("change", async (e) => {
const v = e.target.value;
signinStatus("");
await patch({ cookiesBrowser: v });
renderSignin();
if (v === "file" && !state.settings.cookiesFile) pickCookies();
else if (v) checkSignin();
});
$("#signinCheck")?.addEventListener("click", checkSignin);
$("#cookiesFilePick")?.addEventListener("click", pickCookies);
}
async function pickCookies() {
const path = await invoke("pick_cookies_file").catch((e) => (toast(errText(e), "err"), null));
if (!path) return;
await patch({ cookiesFile: path });
renderSignin();
checkSignin();
}
function renderToolSettings() {
const t = state.tools;
if (!t || !$("#toolYtdlp")) return;
+1 -1
View File
File diff suppressed because one or more lines are too long
+29 -4
View File
@@ -97,6 +97,7 @@
<li><span class="i" data-icon="music"></span><div><strong>A track or video</strong><span>Saved as one file, with its cover and details.</span></div></li>
<li><span class="i" data-icon="disc"></span><div><strong>An album, EP or playlist</strong><span>Detected, numbered in order, kept in one folder.</span></div></li>
<li><span class="i" data-icon="user-circle"></span><div><strong>A profile or channel</strong><span>Every upload, listed so you can pick.</span></div></li>
<li><span class="i" data-icon="file-music"></span><div><strong>A direct file link</strong><span>Links ending in .mp3, .wav, .flac, .mp4 and more, checked and read for their real quality and tags.</span></div></li>
</ul>
<p class="hint">Tip: drag a link onto this window, or press <kbd>Ctrl V</kbd> anywhere.</p>
</div>
@@ -195,6 +196,7 @@
<div class="group" id="lyricsProviders"></div>
<div class="group gap-top">
<div class="setting"><div><strong>Musixmatch API key</strong><span>A developer API key from developer.musixmatch.com (free tier available). Stays on this device.</span></div><input class="text" type="password" data-key="musixmatchKey" placeholder="Not set" spellcheck="false" autocomplete="off" /></div>
<label class="setting"><div><strong>Soft focus around the current line</strong><span>Blurs synced lyrics more the further they are from what's being sung. Hover any line to read it clearly.</span></div><input type="checkbox" class="switch" id="lyricsBlurToggle" /></label>
<label class="setting"><div><strong>Save lyrics with downloads</strong><span>Writes a synced .lrc file next to each song you download, when lyrics are found.</span></div><input type="checkbox" class="switch" data-key="lyricsOnDownload" /></label>
</div>
<h2 class="sub">Custom sources</h2>
@@ -228,11 +230,27 @@
<h2 id="set-network">Network &amp; sign-in</h2>
<div class="group">
<div class="setting">
<div><strong>Use my browser sign-in</strong><span>Lets Atmosphere reach content your account can already see, like your own private uploads. Your sign-in stays in your browser.</span></div>
<select data-key="cookiesBrowser">
<option value="">Off</option><option value="chrome">Chrome</option><option value="edge">Edge</option><option value="firefox">Firefox</option><option value="brave">Brave</option><option value="opera">Opera</option><option value="vivaldi">Vivaldi</option>
<div class="setting signin">
<div><strong>Use my browser sign-in</strong><span>Lets Atmosphere reach content your account can already see, like your own private uploads. Your sign-in stays on this computer.</span><p class="signin-status" id="signinStatus" role="status" hidden></p></div>
<div class="signin-ctl">
<select data-key="cookiesBrowser" id="signinSelect">
<option value="">Off</option>
<option value="firefox">Firefox</option>
<option value="chrome">Chrome</option>
<option value="edge">Edge</option>
<option value="brave">Brave</option>
<option value="opera">Opera</option>
<option value="vivaldi">Vivaldi</option>
<option value="chromium" data-os="linux">Chromium</option>
<option value="safari" data-os="mac">Safari</option>
<option value="file">A cookies.txt file</option>
</select>
<button class="btn" id="signinCheck" type="button"><span class="label">Check</span><span class="spin" aria-hidden="true"></span></button>
</div>
</div>
<div class="setting" id="cookiesFileRow" hidden>
<div><strong>Cookies file</strong><span id="cookiesFilePath">Export one in Netscape format from a browser you're signed in to, using a cookies.txt extension.</span></div>
<button class="btn" id="cookiesFilePick" type="button">Choose file</button>
</div>
<div class="setting"><div><strong>Speed limit</strong><span>Blank for no limit. For example <code>2M</code> is 2 MB/s.</span></div><input class="text short" data-key="rateLimit" placeholder="No limit" spellcheck="false" /></div>
<div class="setting"><div><strong>Proxy</strong><span>For example <code>socks5://127.0.0.1:1080</code></span></div><input class="text" data-key="proxy" placeholder="None" spellcheck="false" /></div>
@@ -250,6 +268,10 @@
<h2 id="set-storage">Storage</h2>
<p class="set-note">Temporary files are removed automatically on every launch and exit. Here's everything else Atmosphere keeps.</p>
<div class="group" id="storageList"></div>
<div class="group">
<div class="setting"><div><strong>Back up your data</strong><span>Settings, stats and play counts, liked songs, artist photos and download history in one .zip. Your music isn't included and is never touched.</span></div><button class="btn" id="backupBtn" type="button"><span class="label">Back up</span><span class="spin" aria-hidden="true"></span></button></div>
<div class="setting"><div><strong>Restore from a backup</strong><span>Replaces your current settings and stats with the backup's, then restarts Atmosphere.</span></div><button class="btn" id="restoreBtn" type="button">Restore</button></div>
</div>
<h2 id="set-rights">Your responsibility</h2>
<div class="group">
@@ -284,6 +306,7 @@
<button class="icon-btn" id="fxBtn" aria-label="Sound and effects" aria-pressed="false" aria-expanded="false" title="Sound, presets, pitch and tempo"><span class="i" data-icon="adjustments-horizontal"></span></button>
<button class="icon-btn" id="lyricsBtn" aria-label="Lyrics" aria-pressed="false" title="Lyrics (L)"><span class="i" data-icon="microphone"></span></button>
<button class="icon-btn" id="queueBtn" aria-label="Queue" aria-pressed="false" title="Queue (Q)"><span class="i" data-icon="list"></span></button>
<button class="icon-btn" id="miniBtn" aria-label="Mini player" title="Mini player (P)"><span class="i" data-icon="picture-in-picture"></span></button>
<button class="icon-btn" id="tvBtn" aria-label="TV mode" title="TV mode (F)"><span class="i" data-icon="device-tv"></span></button>
<button class="icon-btn" id="muteBtn" aria-label="Mute"></button>
<input type="range" id="volume" class="range vol" min="0" max="100" value="85" aria-label="Volume" />
@@ -294,6 +317,7 @@
<aside class="drawer-panel" id="queuePanel" aria-label="Queue" hidden></aside>
<div class="fx" id="fxPanel" role="dialog" aria-label="Sound and effects" hidden></div>
<div class="tv" id="tv" hidden></div>
<div class="mini" id="mini" hidden></div>
<div class="save-menu" id="saveMenu" role="dialog" aria-label="Save as" hidden></div>
<div class="menu" id="typeMenu" role="menu" hidden></div>
@@ -334,5 +358,6 @@
<script src="nowplaying.js"></script>
<script src="lyrics.js"></script>
<script src="stats.js"></script>
<script src="miniplayer.js"></script>
</body>
</html>
+35
View File
@@ -696,6 +696,41 @@ function renderLibrarySettings() {
h("button", { class: "btn", disabled: !hidden, onclick: async () => { const n = await invoke("tracks_unhide_all"); toast(`Restoring ${songs(n)}…`, "ok"); } }, "Restore all"));
}
async function backupNow() {
const b = $("#backupBtn");
const d = new Date();
const name = `Atmosphere backup ${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}.zip`;
b.classList.add("loading");
b.disabled = true;
try {
const r = await invoke("backup_save", { name });
if (r) toast(`Backed up ${r[1]} items to ${r[0].split(/[\\/]/).pop()}`, "ok");
} catch (e) {
toast(errText(e), "err");
} finally {
b.disabled = false;
b.classList.remove("loading");
}
}
async function restoreNow() {
const path = await invoke("backup_pick").catch(() => null);
if (!path) return;
const body = h("p", {}, "Your current settings, stats, liked songs and artist photos will be replaced by the ones in ", h("strong", {}, path.split(/[\\/]/).pop()), ". Your music files stay as they are. Atmosphere restarts afterwards.");
const ok = await modal("Restore this backup?", body, [{ label: "Cancel", value: false }, { label: "Restore and restart", value: true, primary: true }]);
if (!ok) return;
try {
await invoke("backup_restore", { path });
} catch (e) {
toast(errText(e), "err");
}
}
function bindBackup() {
$("#backupBtn")?.addEventListener("click", backupNow);
$("#restoreBtn")?.addEventListener("click", restoreNow);
}
async function renderStorage() {
const box = $("#storageList");
if (!box) return;
+28 -1
View File
@@ -43,13 +43,26 @@ async function loadLyrics(refresh = false) {
}
}
const blurOn = () => {
try {
return localStorage.getItem("atmo.lyricsBlur") !== "off";
} catch {
return true;
}
};
function setDepth(box, idx) {
$$(".lyr-line", box).forEach((el, i) => el.style.setProperty("--dist", String(Math.min(Math.abs(i - Math.max(idx, -1)) || 0, 4))));
}
function lyricLines(l, big) {
const box = h("div", { class: `lyr ${big ? "big" : ""} ${l.synced ? "synced" : "plain"}` });
const box = h("div", { class: `lyr ${big ? "big" : ""} ${l.synced ? "synced" : "plain"} ${l.synced && blurOn() ? "depth" : ""}` });
l.lines.forEach((line, i) => {
const el = h("div", { class: "lyr-line", "data-i": i, role: l.synced ? "button" : null, tabindex: l.synced ? "0" : null, onclick: () => line.t != null && Player.seek((line.t - Lyr.offset) / 1000) });
if (line.words?.length > 1) line.words.forEach((w, j) => el.append(h("span", { class: "w", "data-j": j }, w.text)));
else el.append(line.text || "· · ·");
if (line.translation) el.append(h("span", { class: "lyr-tr" }, line.translation));
if (l.synced) el.style.setProperty("--dist", String(Math.min(i + 1, 4)));
box.append(el);
});
return box;
@@ -161,6 +174,7 @@ function tick() {
el.classList.toggle("on", i === idx);
el.classList.toggle("past", i < idx);
});
if (box.classList.contains("depth")) setDepth(box, idx);
const cur = box.querySelector(".lyr-line.on");
if (cur) cur.scrollIntoView({ block: "center", behavior: reduced.matches ? "auto" : "smooth" });
}
@@ -367,7 +381,20 @@ function renderLyricsSettings() {
);
}
function renderBlurSetting() {
const sw = $("#lyricsBlurToggle");
if (!sw) return;
sw.checked = blurOn();
}
function bindLyrics() {
$("#lyricsBlurToggle")?.addEventListener("change", (e) => {
try {
localStorage.setItem("atmo.lyricsBlur", e.target.checked ? "on" : "off");
} catch {}
$$(".lyr.synced").forEach((b) => b.classList.toggle("depth", e.target.checked));
});
renderBlurSetting();
window.addEventListener("player", (e) => {
if (e.detail.type === "track") {
Lyr.offset = 0;
+211
View File
@@ -0,0 +1,211 @@
// atmosphere · miniplayer.js · Compact always-on-top player with optional cover, blurred backdrop and an editable queue
const Mini = {
on: false,
restore: null,
prefs: { cover: true, blur: true, queue: false, pin: true },
dragFrom: null,
};
const MINI_W = 340;
const MINI_BASE = 168;
const MINI_COVER = 300;
const MINI_QUEUE = 232;
function miniLoad() {
try {
Object.assign(Mini.prefs, JSON.parse(localStorage.getItem("atmo.mini") || "{}"));
} catch {}
}
function miniSave() {
try {
localStorage.setItem("atmo.mini", JSON.stringify(Mini.prefs));
} catch {}
}
const miniWin = () => window.__TAURI__?.window?.getCurrentWindow?.();
function miniHeight() {
return MINI_BASE + (Mini.prefs.cover ? MINI_COVER : 0) + (Mini.prefs.queue ? MINI_QUEUE : 0);
}
async function miniResize() {
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(() => {});
}
async function openMini() {
if (Mini.on) return;
if (typeof closeTv === "function" && Lyr?.tv) await closeTv();
closeDrawers();
closeFx();
Mini.on = true;
document.body.classList.add("mini-mode");
$("#mini").hidden = false;
$("#mini").classList.toggle("mac", isMac);
const win = miniWin();
if (win) {
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.setAlwaysOnTop(!!Mini.prefs.pin).catch(() => {});
}
renderMini();
}
async function closeMini() {
if (!Mini.on) return;
Mini.on = false;
document.body.classList.remove("mini-mode");
$("#mini").hidden = true;
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.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(() => {});
if (r?.max) await win.maximize().catch(() => {});
}
async function miniToggle(key) {
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();
}
function miniButton(key, iconName, label) {
const on = !!Mini.prefs[key];
return h("button", { class: "icon-btn mini-opt", "aria-pressed": String(on), "aria-label": label, title: label, onclick: () => miniToggle(key) }, icon(iconName));
}
function miniQueueRow(t, i) {
const row = h("div", { class: "mq-row", draggable: "true", "data-qi": i, ondblclick: () => Player.load(i) },
h("span", { class: "mq-grip", "aria-hidden": "true" }, icon("grip-vertical")),
h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, t.title), h("span", { class: "lt-sub" }, t.artist)),
h("button", { class: "icon-btn", "aria-label": `Remove ${t.title}`, title: "Remove", onclick: (e) => { e.stopPropagation(); Player.removeAt(i); } }, icon("x")));
row.addEventListener("dragstart", (e) => {
Mini.dragFrom = i;
e.dataTransfer.effectAllowed = "move";
e.dataTransfer.setData("text/plain", "");
row.classList.add("dragging");
});
row.addEventListener("dragend", () => row.classList.remove("dragging"));
row.addEventListener("dragover", (e) => {
if (Mini.dragFrom == null) return;
e.preventDefault();
const r = row.getBoundingClientRect();
row.classList.toggle("drop-above", e.clientY < r.top + r.height / 2);
row.classList.toggle("drop-below", e.clientY >= r.top + r.height / 2);
});
row.addEventListener("dragleave", () => row.classList.remove("drop-above", "drop-below"));
row.addEventListener("drop", (e) => {
e.preventDefault();
const below = row.classList.contains("drop-below");
row.classList.remove("drop-above", "drop-below");
const from = Mini.dragFrom;
Mini.dragFrom = null;
if (from == null) return;
moveInQueue(from, below ? i + 1 : i);
});
return row;
}
function moveInQueue(from, to) {
const q = Player.queue;
if (from <= Player.index || from >= q.length) return;
const [t] = q.splice(from, 1);
const dest = Math.max(Player.index + 1, Math.min(q.length, to > from ? to - 1 : to));
q.splice(dest, 0, t);
Player.emit("queue");
Player.persist();
}
function renderMini() {
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");
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));
miniTime();
}
function miniTime() {
if (!Mini.on) return;
const seek = $("#miniSeek");
if (!seek || document.activeElement === seek) return;
const a = Player.audio;
const d = isFinite(a.duration) ? a.duration : 0;
seek.value = d ? String(Math.round((a.currentTime / d) * 1000)) : "0";
rangeFill(seek);
$("#miniCur").textContent = fmtDur(a.currentTime * 1000);
$("#miniDur").textContent = d ? fmtDur(d * 1000) : "0:00";
}
function bindMini() {
miniLoad();
$("#miniBtn")?.addEventListener("click", () => (Mini.on ? closeMini() : openMini()));
window.addEventListener("player", (e) => {
if (!Mini.on) return;
const type = e.detail.type;
if (type === "time") return miniTime();
if (type === "volume" || type === "fx") return;
renderMini();
});
document.addEventListener("keydown", (e) => {
if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey || e.ctrlKey || e.metaKey) return;
if (e.key.toLowerCase() === "p") {
e.preventDefault();
Mini.on ? closeMini() : openMini();
} else if (e.key === "Escape" && Mini.on) closeMini();
});
}
+1
View File
@@ -315,6 +315,7 @@ function bindPlayer() {
if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey) return;
const mod = e.ctrlKey || e.metaKey;
const k = e.key;
if (document.body.classList.contains("mini-mode") && /^[lqf]$/i.test(k)) return;
if (k === " " && !mod) { e.preventDefault(); Player.toggle(); }
else if (k === "ArrowRight" && mod) { e.preventDefault(); Player.next(); }
else if (k === "ArrowLeft" && mod) { e.preventDefault(); Player.prev(); }
+67
View File
@@ -882,3 +882,70 @@ input[type="checkbox"].box:checked::after { content: ""; width: 8px; height: 4px
.share-side h3 { font-size: 12px; color: var(--text-2); margin-top: var(--s2); }
.share-side .row { margin-top: var(--s3); flex-wrap: wrap; }
@media (max-width: 1100px) { .stat-cards { grid-template-columns: 1fr 1fr; } .stat-split { grid-template-columns: 1fr; } .share { grid-template-columns: 1fr; } }
/* lyric depth of field */
.lyr.depth .lyr-line { filter: blur(calc(var(--dist, 2) * 0.7px)); transition: color 180ms var(--ease), opacity 180ms var(--ease), filter 320ms var(--ease); }
.lyr.depth .lyr-line.on { filter: none; }
.lyr.depth .lyr-line:hover, .lyr.depth .lyr-line:focus-visible { filter: none; opacity: 0.95; transition-duration: 120ms; }
.lyr.big.depth .lyr-line { filter: blur(calc(var(--dist, 2) * 1.4px)); }
.lyr.big.depth .lyr-line.on, .lyr.big.depth .lyr-line:hover, .lyr.big.depth .lyr-line:focus-visible { filter: none; }
@media (prefers-reduced-motion: reduce) { .lyr.depth .lyr-line { transition: none !important; } }
/* nothing visual drags out of the app */
img, svg, canvas, picture, a { -webkit-user-drag: none; user-drag: none; }
img { user-select: none; }
[draggable="true"] { -webkit-user-drag: element; }
/* browser sign-in */
.signin-ctl { display: flex; gap: var(--s2); align-items: center; flex-shrink: 0; }
.signin-status { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-2); max-width: 60ch; }
.signin-status[data-kind="ok"] { color: var(--ok); }
.signin-status[data-kind="err"] { color: var(--err); }
#cookiesFilePath { overflow-wrap: anywhere; }
/* 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[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-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-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-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-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.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); }
.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:hover { background: var(--hover); }
.mq-row .icon-btn { opacity: 0; }
.mq-row:hover .icon-btn, .mq-row:focus-within .icon-btn { opacity: 1; }
.mq-grip { color: var(--text-3); display: grid; place-items: center; }
.mq-grip .i svg { width: 14px; height: 14px; }
.mq-row.dragging { opacity: 0.4; }
.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; }