use crate::prelude::*; use atom_syndication::Link; use std::process::Command; pub struct FetchEnv { pub download: FetchDownload, pub get: FetchGet, } pub type FetchDownload = fn(&Link) -> Result<()>; pub type FetchGet = fn(&str) -> Result; pub fn download(link: &Link) -> Result<()> { 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(()) } pub type Response = String; pub fn get(url: &str) -> Result { Ok(reqwest::blocking::get(url)?.text()?) }