fix: resolve media download bugs and Add window UI issues

- Fix 'Unknown size' for YouTube videos by improving media size estimation fallback
- Optimize yt-dlp metadata fetch by isolating PATH to bundled binaries
- Fix dull slider color in Add window using Tailwind accent class
- Fix Add window failing to fetch metadata automatically upon re-opening via paste
This commit is contained in:
NimBold
2026-06-20 23:14:18 +03:30
parent c59db4e032
commit 262633f441
2 changed files with 16 additions and 16 deletions
+13 -15
View File
@@ -245,19 +245,17 @@ fn joined_format_label(container: &str, video_codec: Option<&str>, audio_codec:
} }
fn estimated_merged_size(video: Option<&serde_json::Value>, audio: Option<&serde_json::Value>) -> (Option<u64>, Option<u64>) { fn estimated_merged_size(video: Option<&serde_json::Value>, audio: Option<&serde_json::Value>) -> (Option<u64>, Option<u64>) {
let Some(video) = video else { let v_bytes = video.and_then(media_sized_bytes);
return (None, None); let a_bytes = audio.and_then(media_sized_bytes);
};
let Some((video_size, video_approx)) = media_sized_bytes(video) else { match (v_bytes, a_bytes) {
return (None, None); (Some((v_size, v_approx)), Some((a_size, a_approx))) => {
}; split_size_estimate(Some((v_size.saturating_add(a_size), v_approx || a_approx)))
let Some(audio) = audio else { }
return split_size_estimate(Some((video_size, video_approx))); (Some((v_size, _v_approx)), None) => split_size_estimate(Some((v_size, true))),
}; (None, Some((a_size, _a_approx))) => split_size_estimate(Some((a_size, true))),
let Some((audio_size, audio_approx)) = media_sized_bytes(audio) else { (None, None) => (None, None),
return (None, None); }
};
split_size_estimate(Some((video_size.saturating_add(audio_size), video_approx || audio_approx)))
} }
fn raw_media_format(value: &serde_json::Value) -> Option<MediaFormat> { fn raw_media_format(value: &serde_json::Value) -> Option<MediaFormat> {
@@ -847,13 +845,13 @@ async fn fetch_media_metadata_uncached(app_handle: tauri::AppHandle, url: String
symlink(&ffmpeg_path, bin_dir.path().join("ffmpeg")).map_err(|e| format!("failed to symlink ffmpeg: {e}"))?; symlink(&ffmpeg_path, bin_dir.path().join("ffmpeg")).map_err(|e| format!("failed to symlink ffmpeg: {e}"))?;
} }
let bin_dir_str = bin_dir.path().to_string_lossy().to_string(); let bin_dir_str = bin_dir.path().to_string_lossy().to_string();
let original_path = std::env::var("PATH").unwrap_or_else(|_| "/usr/bin:/bin".to_string()); let path_env = format!("{}:/usr/bin:/bin", bin_dir_str);
let path_env = format!("{}:{}", bin_dir_str, original_path);
use tauri_plugin_shell::ShellExt; use tauri_plugin_shell::ShellExt;
let (ytdlp_path, _) = resolve_metadata_ytdlp_path(&app_handle)?; let (ytdlp_path, _) = resolve_metadata_ytdlp_path(&app_handle)?;
let mut cmd = app_handle.shell().command(ytdlp_path.to_string_lossy().to_string()); let mut cmd = app_handle.shell().command(ytdlp_path.to_string_lossy().to_string());
cmd = cmd.env("PATH", &path_env) cmd = cmd.env("PATH", &path_env)
.arg("--ffmpeg-location").arg(&bin_dir_str)
.arg("--no-warnings") .arg("--no-warnings")
.arg("--no-playlist") .arg("--no-playlist")
.arg("--skip-download") .arg("--skip-download")
+3 -1
View File
@@ -335,6 +335,8 @@ export const AddDownloadsModal = () => {
setCookies(pendingAddCookies); setCookies(pendingAddCookies);
setMirrors(''); setMirrors('');
setIsActionMenuOpen(false); setIsActionMenuOpen(false);
} else {
setUrls('');
} }
}, [ }, [
isAddModalOpen, isAddModalOpen,
@@ -1018,7 +1020,7 @@ export const AddDownloadsModal = () => {
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<label className="text-xs text-text-secondary font-medium">Connections per File</label> <label className="text-xs text-text-secondary font-medium">Connections per File</label>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<input type="range" min="1" max="16" value={connections} onChange={e=>setConnections(Number(e.target.value))} className="add-download-range w-24" disabled={parsedItems.some(i => i.isMedia)} aria-label="Connections per file" /> <input type="range" min="1" max="16" value={connections} onChange={e=>setConnections(Number(e.target.value))} className="add-download-range w-24 accent-blue-500" disabled={parsedItems.some(i => i.isMedia)} aria-label="Connections per file" />
<span className="add-download-value text-xs text-text-primary font-mono w-6 text-center">{connections}</span> <span className="add-download-value text-xs text-text-primary font-mono w-6 text-center">{connections}</span>
</div> </div>
</div> </div>