diff --git a/releases/YTPlayer_1.0.0_x64-setup.exe b/releases/YTPlayer_1.0.0_x64-setup.exe index 2073903..1246ee0 100644 Binary files a/releases/YTPlayer_1.0.0_x64-setup.exe and b/releases/YTPlayer_1.0.0_x64-setup.exe differ diff --git a/releases/YTPlayer_1.0.0_x64_en-US.msi b/releases/YTPlayer_1.0.0_x64_en-US.msi index 404f474..724b8b2 100644 Binary files a/releases/YTPlayer_1.0.0_x64_en-US.msi and b/releases/YTPlayer_1.0.0_x64_en-US.msi differ diff --git a/releases/ytplayer.exe b/releases/ytplayer.exe index a122221..d0e1b2c 100644 Binary files a/releases/ytplayer.exe and b/releases/ytplayer.exe differ diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 100e43c..bd1a327 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -21,7 +21,31 @@ use tauri::Manager; const SEARCH_LIMIT: u32 = 25; -/// Locate yt-dlp: prefer the bundled resource copy, then a dev ./bin, then PATH. +// yt-dlp.exe is baked straight into this binary at compile time, so the standalone +// `ytplayer.exe` is fully self-contained — no sibling file and nothing on PATH +// required. On first run we materialize it into the app cache dir and run from there. +// (Windows only; other platforms fall back to a resource/dev/PATH copy.) +#[cfg(windows)] +static YTDLP_EMBEDDED: &[u8] = include_bytes!("../../bin/yt-dlp.exe"); + +/// Write the embedded yt-dlp to the cache dir if it isn't already there (size-checked), +/// and return its path. +#[cfg(windows)] +fn embedded_ytdlp(app: &tauri::AppHandle) -> Option { + let dir = app.path().app_cache_dir().ok()?; + std::fs::create_dir_all(&dir).ok()?; + let dest = dir.join("yt-dlp.exe"); + let fresh = std::fs::metadata(&dest) + .map(|m| m.len() == YTDLP_EMBEDDED.len() as u64) + .unwrap_or(false); + if !fresh { + std::fs::write(&dest, YTDLP_EMBEDDED).ok()?; + } + Some(dest) +} + +/// Locate yt-dlp: prefer a bundled resource copy, then a dev ./bin, then the +/// embedded self-contained copy (Windows), then finally PATH. fn ytdlp_path(app: &tauri::AppHandle) -> PathBuf { let name = if cfg!(windows) { "yt-dlp.exe" } else { "yt-dlp" }; if let Ok(res) = app.path().resource_dir() { @@ -34,6 +58,12 @@ fn ytdlp_path(app: &tauri::AppHandle) -> PathBuf { if dev.exists() { return dev; } + #[cfg(windows)] + { + if let Some(p) = embedded_ytdlp(app) { + return p; + } + } PathBuf::from(name) } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 428ef39..71634ab 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -35,9 +35,6 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ], - "resources": { - "../bin/yt-dlp.exe": "bin/yt-dlp.exe" - } + ] } }