Fix download of non search inputs & .cargo config
This commit is contained in:
parent
f62db8e68d
commit
bf0b8b2bad
2 changed files with 56 additions and 53 deletions
2
.cargo/config
Normal file
2
.cargo/config
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[net]
|
||||||
|
git-fetch-with-cli = true
|
||||||
107
src/main.rs
107
src/main.rs
|
|
@ -78,7 +78,7 @@ async fn start() {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let spotify = match Spotify::new(
|
let spotify = match Spotify::new(
|
||||||
&settings.username,
|
&settings.username,
|
||||||
&settings.password,
|
&settings.password,
|
||||||
|
|
@ -143,60 +143,61 @@ async fn start() {
|
||||||
e
|
e
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
return;
|
||||||
let refresh = Duration::from_secs(settings.refresh_ui_seconds);
|
|
||||||
let now = Instant::now();
|
|
||||||
let mut time_elapsed: u64;
|
|
||||||
|
|
||||||
'outer: loop {
|
|
||||||
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
|
|
||||||
let mut exit_flag: i8 = 1;
|
|
||||||
|
|
||||||
for download in downloader.get_downloads().await {
|
|
||||||
let state = download.state;
|
|
||||||
|
|
||||||
let progress: String;
|
|
||||||
|
|
||||||
if state != DownloadState::Done {
|
|
||||||
exit_flag &= 0;
|
|
||||||
progress = match state {
|
|
||||||
DownloadState::Downloading(r, t) => {
|
|
||||||
let p = r as f32 / t as f32 * 100.0;
|
|
||||||
if p > 100.0 {
|
|
||||||
"100%".to_string()
|
|
||||||
} else {
|
|
||||||
format!("{}%", p as i8)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DownloadState::Post => "Postprocessing... ".to_string(),
|
|
||||||
DownloadState::None => "Preparing... ".to_string(),
|
|
||||||
DownloadState::Lock => "Preparing... ".to_string(),
|
|
||||||
DownloadState::Error(e) => {
|
|
||||||
exit_flag |= 1;
|
|
||||||
format!("{} ", e)
|
|
||||||
}
|
|
||||||
DownloadState::Done => {
|
|
||||||
exit_flag |= 1;
|
|
||||||
"Impossible state".to_string()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
progress = "Done.".to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("{:<19}| {}", progress, download.title);
|
|
||||||
}
|
|
||||||
time_elapsed = now.elapsed().as_secs();
|
|
||||||
if exit_flag == 1 {
|
|
||||||
break 'outer;
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("\nElapsed second(s): {}", time_elapsed);
|
|
||||||
task::sleep(refresh).await
|
|
||||||
}
|
|
||||||
println!("Finished download(s) in {} second(s).", time_elapsed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let refresh = Duration::from_secs(settings.refresh_ui_seconds);
|
||||||
|
let now = Instant::now();
|
||||||
|
let mut time_elapsed: u64;
|
||||||
|
|
||||||
|
'outer: loop {
|
||||||
|
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
|
||||||
|
let mut exit_flag: i8 = 1;
|
||||||
|
|
||||||
|
for download in downloader.get_downloads().await {
|
||||||
|
let state = download.state;
|
||||||
|
|
||||||
|
let progress: String;
|
||||||
|
|
||||||
|
if state != DownloadState::Done {
|
||||||
|
exit_flag &= 0;
|
||||||
|
progress = match state {
|
||||||
|
DownloadState::Downloading(r, t) => {
|
||||||
|
let p = r as f32 / t as f32 * 100.0;
|
||||||
|
if p > 100.0 {
|
||||||
|
"100%".to_string()
|
||||||
|
} else {
|
||||||
|
format!("{}%", p as i8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DownloadState::Post => "Postprocessing... ".to_string(),
|
||||||
|
DownloadState::None => "Preparing... ".to_string(),
|
||||||
|
DownloadState::Lock => "Preparing... ".to_string(),
|
||||||
|
DownloadState::Error(e) => {
|
||||||
|
exit_flag |= 1;
|
||||||
|
format!("{} ", e)
|
||||||
|
}
|
||||||
|
DownloadState::Done => {
|
||||||
|
exit_flag |= 1;
|
||||||
|
"Impossible state".to_string()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
progress = "Done.".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("{:<19}| {}", progress, download.title);
|
||||||
|
}
|
||||||
|
time_elapsed = now.elapsed().as_secs();
|
||||||
|
if exit_flag == 1 {
|
||||||
|
break 'outer;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("\nElapsed second(s): {}", time_elapsed);
|
||||||
|
task::sleep(refresh).await
|
||||||
|
}
|
||||||
|
println!("Finished download(s) in {} second(s).", time_elapsed);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("{} {}", "Handling input failed:".red(), e)
|
error!("{} {}", "Handling input failed:".red(), e)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue