Don't show duration if <= 0

This commit is contained in:
blank X 2021-02-03 14:27:40 +07:00
parent efd375e758
commit 787b22a1c1
4 changed files with 28 additions and 27 deletions

2
Cargo.lock generated
View File

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

View File

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

View File

@ -8,7 +8,7 @@ fn main() {
let matches = App::new("hanimers") let matches = App::new("hanimers")
.about("hanime.tv downloader in rust") .about("hanime.tv downloader in rust")
// let's hope i remember to bump the version xd // let's hope i remember to bump the version xd
.version("0.1.0") .version("0.1.1")
.setting(AppSettings::SubcommandRequiredElseHelp) .setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand( .subcommand(
SubCommand::with_name("search") SubCommand::with_name("search")

View File

@ -66,6 +66,23 @@ pub struct HentaiVideo {
impl fmt::Display for HentaiInfo { impl fmt::Display for HentaiInfo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let video = &self.state.data.video.hentai_video; let video = &self.state.data.video.hentai_video;
let mut text = format!("ID: {}\nSlug: {}\nName: {}\nViews: {}\nLikes: {}\nDislikes: {}\nCensored: {}\nHardsubbed: {}\n",
video.id,
&video.slug,
&video.name,
video.views,
video.likes,
video.dislikes,
match video.is_censored {
true => "Yes",
false => "No"
},
match video.is_hard_subtitled {
true => "Yes",
false => "No"
}
);
if video.duration_in_ms > 0 {
let mut seconds = video.duration_in_ms / 1000; let mut seconds = video.duration_in_ms / 1000;
let mut minutes = seconds / 60; let mut minutes = seconds / 60;
if minutes > 0 { if minutes > 0 {
@ -84,25 +101,9 @@ impl fmt::Display for HentaiInfo {
duration.push_str(&format!("{}:", minutes)); duration.push_str(&format!("{}:", minutes));
} }
duration.push_str(&seconds.to_string()); duration.push_str(&seconds.to_string());
formatter.write_str(&format!("ID: {}\nSlug: {}\nName: {}\nViews: {}\nLikes: {}\nDislikes: {}\nCensored: {}\nHardsubbed: {}\nDuration: {}\nTags: {}\nDescription: {}", text.push_str(&format!("Duration: {}\n", &duration));
video.id, }
&video.slug, formatter.write_str(&format!("{}Tags: {}\nDescription: {}", &text, video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", "), &video.description))
&video.name,
video.views,
video.likes,
video.dislikes,
match video.is_censored {
true => "Yes",
false => "No"
},
match video.is_hard_subtitled {
true => "Yes",
false => "No"
},
duration,
video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", "),
&video.description
))
} }
} }