1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-07-01 18:17:46 +00:00
auracite/src/downloader.rs

26 lines
603 B
Rust
Raw Normal View History

2024-09-29 17:45:53 -04:00
use downloader::{Download, Downloader};
use std::path::Path;
pub fn download(url: &str, path: &Path) -> Result<(), ()> {
let mut downloader = Downloader::builder().build().unwrap();
let mut dl = Download::new(url);
dl = dl.file_name(path);
if !path.exists() {
let result = downloader.download(&[dl]).unwrap();
for r in result {
return match r {
Err(e) => {
println!("Error: {}", e.to_string());
Err(())
}
Ok(s) => Ok(()),
};
}
}
Ok(())
}