Don't show duration if <= 0
This commit is contained in:
parent
efd375e758
commit
787b22a1c1
|
@ -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",
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -66,25 +66,7 @@ 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 seconds = video.duration_in_ms / 1000;
|
let mut text = format!("ID: {}\nSlug: {}\nName: {}\nViews: {}\nLikes: {}\nDislikes: {}\nCensored: {}\nHardsubbed: {}\n",
|
||||||
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: {}",
|
|
||||||
video.id,
|
video.id,
|
||||||
&video.slug,
|
&video.slug,
|
||||||
&video.name,
|
&video.name,
|
||||||
|
@ -98,11 +80,30 @@ impl fmt::Display for HentaiInfo {
|
||||||
match video.is_hard_subtitled {
|
match video.is_hard_subtitled {
|
||||||
true => "Yes",
|
true => "Yes",
|
||||||
false => "No"
|
false => "No"
|
||||||
},
|
}
|
||||||
duration,
|
);
|
||||||
video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", "),
|
if video.duration_in_ms > 0 {
|
||||||
&video.description
|
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::<Vec<_>>().join(", "), &video.description))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue