diff --git a/Cargo.lock b/Cargo.lock index 129df3b..0d34e74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "hanimers" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "quick-xml", diff --git a/Cargo.toml b/Cargo.toml index 5064be0..17c9aba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hanimers" -version = "0.1.0" +version = "0.1.1" authors = ["blank X "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 55c05f1..ee48d04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ fn main() { let matches = App::new("hanimers") .about("hanime.tv downloader in rust") // let's hope i remember to bump the version xd - .version("0.1.0") + .version("0.1.1") .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand( SubCommand::with_name("search") diff --git a/src/structs.rs b/src/structs.rs index c3f719e..e805771 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -66,25 +66,7 @@ pub struct HentaiVideo { impl fmt::Display for HentaiInfo { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let video = &self.state.data.video.hentai_video; - let mut seconds = video.duration_in_ms / 1000; - let mut minutes = seconds / 60; - if minutes > 0 { - seconds -= minutes * 60; - } - let hours = minutes / 60; - if hours > 0 { - minutes -= hours * 60; - seconds -= hours * 60 * 60; - } - let mut duration = String::new(); - if hours > 0 { - duration.push_str(&format!("{}:", hours)); - } - if minutes > 0 { - duration.push_str(&format!("{}:", minutes)); - } - duration.push_str(&seconds.to_string()); - formatter.write_str(&format!("ID: {}\nSlug: {}\nName: {}\nViews: {}\nLikes: {}\nDislikes: {}\nCensored: {}\nHardsubbed: {}\nDuration: {}\nTags: {}\nDescription: {}", + let mut text = format!("ID: {}\nSlug: {}\nName: {}\nViews: {}\nLikes: {}\nDislikes: {}\nCensored: {}\nHardsubbed: {}\n", video.id, &video.slug, &video.name, @@ -98,11 +80,30 @@ impl fmt::Display for HentaiInfo { match video.is_hard_subtitled { true => "Yes", false => "No" - }, - duration, - video.hentai_tags.iter().map(|i| i.text.as_str()).collect::>().join(", "), - &video.description - )) + } + ); + if video.duration_in_ms > 0 { + let mut seconds = video.duration_in_ms / 1000; + let mut minutes = seconds / 60; + if minutes > 0 { + seconds -= minutes * 60; + } + let hours = minutes / 60; + if hours > 0 { + minutes -= hours * 60; + seconds -= hours * 60 * 60; + } + let mut duration = String::new(); + if hours > 0 { + duration.push_str(&format!("{}:", hours)); + } + if minutes > 0 { + duration.push_str(&format!("{}:", minutes)); + } + duration.push_str(&seconds.to_string()); + text.push_str(&format!("Duration: {}\n", &duration)); + } + formatter.write_str(&format!("{}Tags: {}\nDescription: {}", &text, video.hentai_tags.iter().map(|i| i.text.as_str()).collect::>().join(", "), &video.description)) } }