display command output while it is running

This commit is contained in:
Paul Campbell 2023-07-24 07:24:03 +01:00
parent 47ff64585b
commit e18c0f8bea

View file

@ -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();