Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

fix(download): preflight ffmpeg and capture yt-dlp error diagnostics

Samir Hossainsd1aa14275e42
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 816ecd4..f8aac42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [Unreleased]
+
+### Fixed
+- **Download Engine & Subprocess Diagnostics**:
+ - Added preflight verification for `ffmpeg` alongside `yt-dlp` in `src/tui/app/download.rs`, failing fast with installation guidance when media muxing tools are missing.
+ - Captured child process stderr lines during DASH transfers to surface concrete `yt-dlp` error diagnostics instead of bare exit codes.
+
## [0.1.24] - 2026-09-24
### Added
diff --git a/docs/downloads.md b/docs/downloads.md
index 96cf467..7a21306 100644
--- a/docs/downloads.md
+++ b/docs/downloads.md
@@ -39,5 +39,6 @@ MovieBox DASH streams require `yt-dlp` and `ffmpeg` to download and mux adaptive
- **macOS**: `brew install yt-dlp ffmpeg`
- **Android (Termux)**: `pkg install yt-dlp ffmpeg`
- **Linux**: Install `yt-dlp` and `ffmpeg` via system package manager.
+The downloader preflights both binaries before launching the transfer, failing fast with platform-specific installation commands if either is absent. Any subprocess errors during transfer capture and display the underlying `yt-dlp` error diagnostics directly in the failure notification.
All other providers (4KHDHub, BDIX, DhakaFlix, CircleFTP, TV mode) download directly through the internal HTTP engine.
diff --git a/src/tui/app/download.rs b/src/tui/app/download.rs
index 6d1fede..d13705b 100644
--- a/src/tui/app/download.rs
+++ b/src/tui/app/download.rs
@@ -246,6 +246,12 @@ impl App {
.ok();
return;
};
+ if crate::player::find_in_path("ffmpeg").is_none() {
+ sender
+ .send(Action::DownloadFailed(yt_dlp_missing_guidance()))
+ .ok();
+ return;
+ }
let mut cmd = tokio::process::Command::new(ytdlp_bin);
for (k, v) in &headers {
@@ -295,12 +301,19 @@ impl App {
}
};
+ let captured_stderr =
+ std::sync::Arc::new(tokio::sync::Mutex::new(Vec::<String>::new()));
+ let stderr_collector = std::sync::Arc::clone(&captured_stderr);
if let Some(stderr) = child.stderr.take() {
tokio::spawn(async move {
use tokio::io::AsyncBufReadExt;
let mut reader = tokio::io::BufReader::new(stderr).lines();
while let Ok(Some(line)) = reader.next_line().await {
log::debug!("yt-dlp stderr: {line}");
+ let mut buf = stderr_collector.lock().await;
+ if buf.len() < 20 {
+ buf.push(line);
+ }
}
});
}
@@ -390,11 +403,21 @@ impl App {
))
.ok();
} else {
- sender
- .send(Action::DownloadFailed(format!(
- "yt-dlp exited with status {s}"
- )))
- .ok();
+ let lines = captured_stderr.lock().await;
+ let last_err = lines
+ .iter()
+ .rev()
+ .find(|l| l.contains("ERROR:") || !l.trim().is_empty())
+ .cloned();
+ drop(lines);
+ let err_msg = match last_err {
+ Some(e) if e.contains("ffmpeg") || e.contains("ffprobe") => {
+ format!("{e}\n{}", yt_dlp_missing_guidance())
+ }
+ Some(e) => e,
+ None => format!("yt-dlp exited with status {s}"),
+ };
+ sender.send(Action::DownloadFailed(err_msg)).ok();
}
}
Err(err) => {