podal/src/fetch.rs

23 lines
621 B
Rust
Raw Normal View History

2023-07-25 10:58:56 +01:00
use crate::prelude::*;
use atom_syndication::Link;
use std::process::Command;
2023-07-25 10:58:56 +01:00
pub type FetchDownload = fn(&Link) -> Result<()>;
2023-07-25 10:58:56 +01:00
pub fn download(link: &Link) -> Result<()> {
2023-07-25 10:58:56 +01:00
let cmd = "yt-dlp";
// println!("{} --extract-audio --audio-format mp3 {}", cmd, &link.href);
let output = Command::new(cmd)
.arg("--extract-audio")
.arg("--audio-format")
.arg("mp3")
.arg(&link.href)
.output()?;
if !output.stderr.is_empty() {
eprintln!("Error: {}", String::from_utf8(output.stderr)?);
println!("{}", String::from_utf8(output.stdout)?);
}
Ok(())
}