From e18c0f8bea3f45db61627640fe62fb0f92c4b0f7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 24 Jul 2023 07:24:03 +0100 Subject: [PATCH] display command output while it is running --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 364eb60..c35928d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,14 +125,14 @@ fn download_audio(link: &Link) -> Result<()> { let cmd = "yt-dlp"; println!("download audio for {}", link.href()); println!("{} --extract-audio --audio-format mp3 {}", cmd, &link.href); - let output = Command::new(cmd) + let mut child = Command::new(cmd) .arg("--extract-audio") .arg("--audio-format") .arg("mp3") .arg(&link.href) - .output() + .spawn() .expect("Failed to execute command"); - println!("Output: {:#?}", output); + child.wait()?; Ok(()) } @@ -143,6 +143,7 @@ fn mark_as_downloaded(link: &Link, file_name: &str) -> Result<()> { let mut file = OpenOptions::new() .write(true) .append(true) + .create(true) .open(file_name) .unwrap();