mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Windows-only, release fixes, Discord covers, and layouts that fit the window
- Atmosphere is now Windows-only: macOS and Linux code, bundle settings and CI are removed - Releases build as drafts and publish once the build succeeds; failing tests show as error notes - Every release lists its Windows downloads and warns that the app isn't code-signed yet, so SmartScreen or antivirus may flag it - Library tests no longer share one data folder at the same time - Discord: the song's cover (Deezer, then Apple Music) as the big image with the logo as a badge; built-in app ID; invite cover in the image kit; clearer status setting - Dialogs, menus and popovers stay inside the window and scroll instead of running off screen - Expandable settings rows show a chevron - Band names with & stay one artist unless both names are already separate artists
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<!-- install-notes -->
|
||||
|
||||
### Downloads
|
||||
|
||||
| File | What it is |
|
||||
| --- | --- |
|
||||
| `Atmosphere_*_x64-setup.exe` | The installer (recommended). Updates itself from then on. |
|
||||
| `Atmosphere_*_x64_en-US.msi` | The same app as an MSI, for managed installs. |
|
||||
| `Atmosphere_*_x64-portable.exe` | No install. Keeps its data beside the file when you add a `portable` file next to it. |
|
||||
|
||||
Atmosphere runs on Windows 10 and 11 (64-bit).
|
||||
|
||||
> [!WARNING]
|
||||
> **Atmosphere isn't code-signed yet**, so Windows SmartScreen may say "Windows protected your PC", and some antivirus apps may flag it as a false positive. To install anyway, choose **More info → Run anyway**.
|
||||
> Every file here is built from this repository's source by GitHub Actions, and in-app updates are still signature-checked before they install.
|
||||
+11
-29
@@ -1,4 +1,4 @@
|
||||
# atmosphere · build.yml · CI: runs the tests and builds installers for Windows, macOS (Apple Silicon + Intel) and Linux.
|
||||
# atmosphere · build.yml · CI: runs the tests and builds the Windows installers and portable app.
|
||||
name: build
|
||||
|
||||
on:
|
||||
@@ -9,34 +9,22 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
name: windows-x64
|
||||
- os: macos-latest
|
||||
name: macos-arm64
|
||||
- os: macos-13
|
||||
name: macos-x64
|
||||
- os: ubuntu-22.04
|
||||
name: linux-x64
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Linux system libraries
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Tests
|
||||
run: cargo test --locked
|
||||
shell: bash
|
||||
run: |
|
||||
set -o pipefail
|
||||
if ! cargo test --locked 2>&1 | tee test.log; then
|
||||
grep -E "^---- |panicked at|^ left|^ right|error(\[E[0-9]+\])?:" test.log | head -40 | while IFS= read -r line; do echo "::error title=Test failure::$line"; done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install Tauri CLI
|
||||
run: cargo install tauri-cli --version "^2" --locked
|
||||
@@ -46,22 +34,16 @@ jobs:
|
||||
run: cargo tauri build --config '{"bundle":{"createUpdaterArtifacts":false}}'
|
||||
|
||||
- name: Portable executable
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: atmosphere-portable-${{ matrix.name }}
|
||||
name: atmosphere-portable-windows-x64
|
||||
path: target/release/atmosphere.exe
|
||||
if-no-files-found: error
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: atmosphere-${{ matrix.name }}
|
||||
name: atmosphere-windows-x64
|
||||
path: |
|
||||
target/release/bundle/**/*.msi
|
||||
target/release/bundle/**/*.exe
|
||||
target/release/bundle/**/*.dmg
|
||||
target/release/bundle/**/*.app.tar.gz
|
||||
target/release/bundle/**/*.deb
|
||||
target/release/bundle/**/*.rpm
|
||||
target/release/bundle/**/*.AppImage
|
||||
if-no-files-found: error
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# atmosphere · release.yml · On a version tag, builds and signs every platform and publishes a GitHub Release with latest.json for in-app updates.
|
||||
# atmosphere · release.yml · On a version tag, builds and signs the Windows installers into a draft release, then publishes it with latest.json.
|
||||
name: release
|
||||
|
||||
on:
|
||||
@@ -8,9 +8,13 @@ on:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: windows-latest
|
||||
outputs:
|
||||
version: ${{ steps.v.outputs.version }}
|
||||
notes: ${{ steps.v.outputs.notes }}
|
||||
@@ -30,39 +34,29 @@ jobs:
|
||||
{
|
||||
echo "notes<<ATMO_NOTES_END"
|
||||
sed '/^<!--/d' RELEASE_NOTES.md
|
||||
echo
|
||||
cat .github/release-footer.md
|
||||
echo "ATMO_NOTES_END"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
publish:
|
||||
needs: check
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
name: windows-x64
|
||||
- os: macos-latest
|
||||
name: macos-arm64
|
||||
- os: macos-13
|
||||
name: macos-x64
|
||||
- os: ubuntu-22.04
|
||||
name: linux-x64
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Linux system libraries
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Tests
|
||||
run: cargo test --locked
|
||||
shell: bash
|
||||
run: |
|
||||
set -o pipefail
|
||||
if ! cargo test --locked 2>&1 | tee test.log; then
|
||||
grep -E "^---- |panicked at|^ left|^ right|error(\[E[0-9]+\])?:" test.log | head -40 | while IFS= read -r line; do echo "::error title=Test failure::$line"; done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install Tauri CLI
|
||||
run: cargo install tauri-cli --version "^2" --locked
|
||||
@@ -78,15 +72,23 @@ jobs:
|
||||
tagName: v__VERSION__
|
||||
releaseName: Atmosphere __VERSION__
|
||||
releaseBody: ${{ needs.check.outputs.notes }}
|
||||
releaseDraft: false
|
||||
releaseDraft: true
|
||||
prerelease: false
|
||||
includeUpdaterJson: true
|
||||
|
||||
- name: Portable executable
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
cp target/release/atmosphere.exe "Atmosphere_${{ needs.check.outputs.version }}_x64-portable.exe"
|
||||
gh release upload "$GITHUB_REF_NAME" "Atmosphere_${{ needs.check.outputs.version }}_x64-portable.exe" --clobber
|
||||
|
||||
finalize:
|
||||
needs: publish
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Publish the release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
|
||||
Generated
-27
@@ -247,14 +247,12 @@ dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"image",
|
||||
"lofty",
|
||||
"lzma-rs",
|
||||
"notify",
|
||||
"regex",
|
||||
"reqwest 0.12.28",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.11.1",
|
||||
"tar",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-clipboard-manager",
|
||||
@@ -776,21 +774,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d"
|
||||
dependencies = [
|
||||
"crc-catalog",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc-catalog"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.5"
|
||||
@@ -2562,16 +2545,6 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"
|
||||
|
||||
[[package]]
|
||||
name = "lzma-rs"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"crc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markup5ever"
|
||||
version = "0.39.0"
|
||||
|
||||
@@ -26,14 +26,12 @@ getrandom = "0.3"
|
||||
futures-util = "0.3.34"
|
||||
image = { version = "0.25.10", default-features = false, features = ["jpeg", "png"] }
|
||||
lofty = "0.25.5"
|
||||
lzma-rs = "0.3.0"
|
||||
notify = "8.2.2"
|
||||
regex = "1.13.2"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "rustls-tls", "gzip", "http2"] }
|
||||
serde = { version = "1.0.229", features = ["derive"] }
|
||||
serde_json = "1.0.154"
|
||||
sha2 = { version = "0.11.1", default-features = false }
|
||||
tar = "0.4.46"
|
||||
tauri = { version = "2", features = ["image-png"] }
|
||||
tauri-plugin-clipboard-manager = "2"
|
||||
tauri-plugin-dialog = "2"
|
||||
@@ -45,8 +43,6 @@ trash = "5.4.0"
|
||||
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]
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
<p align="center">
|
||||
<b>Your music, beautifully kept.</b><br>
|
||||
A fast, native music library, player and downloader for Windows, macOS and Linux.
|
||||
A fast, native music library, player and downloader for Windows.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img alt="Windows · macOS · Linux" src="https://img.shields.io/badge/platform-Windows%20%C2%B7%20macOS%20%C2%B7%20Linux-5b63e6?style=flat-square">
|
||||
<img alt="Windows 10 and 11" src="https://img.shields.io/badge/platform-Windows%2010%20%C2%B7%2011-5b63e6?style=flat-square">
|
||||
<img alt="Built with Rust and Tauri 2" src="https://img.shields.io/badge/built%20with-Rust%20%2B%20Tauri%202-171a23?style=flat-square&logo=rust">
|
||||
<img alt="Engine: yt-dlp and ffmpeg" src="https://img.shields.io/badge/engine-yt--dlp%20%2B%20ffmpeg-171a23?style=flat-square">
|
||||
<img alt="Size: about 8 MB" src="https://img.shields.io/badge/app%20size-~8%20MB-171a23?style=flat-square">
|
||||
@@ -142,32 +142,23 @@ It's built for media you **own or have the rights to keep**, such as your own 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**.
|
||||
- **Automatic updates:** Atmosphere checks this repo's releases when it opens and every few hours while it's open. When there's a new version, a notice shows what's new with **Update and restart**: one click downloads it, verifies its signature, installs it and reopens Atmosphere where you left off. You can turn checking off in Settings.
|
||||
- **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.
|
||||
- **Clean uninstall:** the 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
|
||||
|
||||
### Download
|
||||
Grab the latest version from [Releases](../../releases/latest). Installed copies keep themselves up to date.
|
||||
Grab the latest version from [Releases](../../releases/latest) for Windows 10 or 11: the setup `.exe`, the `.msi`, or the portable `atmosphere.exe`. Installed copies keep themselves up to date.
|
||||
|
||||
| Platform | Files |
|
||||
| --- | --- |
|
||||
| Windows | Setup `.exe`, `.msi`, or the portable `atmosphere.exe` |
|
||||
| macOS | `.dmg` (Apple Silicon and Intel) |
|
||||
| Linux | `.deb`, `.rpm`, `.AppImage` |
|
||||
> [!WARNING]
|
||||
> Atmosphere isn't code-signed yet, so Windows SmartScreen may say "Windows protected your PC", and some antivirus apps may flag it as a false positive. Choose **More info → Run anyway** to install. Every release is built from this repository by GitHub Actions, and in-app updates are signature-checked before they install.
|
||||
|
||||
On first launch:
|
||||
1. Confirm the three rights statements. The Windows installer covers this on its licence page.
|
||||
2. Let Atmosphere set up its engine: [yt-dlp](https://github.com/yt-dlp/yt-dlp) and [ffmpeg](https://ffmpeg.org), downloaded from their official releases and checksum-verified. On macOS, install ffmpeg with `brew install ffmpeg`.
|
||||
1. Confirm the three rights statements. The installer covers this on its licence page.
|
||||
2. Let Atmosphere set up its engine: [yt-dlp](https://github.com/yt-dlp/yt-dlp) and [ffmpeg](https://ffmpeg.org), downloaded from their official releases and checksum-verified.
|
||||
3. Add your music folders in **Settings → Library**, or paste a link.
|
||||
|
||||
### Build from source
|
||||
You'll need [Rust](https://rustup.rs). On Linux, also install the WebKitGTK dependencies:
|
||||
|
||||
```bash
|
||||
sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
```
|
||||
|
||||
Run the app:
|
||||
You'll need Windows and [Rust](https://rustup.rs). Run the app:
|
||||
|
||||
```bash
|
||||
cargo run --release
|
||||
@@ -200,13 +191,11 @@ cargo tauri build
|
||||
| `Delete` | Delete the selected songs (with confirmation) |
|
||||
| `Ctrl A` | Select all in the current list |
|
||||
|
||||
On macOS, use `⌘` in place of `Ctrl`.
|
||||
|
||||
## Responsible use
|
||||
|
||||
Atmosphere is for media you own or are allowed to keep.
|
||||
|
||||
- **Before first use**, you agree to three statements about rights and responsibility. On Windows, that's the installer's licence page. The portable app, macOS and Linux ask once inside the app. **Each download** also asks for confirmation. The app's backend enforces both, not only the UI.
|
||||
- **Before first use**, you agree to three statements about rights and responsibility. The installer covers this on its licence page, and the portable app asks once inside the app. **Each download** also asks for confirmation. The app's backend enforces both, not only the UI.
|
||||
- It **never bypasses DRM or paywalls**, and skips preview-only media, the same way yt-dlp itself refuses encrypted formats.
|
||||
- **Artists recovering their own uploads** can enable downloads on the track and choose **Original file** to get the uploaded master.
|
||||
|
||||
|
||||
+160
-37
@@ -11,7 +11,7 @@ use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::time::{timeout, Instant};
|
||||
|
||||
pub const BUILTIN_CLIENT_ID: &str = "";
|
||||
pub const BUILTIN_CLIENT_ID: &str = "1573218461658648768";
|
||||
pub const ASSET_LOGO: &str = "atmosphere";
|
||||
pub const ASSET_PAUSED: &str = "paused";
|
||||
const LOGO_PNG: &[u8] = include_bytes!("../icons/icon.png");
|
||||
@@ -215,11 +215,11 @@ impl Worker {
|
||||
}
|
||||
}
|
||||
let wanted = match (&self.now, self.opts.cover) {
|
||||
(Some(n), true) if !n.title.trim().is_empty() => Some((n.artist.clone(), n.title.clone())),
|
||||
(Some(n), true) if !n.title.trim().is_empty() => Some((n.artist.clone(), n.title.clone(), n.album.clone())),
|
||||
_ => None,
|
||||
};
|
||||
let cover = match wanted {
|
||||
Some((artist, title)) => self.cover_for(&artist, &title).await,
|
||||
Some((artist, title, album)) => self.cover_for(&artist, &title, &album).await,
|
||||
None => None,
|
||||
};
|
||||
let act = self.now.as_ref().and_then(|n| activity(&self.opts, n, cover.as_deref(), now_ms()));
|
||||
@@ -250,19 +250,13 @@ impl Worker {
|
||||
}
|
||||
}
|
||||
|
||||
async fn cover_for(&mut self, artist: &str, title: &str) -> Option<String> {
|
||||
let key = format!("{}\u{1}{}", crate::artistinfo::norm(artist), crate::artistinfo::norm(title));
|
||||
async fn cover_for(&mut self, artist: &str, title: &str, album: &str) -> Option<String> {
|
||||
let norm = crate::artistinfo::norm;
|
||||
let key = format!("{}\u{1}{}\u{1}{}", norm(artist), norm(title), norm(album));
|
||||
if let Some(hit) = self.covers.get(&key) {
|
||||
return hit.clone();
|
||||
}
|
||||
let first = artist.split([',', '&']).next().unwrap_or(artist).trim();
|
||||
let q = if first.is_empty() { format!("track:\"{title}\"") } else { format!("artist:\"{first}\" track:\"{title}\"") };
|
||||
let url = format!("https://api.deezer.com/search?limit=5&q={}", crate::artistinfo::enc(&q));
|
||||
let found = match timeout(Duration::from_secs(6), crate::artistinfo::get_json(&self.http, &url)).await {
|
||||
Ok(Some(v)) => pick_cover(&v, first),
|
||||
Ok(None) => None,
|
||||
Err(_) => return None,
|
||||
};
|
||||
let found = timeout(Duration::from_secs(15), find_cover(&self.http, artist, title, album)).await.ok().flatten();
|
||||
self.covers.insert(key, found.clone());
|
||||
found
|
||||
}
|
||||
@@ -276,11 +270,81 @@ fn now_ms() -> u64 {
|
||||
SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_millis() as u64).unwrap_or(0)
|
||||
}
|
||||
|
||||
pub fn lead_artist(artist: &str) -> String {
|
||||
static SPLIT: std::sync::LazyLock<regex::Regex> = std::sync::LazyLock::new(|| regex::Regex::new(r"(?i)\s*(?:,|;|\s(?:feat\.?|ft\.?|featuring|with|x)\s)").unwrap());
|
||||
SPLIT.split(artist.trim()).next().unwrap_or_default().trim().to_string()
|
||||
}
|
||||
|
||||
pub fn clean_title(title: &str) -> String {
|
||||
static NOISE: std::sync::LazyLock<regex::Regex> = std::sync::LazyLock::new(|| {
|
||||
regex::Regex::new(r"(?i)\s*(?:[\(\[][^\)\]]*(?:feat|ft\.|with |remaster|version|edit|mix|live|explicit|clean|bonus|deluxe|official|audio|video|lyric)[^\)\]]*[\)\]]|\s-\s.*(?:remaster|version|edit|mix|live).*$|\s(?:feat\.?|ft\.?|featuring)\s.*$)").unwrap()
|
||||
});
|
||||
let t = NOISE.replace_all(title.trim(), "").trim().to_string();
|
||||
if t.is_empty() { title.trim().to_string() } else { t }
|
||||
}
|
||||
|
||||
fn same_artist(found: &str, want: &str) -> bool {
|
||||
let (f, w) = (crate::artistinfo::norm(found), crate::artistinfo::norm(want));
|
||||
w.is_empty() || (!f.is_empty() && (f == w || f.contains(&w) || w.contains(&f)))
|
||||
}
|
||||
|
||||
pub fn pick_album_cover(v: &Value, artist: &str, album: &str) -> Option<String> {
|
||||
let want = crate::artistinfo::norm(album);
|
||||
v["data"].as_array()?.iter().find_map(|a| {
|
||||
let title = crate::artistinfo::norm(a["title"].as_str().unwrap_or_default());
|
||||
let ok = same_artist(a["artist"]["name"].as_str().unwrap_or_default(), artist) && !want.is_empty() && (title == want || title.starts_with(&want) || want.starts_with(&title));
|
||||
let url = a["cover_xl"].as_str().or_else(|| a["cover_big"].as_str())?;
|
||||
(ok && url.starts_with("https://")).then(|| url.to_string())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn pick_itunes(v: &Value, artist: &str, title: &str, album: &str) -> Option<String> {
|
||||
let (t, al) = (crate::artistinfo::norm(title), crate::artistinfo::norm(album));
|
||||
let list = v["results"].as_array()?;
|
||||
let ok = |r: &&Value| same_artist(r["artistName"].as_str().unwrap_or_default(), artist);
|
||||
let by_song = list.iter().filter(ok).find(|r| {
|
||||
let name = crate::artistinfo::norm(&clean_title(r["trackName"].as_str().unwrap_or_default()));
|
||||
!t.is_empty() && (name == t || name.starts_with(&t) || t.starts_with(&name))
|
||||
});
|
||||
let by_album = || list.iter().filter(ok).find(|r| !al.is_empty() && crate::artistinfo::norm(r["collectionName"].as_str().unwrap_or_default()).starts_with(&al));
|
||||
let art = by_song.or_else(by_album)?["artworkUrl100"].as_str()?;
|
||||
art.starts_with("https://").then(|| art.replace("100x100bb", "1000x1000bb"))
|
||||
}
|
||||
|
||||
async fn find_cover(http: &reqwest::Client, artist: &str, title: &str, album: &str) -> Option<String> {
|
||||
use crate::artistinfo::{enc, get_json};
|
||||
let lead = lead_artist(artist);
|
||||
let song = clean_title(title);
|
||||
let album = album.trim();
|
||||
let field = |k: &str, v: &str| if v.is_empty() { String::new() } else { format!("{k}:\"{v}\" ") };
|
||||
let deezer = |q: String| format!("https://api.deezer.com/search{q}");
|
||||
if let Some(v) = get_json(http, &deezer(format!("?limit=10&q={}", enc(&format!("{}{}", field("artist", &lead), field("track", &song)))))).await {
|
||||
if let Some(u) = pick_cover(&v, &lead) {
|
||||
return Some(u);
|
||||
}
|
||||
}
|
||||
if !album.is_empty() {
|
||||
if let Some(v) = get_json(http, &deezer(format!("/album?limit=10&q={}", enc(&format!("{}{}", field("artist", &lead), field("album", &clean_title(album))))))).await {
|
||||
if let Some(u) = pick_album_cover(&v, &lead, &clean_title(album)) {
|
||||
return Some(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
let term = enc(&format!("{lead} {song}"));
|
||||
if let Some(v) = get_json(http, &format!("https://itunes.apple.com/search?media=music&entity=song&limit=15&term={term}")).await {
|
||||
if let Some(u) = pick_itunes(&v, &lead, &song, album) {
|
||||
return Some(u);
|
||||
}
|
||||
}
|
||||
let loose = get_json(http, &deezer(format!("?limit=10&q={}", enc(&format!("{lead} {song}"))))).await?;
|
||||
pick_cover(&loose, &lead)
|
||||
}
|
||||
|
||||
pub fn pick_cover(v: &Value, artist: &str) -> Option<String> {
|
||||
let want = crate::artistinfo::norm(artist);
|
||||
v["data"].as_array()?.iter().find_map(|t| {
|
||||
let name = crate::artistinfo::norm(t["artist"]["name"].as_str().unwrap_or_default());
|
||||
let ok = want.is_empty() || name == want || name.contains(&want) || want.contains(&name);
|
||||
let _ = &want;
|
||||
let ok = same_artist(t["artist"]["name"].as_str().unwrap_or_default(), artist);
|
||||
let url = t["album"]["cover_xl"].as_str().or_else(|| t["album"]["cover_big"].as_str())?;
|
||||
(ok && url.starts_with("https://")).then(|| url.to_string())
|
||||
})
|
||||
@@ -361,27 +425,11 @@ async fn read_frame(io: &mut Box<dyn Io>) -> std::io::Result<(u32, Value)> {
|
||||
}
|
||||
|
||||
async fn open_socket() -> Option<Box<dyn Io>> {
|
||||
#[cfg(windows)]
|
||||
for i in 0..10 {
|
||||
if let Ok(p) = tokio::net::windows::named_pipe::ClientOptions::new().open(format!(r"\\.\pipe\discord-ipc-{i}")) {
|
||||
return Some(Box::new(p));
|
||||
}
|
||||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let mut dirs: Vec<std::path::PathBuf> = ["XDG_RUNTIME_DIR", "TMPDIR", "TMP", "TEMP"].iter().filter_map(|k| std::env::var_os(k).map(Into::into)).collect();
|
||||
dirs.push("/tmp".into());
|
||||
for dir in dirs {
|
||||
for sub in ["", "app/com.discordapp.Discord", "snap.discord", ".flatpak/dev.vencord.Vesktop/xdg-run"] {
|
||||
for i in 0..10 {
|
||||
let path = dir.join(sub).join(format!("discord-ipc-{i}"));
|
||||
if let Ok(s) = tokio::net::UnixStream::connect(&path).await {
|
||||
return Some(Box::new(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -447,15 +495,42 @@ const SETUP_NOTES: &str = "Atmosphere on Discord: using your own Discord applica
|
||||
The name you give it is what Discord shows as \"Listening to <name>\".
|
||||
2. On the application's General Information page, copy the Application ID
|
||||
and paste it into Atmosphere > Settings > Discord > Your own Discord app.
|
||||
3. Open Rich Presence > Art Assets and upload both images from this folder.
|
||||
Keep their names exactly as they are (atmosphere and paused), because
|
||||
Atmosphere asks Discord for them by name.
|
||||
4. New art can take a few minutes to show up on Discord.
|
||||
3. Open Rich Presence > Art Assets. Under Rich Presence Assets, choose
|
||||
Add Image(s) and upload atmosphere.png and paused.png. Keep their names
|
||||
exactly as they are, because Atmosphere asks Discord for them by name.
|
||||
4. Optional: under Rich Presence Invite Image, upload invite-cover.png as
|
||||
the Cover Image (1024x576).
|
||||
5. New art can take a few minutes to show up on Discord.
|
||||
";
|
||||
|
||||
fn cover_png() -> Vec<u8> {
|
||||
let (w, h) = (1024u32, 576u32);
|
||||
let (from, to, glow): ([f32; 3], [f32; 3], [f32; 3]) = ([13.0, 15.0, 31.0], [42.0, 47.0, 143.0], [154.0, 164.0, 255.0]);
|
||||
let mut img = image::RgbaImage::from_fn(w, h, |x, y| {
|
||||
let t = (x as f32 / w as f32 * 0.6 + y as f32 / h as f32 * 0.4).clamp(0.0, 1.0);
|
||||
let (dx, dy) = (x as f32 - w as f32 / 2.0, (y as f32 - h as f32 / 2.0) * 1.4);
|
||||
let g = (1.0 - (dx * dx + dy * dy).sqrt() / 420.0).clamp(0.0, 1.0).powi(2) * 0.28;
|
||||
let c = |i: usize| (from[i] + (to[i] - from[i]) * t) * (1.0 - g) + glow[i] * g;
|
||||
image::Rgba([c(0) as u8, c(1) as u8, c(2) as u8, 255])
|
||||
});
|
||||
if let Ok(logo) = image::load_from_memory(LOGO_PNG) {
|
||||
let size = 300;
|
||||
let logo = image::imageops::resize(&logo.to_rgba8(), size, size, image::imageops::FilterType::Lanczos3);
|
||||
image::imageops::overlay(&mut img, &logo, ((w - size) / 2) as i64, ((h - size) / 2) as i64);
|
||||
}
|
||||
let mut out = std::io::Cursor::new(Vec::new());
|
||||
img.write_to(&mut out, image::ImageFormat::Png).expect("png");
|
||||
out.into_inner()
|
||||
}
|
||||
|
||||
pub fn write_assets(dir: &Path) -> anyhow::Result<Vec<String>> {
|
||||
std::fs::create_dir_all(dir)?;
|
||||
let files = [(format!("{ASSET_LOGO}.png"), LOGO_PNG.to_vec()), (format!("{ASSET_PAUSED}.png"), badge_png(1024)), ("How to set up.txt".to_string(), SETUP_NOTES.as_bytes().to_vec())];
|
||||
let files = [
|
||||
(format!("{ASSET_LOGO}.png"), LOGO_PNG.to_vec()),
|
||||
(format!("{ASSET_PAUSED}.png"), badge_png(1024)),
|
||||
("invite-cover.png".to_string(), cover_png()),
|
||||
("How to set up.txt".to_string(), SETUP_NOTES.as_bytes().to_vec()),
|
||||
];
|
||||
let mut written = Vec::new();
|
||||
for (name, bytes) in files {
|
||||
let path = dir.join(&name);
|
||||
@@ -522,11 +597,59 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cleans_titles_and_finds_covers_from_apple_music_too() {
|
||||
assert_eq!(lead_artist("Rihanna, The Weeknd feat. Drake"), "Rihanna");
|
||||
assert_eq!(lead_artist("Mumford & Sons"), "Mumford & Sons");
|
||||
assert_eq!(lead_artist("Calvin Harris x Dua Lipa"), "Calvin Harris");
|
||||
assert_eq!(clean_title("Get Lucky (feat. Pharrell Williams) [Radio Edit]"), "Get Lucky");
|
||||
assert_eq!(clean_title("Bohemian Rhapsody - Remastered 2011"), "Bohemian Rhapsody");
|
||||
assert_eq!(clean_title("Love Story (Taylor's Version)"), "Love Story");
|
||||
assert_eq!(clean_title("(Untitled)"), "(Untitled)");
|
||||
let it = json!({ "results": [
|
||||
{ "artistName": "Someone", "trackName": "Woo", "collectionName": "X", "artworkUrl100": "https://is1-ssl.mzstatic.com/a/100x100bb.jpg" },
|
||||
{ "artistName": "Rihanna", "trackName": "Woo", "collectionName": "ANTI", "artworkUrl100": "https://is1-ssl.mzstatic.com/b/100x100bb.jpg" }
|
||||
]});
|
||||
assert_eq!(pick_itunes(&it, "Rihanna", "Woo", "").as_deref(), Some("https://is1-ssl.mzstatic.com/b/1000x1000bb.jpg"));
|
||||
assert_eq!(pick_itunes(&it, "Nobody", "Woo", ""), None);
|
||||
let al = json!({ "data": [ { "title": "ANTI (Deluxe)", "artist": { "name": "Rihanna" }, "cover_xl": "https://e/anti.jpg" } ] });
|
||||
assert_eq!(pick_album_cover(&al, "Rihanna", "ANTI").as_deref(), Some("https://e/anti.jpg"));
|
||||
assert_eq!(pick_album_cover(&al, "Drake", "ANTI"), None);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore]
|
||||
async fn live_finds_covers() {
|
||||
let http = reqwest::Client::builder().user_agent("atmosphere/test").build().unwrap();
|
||||
for (a, t, al) in [("Rihanna, The Weeknd, Travis Scott, Jeremih", "Woo", "ANTI"), ("Daft Punk", "Get Lucky (feat. Pharrell Williams) [Radio Edit]", ""), ("Lana Del Rey", "Video Games - Remastered", "Born To Die")] {
|
||||
let c = find_cover(&http, a, t, al).await;
|
||||
eprintln!("{t}: {c:?}");
|
||||
assert!(c.is_some_and(|u| u.starts_with("https://")), "no cover for {t}");
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore]
|
||||
async fn live_discord_echo() {
|
||||
let id = std::env::var("ATMO_DISCORD_ID").expect("set ATMO_DISCORD_ID");
|
||||
let Ok((mut conn, user)) = connect(&id).await else { panic!("couldn't connect") };
|
||||
eprintln!("user: {user:?}");
|
||||
let now = NowPlaying { title: "Woo".into(), artist: "Rihanna".into(), album: "ANTI".into(), duration_ms: 236_000, position_ms: 1_000, playing: true };
|
||||
let act = activity(&Options { enabled: true, client_id: id.clone(), cover: true, paused: true, status: "artist".into() }, &now, None, now_ms());
|
||||
write_frame(&mut conn.io, 1, &json!({ "cmd": "SET_ACTIVITY", "args": { "pid": std::process::id(), "activity": act }, "nonce": "t1" })).await.unwrap();
|
||||
let (_, reply) = read_frame(&mut conn.io).await.unwrap();
|
||||
eprintln!("echo: {}", serde_json::to_string(&reply["data"]).unwrap());
|
||||
write_frame(&mut conn.io, 1, &json!({ "cmd": "SET_ACTIVITY", "args": { "pid": std::process::id(), "activity": null }, "nonce": "t2" })).await.unwrap();
|
||||
let _ = read_frame(&mut conn.io).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn writes_the_art_assets() {
|
||||
let dir = std::env::temp_dir().join(format!("atmo-discord-{}", std::process::id()));
|
||||
let files = write_assets(&dir).unwrap();
|
||||
assert_eq!(files.len(), 3);
|
||||
assert_eq!(files.len(), 4);
|
||||
let cover = image::open(dir.join("invite-cover.png")).unwrap();
|
||||
assert_eq!((cover.width(), cover.height()), (1024, 576));
|
||||
let badge = image::open(dir.join("paused.png")).unwrap();
|
||||
assert_eq!((badge.width(), badge.height()), (1024, 1024));
|
||||
let logo = image::open(dir.join("atmosphere.png")).unwrap();
|
||||
|
||||
+8
-59
@@ -7,10 +7,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Stdio;
|
||||
use tokio::process::Command;
|
||||
|
||||
#[cfg(windows)]
|
||||
const EXE: &str = ".exe";
|
||||
#[cfg(not(windows))]
|
||||
const EXE: &str = "";
|
||||
|
||||
const YTDLP_RELEASE: &str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download";
|
||||
const FFMPEG_RELEASE: &str = "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest";
|
||||
@@ -53,16 +50,7 @@ pub fn temp_root() -> PathBuf {
|
||||
}
|
||||
|
||||
fn search_dirs() -> Vec<PathBuf> {
|
||||
let mut dirs: Vec<PathBuf> = std::env::var_os("PATH").map(|p| std::env::split_paths(&p).collect()).unwrap_or_default();
|
||||
if cfg!(unix) {
|
||||
let home = dirs::home_dir().unwrap_or_default();
|
||||
for extra in ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/snap/bin", "/opt/local/bin"] {
|
||||
dirs.push(PathBuf::from(extra));
|
||||
}
|
||||
dirs.push(home.join(".local/bin"));
|
||||
dirs.push(home.join("bin"));
|
||||
}
|
||||
dirs
|
||||
std::env::var_os("PATH").map(|p| std::env::split_paths(&p).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn on_path(name: &str) -> Option<PathBuf> {
|
||||
@@ -89,7 +77,6 @@ pub fn find_tool(name: &str) -> Option<PathBuf> {
|
||||
pub fn command(program: &Path) -> Command {
|
||||
let mut cmd = Command::new(program);
|
||||
cmd.stdin(Stdio::null()).env("PYTHONIOENCODING", "utf-8").env("PYTHONUTF8", "1");
|
||||
#[cfg(windows)]
|
||||
cmd.creation_flags(0x0800_0000);
|
||||
cmd
|
||||
}
|
||||
@@ -133,22 +120,11 @@ pub async fn status(ytdlp_custom: &str, ffmpeg_custom: &str) -> ToolStatus {
|
||||
}
|
||||
|
||||
fn ytdlp_asset() -> &'static str {
|
||||
match (std::env::consts::OS, std::env::consts::ARCH) {
|
||||
("windows", _) => "yt-dlp.exe",
|
||||
("macos", _) => "yt-dlp_macos",
|
||||
("linux", "aarch64") => "yt-dlp_linux_aarch64",
|
||||
_ => "yt-dlp_linux",
|
||||
}
|
||||
"yt-dlp.exe"
|
||||
}
|
||||
|
||||
fn ffmpeg_asset() -> Option<&'static str> {
|
||||
match (std::env::consts::OS, std::env::consts::ARCH) {
|
||||
("windows", "aarch64") => Some("ffmpeg-master-latest-winarm64-gpl.zip"),
|
||||
("windows", _) => Some("ffmpeg-master-latest-win64-gpl.zip"),
|
||||
("linux", "aarch64") => Some("ffmpeg-master-latest-linuxarm64-gpl.tar.xz"),
|
||||
("linux", "x86_64") => Some("ffmpeg-master-latest-linux64-gpl.tar.xz"),
|
||||
_ => None,
|
||||
}
|
||||
Some(if std::env::consts::ARCH == "aarch64" { "ffmpeg-master-latest-winarm64-gpl.zip" } else { "ffmpeg-master-latest-win64-gpl.zip" })
|
||||
}
|
||||
|
||||
fn wanted(path: &str) -> Option<String> {
|
||||
@@ -157,7 +133,7 @@ fn wanted(path: &str) -> Option<String> {
|
||||
(path.contains("/bin/") && (file == format!("ffmpeg{EXE}") || file == format!("ffprobe{EXE}"))).then(|| file.to_string())
|
||||
}
|
||||
|
||||
fn extract_ffmpeg(asset: &str, data: Vec<u8>, dir: &Path) -> Result<PathBuf> {
|
||||
fn extract_ffmpeg(data: Vec<u8>, dir: &Path) -> Result<PathBuf> {
|
||||
let mut found = None;
|
||||
let mut keep = |file: String, buf: Vec<u8>| -> Result<()> {
|
||||
let dest = dir.join(&file);
|
||||
@@ -167,7 +143,6 @@ fn extract_ffmpeg(asset: &str, data: Vec<u8>, dir: &Path) -> Result<PathBuf> {
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
if asset.ends_with(".zip") {
|
||||
let mut archive = zip::ZipArchive::new(std::io::Cursor::new(data))?;
|
||||
for i in 0..archive.len() {
|
||||
let mut entry = archive.by_index(i)?;
|
||||
@@ -177,21 +152,6 @@ fn extract_ffmpeg(asset: &str, data: Vec<u8>, dir: &Path) -> Result<PathBuf> {
|
||||
keep(file, buf)?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let mut tar_bytes = Vec::new();
|
||||
lzma_rs::xz_decompress(&mut std::io::BufReader::new(std::io::Cursor::new(data)), &mut tar_bytes)
|
||||
.map_err(|e| anyhow!("Couldn't unpack ffmpeg ({e})"))?;
|
||||
let mut archive = tar::Archive::new(std::io::Cursor::new(tar_bytes));
|
||||
for entry in archive.entries()? {
|
||||
let mut entry = entry?;
|
||||
let name = entry.path()?.to_string_lossy().into_owned();
|
||||
if let Some(file) = wanted(&name) {
|
||||
let mut buf = Vec::new();
|
||||
entry.read_to_end(&mut buf)?;
|
||||
keep(file, buf)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
found.ok_or_else(|| anyhow!("ffmpeg wasn't in the downloaded archive"))
|
||||
}
|
||||
|
||||
@@ -232,11 +192,6 @@ fn write_exec(path: &Path, data: &[u8]) -> Result<()> {
|
||||
}
|
||||
let tmp = path.with_extension("download");
|
||||
std::fs::write(&tmp, data)?;
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
std::fs::set_permissions(&tmp, std::fs::Permissions::from_mode(0o755))?;
|
||||
}
|
||||
std::fs::rename(&tmp, path)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -252,18 +207,12 @@ pub async fn install_ytdlp(http: &reqwest::Client, progress: impl FnMut(u64, Opt
|
||||
}
|
||||
|
||||
pub async fn install_ffmpeg(http: &reqwest::Client, progress: impl FnMut(u64, Option<u64>)) -> Result<PathBuf> {
|
||||
let Some(asset) = ffmpeg_asset() else {
|
||||
bail!(if cfg!(target_os = "macos") {
|
||||
"On macOS, install ffmpeg with Homebrew (`brew install ffmpeg`). Atmosphere finds it automatically."
|
||||
} else {
|
||||
"Install ffmpeg with your package manager, then restart Atmosphere."
|
||||
});
|
||||
};
|
||||
let Some(asset) = ffmpeg_asset() else { bail!("ffmpeg isn't available for this computer.") };
|
||||
let sums = http.get(format!("{FFMPEG_RELEASE}/checksums.sha256")).send().await?.error_for_status()?.text().await?;
|
||||
let data = fetch(http, &format!("{FFMPEG_RELEASE}/{asset}"), progress).await?;
|
||||
verify(&data, &sums, asset)?;
|
||||
let dir = bin_dir();
|
||||
tokio::task::spawn_blocking(move || extract_ffmpeg(asset, data, &dir)).await?
|
||||
tokio::task::spawn_blocking(move || extract_ffmpeg(data, &dir)).await?
|
||||
}
|
||||
|
||||
pub async fn update_ytdlp(path: &Path) -> Result<String> {
|
||||
@@ -289,9 +238,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn finds_checksums() {
|
||||
let sums = "abc123 yt-dlp.exe\nDEF456 *yt-dlp_linux\n";
|
||||
let sums = "abc123 yt-dlp.exe\nDEF456 *ffmpeg.zip\n";
|
||||
assert_eq!(expected_hash(sums, "yt-dlp.exe").as_deref(), Some("abc123"));
|
||||
assert_eq!(expected_hash(sums, "yt-dlp_linux").as_deref(), Some("def456"));
|
||||
assert_eq!(expected_hash(sums, "ffmpeg.zip").as_deref(), Some("def456"));
|
||||
assert!(expected_hash(sums, "nope").is_none());
|
||||
let data = b"hello";
|
||||
let good = format!("{} file.bin", Sha256::digest(data).iter().map(|b| format!("{b:02x}")).collect::<String>());
|
||||
|
||||
+13
-5
@@ -1048,6 +1048,14 @@ impl Library {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
static DATA_DIR: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
|
||||
fn own_data_dir(root: &Path) -> std::sync::MutexGuard<'static, ()> {
|
||||
let guard = DATA_DIR.lock().unwrap_or_else(|e| e.into_inner());
|
||||
std::env::set_var("ATMOSPHERE_DATA_DIR", root.join("data"));
|
||||
guard
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_playlist_membership() {
|
||||
let root = Path::new("/music/Playlists");
|
||||
@@ -1089,7 +1097,7 @@ mod tests {
|
||||
#[test]
|
||||
fn hide_restore_and_folder_removal() {
|
||||
let root = std::env::temp_dir().join(format!("atmo-lib-{}", now()));
|
||||
std::env::set_var("ATMOSPHERE_DATA_DIR", root.join("data"));
|
||||
let _data = own_data_dir(&root);
|
||||
let music = root.join("music");
|
||||
let lists = music.join("Playlists");
|
||||
wav(&music.join("Album A").join("one.wav"), 2);
|
||||
@@ -1114,7 +1122,7 @@ mod tests {
|
||||
#[test]
|
||||
fn linked_folders_link_go_missing_relocate_and_unlink() {
|
||||
let root = std::env::temp_dir().join(format!("atmo-link-{}-{}", std::process::id(), now()));
|
||||
std::env::set_var("ATMOSPHERE_DATA_DIR", root.join("data"));
|
||||
let _data = own_data_dir(&root);
|
||||
let lists = root.join("Playlists");
|
||||
std::fs::create_dir_all(lists.join("Gym")).unwrap();
|
||||
let mine = root.join("Elsewhere").join("Gym");
|
||||
@@ -1152,7 +1160,7 @@ mod tests {
|
||||
#[test]
|
||||
fn moving_the_music_folder_keeps_likes_and_plays() {
|
||||
let root = std::env::temp_dir().join(format!("atmo-remap-{}-{}", std::process::id(), now()));
|
||||
std::env::set_var("ATMOSPHERE_DATA_DIR", root.join("data"));
|
||||
let _data = own_data_dir(&root);
|
||||
let (old, new) = (root.join("old"), root.join("new"));
|
||||
wav(&old.join("Albums").join("one.wav"), 2);
|
||||
let lib = Library::load();
|
||||
@@ -1174,7 +1182,7 @@ mod tests {
|
||||
#[test]
|
||||
fn moving_one_song_keeps_its_likes_and_plays() {
|
||||
let root = std::env::temp_dir().join(format!("atmo-remap1-{}-{}", std::process::id(), now()));
|
||||
std::env::set_var("ATMOSPHERE_DATA_DIR", root.join("data"));
|
||||
let _data = own_data_dir(&root);
|
||||
let (from, to) = (root.join("Tracks").join("one.wav"), root.join("Albums").join("A").join("one.wav"));
|
||||
wav(&from, 2);
|
||||
wav(&root.join("Tracks").join("two.wav"), 2);
|
||||
@@ -1186,7 +1194,7 @@ mod tests {
|
||||
std::fs::rename(&from, &to).unwrap();
|
||||
let new_id = lib.remap_file(&from, &to).unwrap();
|
||||
let snap = lib.snapshot(&root.join("Playlists"));
|
||||
assert_eq!(snap.tracks.len(), 2);
|
||||
assert_eq!(snap.tracks.iter().filter(|t| Path::new(&t.path).starts_with(&root)).count(), 2);
|
||||
assert!(snap.liked.contains(&new_id));
|
||||
assert!(snap.tracks.iter().any(|t| t.path.ends_with("two.wav")));
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
|
||||
+3
-14
@@ -1,6 +1,9 @@
|
||||
// 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")]
|
||||
|
||||
#[cfg(not(windows))]
|
||||
compile_error!("Atmosphere is a Windows app.");
|
||||
|
||||
mod api;
|
||||
mod artistinfo;
|
||||
mod backup;
|
||||
@@ -381,7 +384,6 @@ fn parse_hex(color: &str) -> Option<(u8, u8, 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);
|
||||
@@ -389,8 +391,6 @@ fn frame_color(window: tauri::WebviewWindow, color: String) {
|
||||
DwmSetWindowAttribute(hwnd.0 as _, DWMWA_BORDER_COLOR as _, &colorref as *const u32 as _, 4);
|
||||
}
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
let _ = (window, r, g, b);
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -596,17 +596,6 @@ fn main() {
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building atmosphere")
|
||||
.run(|app, event| {
|
||||
#[cfg(target_os = "macos")]
|
||||
if let tauri::RunEvent::Opened { urls } = &event {
|
||||
let files: Vec<String> = urls.iter().filter_map(|u| u.to_file_path().ok()).map(|p| p.to_string_lossy().into_owned()).collect();
|
||||
let files = libcmd::audio_args(files);
|
||||
if !files.is_empty() {
|
||||
if let Some(state) = app.try_state::<AppState>() {
|
||||
state.pending_open.lock().unwrap().extend(files.clone());
|
||||
}
|
||||
let _ = app.emit("atmosphere://open-files", files);
|
||||
}
|
||||
}
|
||||
if let tauri::RunEvent::Exit = event {
|
||||
if let Some(state) = app.try_state::<AppState>() {
|
||||
state.dl.cancel_all();
|
||||
|
||||
@@ -473,7 +473,6 @@ fn browser_label(id: &str) -> String {
|
||||
"brave" => "Brave".into(),
|
||||
"opera" => "Opera".into(),
|
||||
"vivaldi" => "Vivaldi".into(),
|
||||
"safari" => "Safari".into(),
|
||||
"whale" => "Whale".into(),
|
||||
_ => "your browser".into(),
|
||||
}
|
||||
|
||||
+2
-8
@@ -19,13 +19,7 @@ pub struct UpdateInfo {
|
||||
}
|
||||
|
||||
pub fn can_self_update() -> bool {
|
||||
if crate::engine::portable_root().is_some() {
|
||||
return false;
|
||||
}
|
||||
if cfg!(target_os = "linux") {
|
||||
return std::env::var_os("APPIMAGE").is_some();
|
||||
}
|
||||
true
|
||||
crate::engine::portable_root().is_none()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -44,7 +38,7 @@ pub async fn update_check(app: AppHandle) -> CmdResult<Option<UpdateInfo>> {
|
||||
Ok(found.map(|u| UpdateInfo {
|
||||
version: u.version.clone(),
|
||||
current: u.current_version.clone(),
|
||||
notes: u.body.clone().filter(|b| !b.trim().is_empty()),
|
||||
notes: u.body.as_deref().map(|b| b.split("<!-- install-notes -->").next().unwrap_or(b).trim().to_string()).filter(|b| !b.is_empty()),
|
||||
date: u.date.map(|d| d.to_string()),
|
||||
can_install: can_self_update(),
|
||||
page: RELEASES.into(),
|
||||
|
||||
+4
-9
@@ -29,7 +29,10 @@
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"targets": [
|
||||
"nsis",
|
||||
"msi"
|
||||
],
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
@@ -39,14 +42,6 @@
|
||||
],
|
||||
"category": "Music",
|
||||
"shortDescription": "Save audio and video you have the rights to keep.",
|
||||
"macOS": {
|
||||
"minimumSystemVersion": "10.15"
|
||||
},
|
||||
"linux": {
|
||||
"deb": {
|
||||
"depends": []
|
||||
}
|
||||
},
|
||||
"licenseFile": "installer/RIGHTS.txt",
|
||||
"windows": {
|
||||
"nsis": {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"label": "main",
|
||||
"title": "Atmosphere",
|
||||
"width": 1200,
|
||||
"height": 800,
|
||||
"minWidth": 900,
|
||||
"minHeight": 620,
|
||||
"center": true,
|
||||
"backgroundColor": "#0b0d14",
|
||||
"dragDropEnabled": false,
|
||||
"decorations": true,
|
||||
"shadow": true,
|
||||
"titleBarStyle": "Overlay",
|
||||
"hiddenTitle": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,6 @@ function h(tag, attrs = {}, ...kids) {
|
||||
return el;
|
||||
}
|
||||
const icon = (name) => h("span", { class: "i", icon: name });
|
||||
const isMac = /Mac|iPhone|iPad/.test(navigator.userAgentData?.platform || navigator.platform || navigator.userAgent);
|
||||
const platformKeys = () => isMac && $$("kbd").forEach((k) => (k.textContent = k.textContent.replace(/^Ctrl /, "⌘ ")));
|
||||
const hydrate = (root = document) => $$("[data-icon]", root).forEach((el) => (el.innerHTML = svg(el.dataset.icon)));
|
||||
|
||||
const KIND = { album: "Album", ep: "EP", single: "Single", lp: "LP", compilation: "Compilation", mixtape: "Mixtape", playlist: "Playlist", profile: "Profile", channel: "Channel", search: "Search results", track: "Track" };
|
||||
@@ -95,6 +93,16 @@ function toast(message, kind = "") {
|
||||
}, kind === "err" ? 6500 : 3000);
|
||||
}
|
||||
|
||||
function placeFloating(el, x, y, above = false) {
|
||||
const pad = 8;
|
||||
el.style.maxHeight = `${Math.max(120, innerHeight - pad * 2)}px`;
|
||||
el.style.maxWidth = `${innerWidth - pad * 2}px`;
|
||||
el.style.overflowY = "auto";
|
||||
const w = el.offsetWidth, hgt = el.offsetHeight;
|
||||
el.style.left = `${Math.max(pad, Math.min(x, innerWidth - w - pad))}px`;
|
||||
el.style.top = `${Math.max(pad, Math.min(above ? y - hgt : y, innerHeight - hgt - pad))}px`;
|
||||
}
|
||||
|
||||
function art(url, cls, alt = "", ph = "music") {
|
||||
if (!url) return h("div", { class: `${cls} ph` }, icon(ph));
|
||||
const img = h("img", { class: cls, src: url, alt, loading: "lazy", draggable: "false", referrerpolicy: "no-referrer" });
|
||||
@@ -195,8 +203,6 @@ function bindSidebar() {
|
||||
|
||||
function bindWindow() {
|
||||
const bar = $("#titlebar");
|
||||
document.documentElement.classList.toggle("mac", isMac);
|
||||
if (isMac) bar.classList.add("mac");
|
||||
const api = window.__TAURI__.window;
|
||||
if (!api?.getCurrentWindow) return;
|
||||
const win = api.getCurrentWindow();
|
||||
@@ -222,7 +228,6 @@ function bindWindow() {
|
||||
/* boot */
|
||||
async function init() {
|
||||
hydrate();
|
||||
platformKeys();
|
||||
bindWindow();
|
||||
bindSidebar();
|
||||
state.settings = await invoke("get_settings");
|
||||
@@ -311,7 +316,7 @@ function renderObTools() {
|
||||
if (!t) return;
|
||||
$("#obTools").replaceChildren(
|
||||
toolRow("ytdlp", t.ytdlp, "yt-dlp", "Reads links and downloads media (about 18 MB)."),
|
||||
toolRow("ffmpeg", t.ffmpeg, "ffmpeg", t.canInstallFfmpeg ? "Converts formats and writes tags (about 90 MB)." : isMac ? "Run brew install ffmpeg in Terminal; Atmosphere finds it." : "Install it with your package manager.")
|
||||
toolRow("ffmpeg", t.ffmpeg, "ffmpeg", "Converts formats and writes tags (about 90 MB).")
|
||||
);
|
||||
$("#obInstall").textContent = t.ytdlp.path && t.ffmpeg.path ? "Continue" : "Set up both";
|
||||
}
|
||||
@@ -860,9 +865,8 @@ function openTypeMenu(anchor, c) {
|
||||
h("div", { class: "menu-note" }, "Albums, EPs and singles get album tags and track numbers.")
|
||||
);
|
||||
const r = anchor.getBoundingClientRect();
|
||||
menu.style.left = `${r.left}px`;
|
||||
menu.style.top = `${r.bottom + 6}px`;
|
||||
menu.hidden = false;
|
||||
placeFloating(menu, r.left, r.bottom + 6);
|
||||
menu.querySelector("button")?.focus();
|
||||
}
|
||||
|
||||
@@ -1148,8 +1152,7 @@ function openSaveMenu() {
|
||||
$("#saveAsBtn").setAttribute("aria-expanded", "true");
|
||||
renderSaveMenu();
|
||||
const r = $("#saveAsBtn").getBoundingClientRect();
|
||||
menu.style.left = `${r.left}px`;
|
||||
menu.style.top = `${Math.max(12, r.top - menu.offsetHeight - 8)}px`;
|
||||
placeFloating(menu, r.left, r.top - 8, true);
|
||||
menu.querySelector(".opt[aria-checked='true']")?.focus();
|
||||
}
|
||||
|
||||
@@ -1556,8 +1559,6 @@ function renderSettings() {
|
||||
renderStorage();
|
||||
}
|
||||
|
||||
const OS = isMac ? "mac" : /Linux|X11/.test(navigator.userAgent) ? "linux" : "windows";
|
||||
|
||||
function signinStatus(text, kind) {
|
||||
const el = $("#signinStatus");
|
||||
if (!el) return;
|
||||
@@ -1570,7 +1571,6 @@ 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;
|
||||
@@ -1628,7 +1628,7 @@ function renderToolSettings() {
|
||||
return [h("div", {}, h("strong", { class: "name" }, h("span", { class: `dot ${tool.path ? "ok" : "warn"}` }), name), h("span", {}, status)), acts];
|
||||
};
|
||||
$("#toolYtdlp").replaceChildren(...card("ytdlp", t.ytdlp, "yt-dlp", "Not installed. Needed to read any link."));
|
||||
$("#toolFfmpeg").replaceChildren(...card("ffmpeg", t.ffmpeg, "ffmpeg", t.canInstallFfmpeg ? "Not installed. Needed for MP3, M4A, FLAC, WAV, video and cover art." : isMac ? "Install it with Homebrew (brew install ffmpeg). Atmosphere finds it automatically." : "Install it with your package manager, then restart."));
|
||||
$("#toolFfmpeg").replaceChildren(...card("ffmpeg", t.ffmpeg, "ffmpeg", "Not installed. Needed for MP3, M4A, FLAC, WAV, video and cover art."));
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => init().catch((e) => toast(errText(e), "err")));
|
||||
|
||||
+5
-6
@@ -259,8 +259,7 @@
|
||||
<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="chromium">Chromium</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>
|
||||
@@ -289,20 +288,20 @@
|
||||
<div class="group">
|
||||
<label class="setting"><div><strong>Show what you're listening to</strong><span class="api-status" id="discordStatus" role="status">Off. Nothing is shared with Discord.</span></div><input type="checkbox" class="switch" data-key="discordEnabled" id="discordToggle" /></label>
|
||||
<div class="setting discord-opt">
|
||||
<div><strong>Your status says</strong><span>What people see under your name, like "Listening to Atmosphere". The song, artist and progress always show on your profile.</span></div>
|
||||
<div><strong>Your status says</strong><span>The short line next to your name in member lists, DMs and your friends list, like "Listening to Atmosphere" or "Listening to Rihanna". Your profile card always shows the song, artist, cover and progress.</span></div>
|
||||
<div class="seg" data-seg="discordStatus"><button type="button" data-value="app">Atmosphere</button><button type="button" data-value="artist">Artist</button><button type="button" data-value="song">Song</button></div>
|
||||
</div>
|
||||
<label class="setting discord-opt"><div><strong>Show cover art</strong><span>Discord can only show pictures from the web, so Atmosphere looks the song up on Deezer (only the artist and title are sent). Off: the Atmosphere logo is shown.</span></div><input type="checkbox" class="switch" data-key="discordCover" /></label>
|
||||
<label class="setting discord-opt"><div><strong>Show cover art</strong><span>Your status shows the song's cover, with the Atmosphere logo as a small badge. Discord can only show pictures from the web, so Atmosphere finds the cover on Deezer or Apple Music (only the artist, title and album are sent). If none is found, or this is off, the Atmosphere logo is shown instead.</span></div><input type="checkbox" class="switch" data-key="discordCover" /></label>
|
||||
<label class="setting discord-opt"><div><strong>Keep showing while paused</strong><span>Off: your status clears when you pause and comes back when you press play.</span></div><input type="checkbox" class="switch" data-key="discordPaused" /></label>
|
||||
<details class="setting advanced discord-opt">
|
||||
<summary><strong>Your own Discord app</strong><span>Shows your app's name and art instead, like "Listening to My Music". Leave the ID blank to use Atmosphere's.</span></summary>
|
||||
<div class="adv-fields">
|
||||
<ol class="discord-steps">
|
||||
<li>Create an application in the <button class="link" id="discordPortal" type="button">Discord Developer Portal</button>. Its name is what your status shows.</li>
|
||||
<li>Save the images, then upload both under <strong>Rich Presence › Art Assets</strong> without renaming them.</li>
|
||||
<li>Save the images. Under <strong>Rich Presence › Art Assets</strong>, add <code>atmosphere.png</code> and <code>paused.png</code> without renaming them, and optionally <code>invite-cover.png</code> as the invite cover image.</li>
|
||||
<li>Paste the <strong>Application ID</strong> from <strong>General Information</strong> here.</li>
|
||||
</ol>
|
||||
<div class="discord-assets"><button class="btn" id="discordAssets" type="button"><span class="label">Save the images…</span><span class="spin" aria-hidden="true"></span></button><span class="muted small">You choose the folder. Includes the logo, the paused badge and these steps.</span></div>
|
||||
<div class="discord-assets"><button class="btn" id="discordAssets" type="button"><span class="label">Save the images…</span><span class="spin" aria-hidden="true"></span></button><span class="muted small">You choose the folder. Includes the logo, the paused badge, an invite cover and these steps.</span></div>
|
||||
<label><span>Application ID</span><input class="text" id="discordClientId" placeholder="Atmosphere's own" inputmode="numeric" spellcheck="false" autocomplete="off" /></label>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
+23
-19
@@ -19,17 +19,21 @@ const Lib = {
|
||||
};
|
||||
|
||||
const lnorm = (s) => (s || "").trim().toLowerCase();
|
||||
function splitList(s) {
|
||||
return (s || "").trim().split(/\s*(?:,|;|\s(?:feat\.?|ft\.?|featuring)\s|^(?:feat\.?|ft\.?)\s)\s*/i).map((p) => p.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);
|
||||
return splitList(s).flatMap((p) => {
|
||||
if (!/\s&\s/.test(p)) return [p];
|
||||
const pieces = p.split(/\s+&\s+/).map((x) => x.trim()).filter(Boolean);
|
||||
return pieces.length > 1 && pieces.every((x) => Lib.solo?.has(lnorm(x))) ? pieces : [p];
|
||||
});
|
||||
}
|
||||
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, ", ")));
|
||||
return [...inBrackets, trailing?.[1]].filter(Boolean).flatMap((x) => splitNames(x));
|
||||
}
|
||||
const primaryArtist = (s) => splitNames(s)[0] || "Unknown artist";
|
||||
const artistsOf = (t) => {
|
||||
@@ -51,6 +55,8 @@ function buildIndexes(snap) {
|
||||
Lib.byId = new Map(snap.tracks.map((t) => [t.id, t]));
|
||||
Lib.liked = new Set(snap.liked);
|
||||
Lib.plays = snap.plays || {};
|
||||
Lib.solo = new Set();
|
||||
for (const t of snap.tracks) for (const n of [t.albumArtist, ...splitList(t.artist)]) if (n && !/\s&\s/.test(n)) Lib.solo.add(lnorm(n));
|
||||
const main = new Set(snap.tracks.filter((t) => !t.playlist).map(sig));
|
||||
Lib.songs = snap.tracks.filter((t) => !t.playlist || !main.has(sig(t)));
|
||||
const albums = new Map();
|
||||
@@ -261,14 +267,14 @@ async function deleteTracks(tracks) {
|
||||
const box = h("input", { type: "checkbox", class: "box" });
|
||||
box.checked = true;
|
||||
const body = h("div", { class: "stack" },
|
||||
h("p", { class: "muted" }, `${tracks.length === 1 ? `“${tracks[0].title}”` : songs(tracks.length)} will be moved to your ${isMac ? "Trash" : "Recycle Bin"}, along with any lyrics files, so you can restore them from there if you change your mind.`),
|
||||
h("p", { class: "muted" }, `${tracks.length === 1 ? `“${tracks[0].title}”` : songs(tracks.length)} will be moved to your Recycle Bin, along with any lyrics files, so you can restore them from there if you change your mind.`),
|
||||
inPlaylists ? h("label", { class: "check-row" }, box, h("span", {}, "Also remove them from your playlists")) : null);
|
||||
const ok = await modal(tracks.length === 1 ? "Delete this song from your device?" : `Delete ${tracks.length} songs from your device?`, body, [{ label: "Cancel", value: false }, { label: "Delete", value: true, primary: true }]);
|
||||
if (!ok) return;
|
||||
try {
|
||||
const n = await invoke("tracks_delete", { ids: tracks.map((t) => t.id), playlists: inPlaylists && box.checked });
|
||||
Lib.sel.clear();
|
||||
toast(`Deleted ${songs(n)}. ${isMac ? "Trash" : "Recycle Bin"} has them if you need them back.`, "ok");
|
||||
toast(`Deleted ${songs(n)}. Recycle Bin has them if you need them back.`, "ok");
|
||||
} catch (e) {
|
||||
toast(errText(e), "err");
|
||||
}
|
||||
@@ -309,7 +315,7 @@ function closeMenus() {
|
||||
$$(".ctx").forEach((m) => m.remove());
|
||||
}
|
||||
|
||||
function menuAt(x, y, items) {
|
||||
function menuAt(x, y, items, above = false) {
|
||||
closeMenus();
|
||||
const m = h("div", { class: "menu ctx", role: "menu" });
|
||||
for (const it of items) {
|
||||
@@ -317,9 +323,7 @@ function menuAt(x, y, items) {
|
||||
else if (it) m.append(h("button", { role: "menuitem", class: `${it.sub ? "has-sub" : ""} ${it.danger ? "danger" : ""}`, disabled: it.disabled, onclick: (e) => { if (it.sub) { e.stopPropagation(); const r = e.currentTarget.getBoundingClientRect(); menuAt(r.right + 4, r.top - 6, it.sub()); } else { closeMenus(); it.run(); } } }, h("span", {}, it.label), it.sub ? icon("chevron-down") : it.hint ? h("kbd", {}, it.hint) : null));
|
||||
}
|
||||
document.body.append(m);
|
||||
const w = m.offsetWidth, hgt = m.offsetHeight;
|
||||
m.style.left = `${Math.min(x, innerWidth - w - 8)}px`;
|
||||
m.style.top = `${Math.min(y, innerHeight - hgt - 8)}px`;
|
||||
placeFloating(m, x, y, above);
|
||||
m.querySelector("button")?.focus();
|
||||
return m;
|
||||
}
|
||||
@@ -411,10 +415,10 @@ async function addToPlaylist(name, tracks) {
|
||||
|
||||
async function removeFromPlaylist(name, tracks) {
|
||||
const pl = (Lib.data?.playlists || []).find((x) => x.name === name);
|
||||
const bin = isMac ? "Trash" : "Recycle Bin";
|
||||
const bin = "Recycle Bin";
|
||||
const ok = pl?.linked
|
||||
? await confirmBox(`Remove ${tracks.length === 1 ? `“${tracks[0].title}”` : plural(tracks.length, "song")} from ${name}?`, `This is your own folder, so the file itself moves from it to your ${bin}. If it's the only copy, it leaves your library too. You can restore it from the ${bin}.`, "Move to " + bin)
|
||||
: await confirmBox(`Remove ${tracks.length === 1 ? `“${tracks[0].title}”` : plural(tracks.length, "song")} from ${name}?`, `The playlist's copy goes to your ${isMac ? "Trash" : "Recycle Bin"}. The song stays in your library.`, "Remove");
|
||||
: await confirmBox(`Remove ${tracks.length === 1 ? `“${tracks[0].title}”` : plural(tracks.length, "song")} from ${name}?`, `The playlist's copy goes to your Recycle Bin. The song stays in your library.`, "Remove");
|
||||
if (!ok) return;
|
||||
try {
|
||||
await invoke("playlist_remove", { name, ids: tracks.map((t) => t.id) });
|
||||
@@ -448,11 +452,11 @@ function modal(title, body, actions) {
|
||||
const close = (v) => { wrap.remove(); resolve(v); };
|
||||
const wrap = h("div", { class: "modal-wrap", onclick: (e) => { if (e.target === wrap) close(null); } },
|
||||
h("div", { class: "modal", role: "dialog", "aria-modal": "true", "aria-label": title },
|
||||
h("h2", {}, title), body,
|
||||
h("div", { class: "row end" }, ...actions.map((a) => h("button", { class: `btn ${a.primary ? "primary" : a.danger ? "danger-ghost" : "ghost"}`, onclick: () => close(a.value) }, a.label)))));
|
||||
h("h2", {}, title), h("div", { class: "modal-body" }, body),
|
||||
h("div", { class: "row end modal-actions" }, ...actions.map((a) => h("button", { class: `btn ${a.primary ? "primary" : a.danger ? "danger-ghost" : "ghost"}`, onclick: () => close(a.value) }, a.label)))));
|
||||
wrap.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape") close(null);
|
||||
if (e.key === "Enter" && e.target.tagName === "INPUT") close(actions.find((a) => a.primary)?.value);
|
||||
if (e.key === "Enter" && e.target.tagName === "INPUT" && !e.defaultPrevented) close(actions.find((a) => a.primary)?.value);
|
||||
});
|
||||
document.body.append(wrap);
|
||||
(wrap.querySelector("input, textarea") || wrap.querySelector(".btn.primary"))?.focus();
|
||||
@@ -1193,7 +1197,7 @@ function bindLibrary() {
|
||||
$$("[data-lib]").forEach((b) => b.addEventListener("click", () => { Lib.back = []; openLib(b.dataset.lib, null, false); }));
|
||||
$("#newPlaylistBtn").addEventListener("click", playlistAddMenu);
|
||||
$("#libScroll").addEventListener("scroll", () => Lib.drawSongs && requestAnimationFrame(Lib.drawSongs), { passive: true });
|
||||
window.addEventListener("resize", () => Lib.drawSongs && Lib.drawSongs());
|
||||
window.addEventListener("resize", () => { closeMenus(); Lib.drawSongs && Lib.drawSongs(); });
|
||||
window.addEventListener("player", (e) => { if (e.detail.type === "track") markPlaying(); });
|
||||
window.addEventListener("played", (e) => { Lib.plays[e.detail] = (Lib.plays[e.detail] || 0) + 1; });
|
||||
listen("atmosphere://library", (e) => {
|
||||
@@ -1212,7 +1216,7 @@ function bindLibrary() {
|
||||
}
|
||||
|
||||
/* app-wide context menus (replaces the browser's own) */
|
||||
const MOD = isMac ? "⌘" : "Ctrl+";
|
||||
const MOD = "Ctrl+";
|
||||
|
||||
function editMenu(e, el) {
|
||||
const isInput = el.tagName === "INPUT" || el.tagName === "TEXTAREA";
|
||||
@@ -1378,7 +1382,7 @@ document.addEventListener("keydown", (e) => {
|
||||
return;
|
||||
}
|
||||
const typing = e.target.closest?.("input, textarea, select, [contenteditable]");
|
||||
if (!typing && state.view === "library" && Lib.sel.size && (e.key === "Delete" || (isMac && e.key === "Backspace" && e.metaKey))) {
|
||||
if (!typing && state.view === "library" && Lib.sel.size && e.key === "Delete") {
|
||||
e.preventDefault();
|
||||
return deleteTracks(selectedTracks());
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ async function openMini() {
|
||||
document.body.classList.add("mini-mode");
|
||||
const box = $("#mini");
|
||||
box.hidden = false;
|
||||
box.classList.toggle("mac", isMac);
|
||||
const win = miniWin();
|
||||
const dpi = window.__TAURI__?.dpi;
|
||||
if (win && dpi) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* atmosphere · player.js · Audio engine: two-deck gapless playback, crossfade, volume levelling, queue, EQ and effects, media keys and resume. */
|
||||
const MEDIA_BASE = /Windows/.test(navigator.userAgent) ? "http://atmo.localhost/" : "atmo://localhost/";
|
||||
const MEDIA_BASE = "http://atmo.localhost/";
|
||||
const mediaUrl = (kind, id) => `${MEDIA_BASE}${kind}/${encodeURIComponent(id)}`;
|
||||
const artUrl = (key) => (key ? mediaUrl("a", key) : null);
|
||||
|
||||
|
||||
+27
-17
@@ -23,8 +23,8 @@
|
||||
--art-opacity: 0.42;
|
||||
--shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.65);
|
||||
--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
--font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, "Cantarell", "Ubuntu", "Noto Sans", sans-serif;
|
||||
--font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, "Cantarell", "Ubuntu", "Noto Sans", sans-serif;
|
||||
--font: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
|
||||
--font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
|
||||
--mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, ui-monospace, "DejaVu Sans Mono", monospace;
|
||||
--s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
|
||||
--r-chip: 6px; --r-ctl: 8px; --r-card: 12px;
|
||||
@@ -323,7 +323,7 @@ select { padding-right: var(--s6); cursor: pointer; }
|
||||
@keyframes nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
|
||||
|
||||
/* save-as menu */
|
||||
.save-menu { position: fixed; z-index: 40; width: 380px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 6px; animation: menuIn 150ms var(--ease); }
|
||||
.save-menu { position: fixed; z-index: 40; width: min(380px, calc(100vw - 16px)); border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 6px; animation: menuIn 150ms var(--ease); }
|
||||
@keyframes menuIn { from { opacity: 0; transform: translateY(6px); } }
|
||||
.opt { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--s3); padding: 10px var(--s3); border-radius: var(--r-ctl); width: 100%; text-align: left; }
|
||||
.opt:hover:not(:disabled) { background: var(--hover); }
|
||||
@@ -464,7 +464,7 @@ label.setting { cursor: pointer; }
|
||||
.sheet-head { grid-template-columns: 128px minmax(0, 1fr); gap: var(--s5); }
|
||||
.cover { width: 128px; height: 128px; }
|
||||
.sheet-body.inspecting { padding-right: var(--s8); }
|
||||
.inspector { position: fixed; top: 80px; right: 16px; }
|
||||
.inspector { position: fixed; top: 80px; right: 16px; max-height: calc(100vh - 180px); max-width: calc(100vw - 32px); overflow-y: auto; }
|
||||
.commit { flex-wrap: wrap; }
|
||||
.attest { order: 3; }
|
||||
}
|
||||
@@ -617,7 +617,7 @@ label.setting { cursor: pointer; }
|
||||
.range.vol { width: 96px; flex: none; }
|
||||
|
||||
/* drawers */
|
||||
.drawer-panel { position: fixed; right: 12px; top: 12px; bottom: 90px; width: 380px; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slideIn 200ms var(--ease); overflow: hidden; }
|
||||
.drawer-panel { position: fixed; right: 12px; top: 12px; bottom: 90px; width: min(380px, calc(100vw - 24px)); z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slideIn 200ms var(--ease); overflow: hidden; }
|
||||
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s4) var(--s3); border-bottom: 1px solid var(--hairline); }
|
||||
.drawer-head h2 { font-size: 15px; }
|
||||
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s2) var(--s2) var(--s4); }
|
||||
@@ -737,8 +737,6 @@ label.setting { cursor: pointer; }
|
||||
.tb-btn:active { background: var(--press); }
|
||||
.tb-btn.close:hover { background: #c42b1c; color: #fff; }
|
||||
.tb-btn.close:active { background: #b3271a; color: #fff; }
|
||||
.titlebar.mac { grid-template-columns: minmax(0, 1fr); }
|
||||
.titlebar.mac .tb-controls { display: none; }
|
||||
.titlebar.blur .tb-btn, .titlebar.blur ~ .shell .side-brand img { opacity: 0.6; }
|
||||
.sidebar { padding-top: 0; }
|
||||
.main { padding-top: var(--titlebar); }
|
||||
@@ -992,9 +990,6 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.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 */
|
||||
@@ -1032,8 +1027,6 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.brand-mark { display: none; height: 24px; width: auto; }
|
||||
.side-toggle { flex: none; opacity: 0; transition: opacity 120ms var(--ease), background-color 120ms var(--ease), color 120ms var(--ease); }
|
||||
.sidebar:hover .side-toggle, .side-toggle:focus-visible { opacity: 1; }
|
||||
.mac .side-brand { padding-left: 80px; }
|
||||
.mac .side-brand .lockup { height: 22px; }
|
||||
|
||||
:root.side-collapsed { --side-w: 64px; }
|
||||
.side-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
|
||||
@@ -1043,9 +1036,6 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.side-collapsed .side-toggle { position: absolute; inset: 0; margin: auto; width: 36px; height: 36px; opacity: 0; }
|
||||
.side-collapsed .side-brand:hover .side-toggle, .side-collapsed .side-toggle:focus-visible { opacity: 1; background: var(--hover); color: var(--text); }
|
||||
.side-collapsed .side-brand:hover .brand-mark, .side-collapsed .side-brand:focus-within .brand-mark { opacity: 0; }
|
||||
.mac.side-collapsed .side-brand { height: auto; padding-top: calc(var(--titlebar) - 4px); flex-direction: column; }
|
||||
.mac.side-collapsed .brand-mark { display: none; }
|
||||
.mac.side-collapsed .side-toggle { position: static; opacity: 1; }
|
||||
.side-collapsed .nav-item { justify-content: center; padding: 0; gap: 0; }
|
||||
.side-collapsed .nav-item > span:not(.i):not(.nav-ring):not(.count), .side-collapsed .nav-item kbd { display: none; }
|
||||
.side-collapsed .nav-item[aria-current="page"]::before { left: -10px; }
|
||||
@@ -1152,14 +1142,14 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
/* choosing artist info online */
|
||||
.modal:has(.pick-photos) { max-width: 720px; }
|
||||
.pick-head { font-size: 12.5px; color: var(--text-2); margin-top: var(--s2); }
|
||||
.pick-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--s2); max-height: 260px; overflow-y: auto; }
|
||||
.pick-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--s2); }
|
||||
.pick-photo { display: grid; gap: 4px; padding: 6px; border-radius: 10px; border: 2px solid transparent; text-align: center; min-width: 0; }
|
||||
.pick-photo:hover { background: var(--hover); }
|
||||
.pick-photo.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
|
||||
.pick-photo img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; background: var(--surface-2, var(--surface)); }
|
||||
.pick-photo span { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.pick-photo small { font-size: 11px; color: var(--text-3); }
|
||||
.pick-pages { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
|
||||
.pick-pages { display: grid; gap: 4px; }
|
||||
.pick-page { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 2px solid transparent; }
|
||||
.pick-page:hover { background: var(--hover); }
|
||||
.pick-page.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
|
||||
@@ -1215,3 +1205,23 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.un-actions { grid-column: 2 / 4; display: flex; gap: var(--s2); flex-wrap: wrap; }
|
||||
.un-close { grid-column: 3; grid-row: 1; margin: -6px -6px 0 0; }
|
||||
@media (prefers-reduced-motion: reduce) { .update-notice { animation: none; } .update-notice.out { transition: none; } }
|
||||
|
||||
/* everything fits the window: dialogs scroll inside, buttons stay visible */
|
||||
.modal-wrap { overflow: hidden; }
|
||||
.modal { max-height: calc(100vh - 2 * var(--s6)); max-height: calc(100dvh - 2 * var(--s6)); display: flex; flex-direction: column; min-height: 0; }
|
||||
.modal > h2, .modal-actions { flex-shrink: 0; }
|
||||
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 calc(-1 * var(--s6)); padding: 2px var(--s6); }
|
||||
.modal-body > * + * { margin-top: 0; }
|
||||
.modal-actions { flex-wrap: wrap; }
|
||||
@media (max-height: 560px), (max-width: 520px) {
|
||||
.modal-wrap { padding: var(--s3); }
|
||||
.modal { padding: var(--s4); gap: var(--s3); max-height: calc(100vh - 2 * var(--s3)); max-height: calc(100dvh - 2 * var(--s3)); }
|
||||
.modal-body { margin: 0 calc(-1 * var(--s4)); padding: 2px var(--s4); }
|
||||
}
|
||||
|
||||
/* expandable rows show a chevron that turns when open */
|
||||
.advanced summary { position: relative; padding-right: 32px; }
|
||||
.advanced summary::after { content: ""; position: absolute; right: 8px; top: 50%; width: 8px; height: 8px; border: solid var(--text-3); border-width: 0 2px 2px 0; transform: translateY(-70%) rotate(45deg); transition: transform 160ms var(--ease); }
|
||||
.advanced[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }
|
||||
.advanced summary:hover::after { border-color: var(--text); }
|
||||
@media (prefers-reduced-motion: reduce) { .advanced summary::after { transition: none; } }
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ function sleepMenu(e) {
|
||||
sleepActive() ? "-" : null,
|
||||
opt("15 minutes", 15), opt("30 minutes", 30), opt("45 minutes", 45), opt("1 hour", 60), opt("2 hours", 120),
|
||||
opt("End of this song", "song"),
|
||||
].filter(Boolean));
|
||||
].filter(Boolean), true);
|
||||
}
|
||||
|
||||
function resumeMap() {
|
||||
|
||||
Reference in New Issue
Block a user