Pad the left side of hours/minutes/seconds with 0 and handle no description

This commit is contained in:
blank X 2021-03-23 12:52:04 +07:00
parent 64763e014f
commit 71727a7b6f
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
3 changed files with 10 additions and 7 deletions

2
Cargo.lock generated
View File

@ -202,7 +202,7 @@ dependencies = [
[[package]]
name = "hanimers"
version = "0.1.6"
version = "0.1.7"
dependencies = [
"clap",
"quick-xml",

View File

@ -1,6 +1,6 @@
[package]
name = "hanimers"
version = "0.1.6"
version = "0.1.7"
authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018"

View File

@ -135,15 +135,18 @@ impl fmt::Display for HentaiInfo {
}
let mut duration = String::new();
if hours > 0 {
duration.push_str(&format!("{}:", hours));
duration.push_str(&format!("{:02}:", hours));
}
if minutes > 0 {
duration.push_str(&format!("{}:", minutes));
duration.push_str(&format!("{:02}:", minutes));
}
duration.push_str(&seconds.to_string());
text.push_str(&format!("Duration: {}\n", &duration));
text.push_str(&format!("Duration: {}{:02}\n", &duration, seconds));
}
formatter.write_str(&format!("{}Tags: {}\nDescription: {}", &text, video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", "), &video.description))
text.push_str(&format!("Tags: {}", video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", ")));
if !video.description.is_empty() {
text.push_str(&format!("\nDescription: {}", &video.description));
}
formatter.write_str(&text)
}
}