3个版本
| 0.1.3 | 2021年8月21日 | 
|---|---|
| 0.1.2 | 2021年8月15日 | 
| 0.1.1 | 2021年8月13日 | 
#506 in HTTP客户端
31KB
426 行
shirodl
ShiroDL是一个针对大量URL批量下载的异步下载库
安装
cargo安装 --示例shirodl --githttps://github.com/Oyami-Srk/shirodl
用法
shirodl --help 获取使用帮助。
库
示例
use shirodl::Downloader;
use std::path::PathBuf;
fn main() {
    let mut dler = Downloader::new();
    dler.set_destination(PathBuf::from("."));
    dler.set_hash_check(true);
    dler.append_task(
        "https://avatars.githubusercontent.com/u/6939913?s=48&v=4".to_string(),
        PathBuf::from("."),
        None,
    );
    let result = dler.download(|_, _, _, _| {});
    for r in result {
        println!("Failed: {}, due to {:?}", r.url, r.err);
    }
}
Downloader::download 将创建 Tokio 运行时,因此您可以在常规同步代码中直接调用它。默认下载参数
folder: Default::default(),
timeout: Some(Duration::from_secs(10)),
headers: HeaderMap::new(),
hash_check: false,
only_binary: true,
auto_rename: true,
注意:目前自动重命名仅通过HTTP头中的MIME简单地确定扩展名,并从 subtype 中提取扩展名。需要手动检查,但至少可以提供一些提示。
shirodl::Error::ignorable() 并非总是可忽略的,始终向用户显示错误,并将决定权留给最终用户。
依赖
~11–28MB
~429K SLoC