diff --git a/src/download.rs b/src/download.rs index 85afd74..c55a3c4 100644 --- a/src/download.rs +++ b/src/download.rs @@ -54,7 +54,8 @@ impl RollingAverage { pub fn url_to_filename(url: &str) -> String { let url_dec = percent_decode_str(&url).decode_utf8_lossy().to_owned().to_string(); let file_name = std::path::Path::new(&url_dec).file_name().unwrap().to_str().unwrap(); - file_name.to_string() + // Split at ? and return the first part. If no ? is present, this just returns the full string + file_name.split("?").next().unwrap().to_string() } pub async fn download_feedback(url: &str, into_file: &str, rep: DlReporter) -> ResBE<()> { diff --git a/src/main.rs b/src/main.rs index bc4b04e..6b9edca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use clap::{ App, Arg, ArgGroup, crate_version }; use tokio::sync::mpsc; use futures::future::join_all; use std::io::BufRead; +use std::time::SystemTime; use dlreport::{ DlReport, DlStatus, DlReporter }; use errors::ResBE; @@ -179,6 +180,8 @@ async fn download_multiple(urls: Vec, outdir: &str, numparal: i32, boost std::fs::create_dir_all(outdir)?; } + let t_start = SystemTime::now(); + let mut joiners = Vec::new(); let (tx, rx) = mpsc::unbounded_channel::(); @@ -265,6 +268,7 @@ async fn download_multiple(urls: Vec, outdir: &str, numparal: i32, boost join_all(joiners).await; + println!("Total time: {}s", t_start.elapsed()?.as_secs()); Ok(()) } \ No newline at end of file