diff --git a/Cargo.lock b/Cargo.lock index 0d34e74..fe7a16f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "hanimers" -version = "0.1.1" +version = "0.1.2" dependencies = [ "clap", "quick-xml", diff --git a/Cargo.toml b/Cargo.toml index 17c9aba..a03060b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hanimers" -version = "0.1.1" +version = "0.1.2" authors = ["blank X "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index ee48d04..8960868 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.1") + .version("0.1.2") .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand( SubCommand::with_name("search") diff --git a/src/structs.rs b/src/structs.rs index e805771..ac4c410 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -82,6 +82,39 @@ impl fmt::Display for HentaiInfo { false => "No" } ); + let servers = &self.state.data.video.videos_manifest.servers; + if !servers.is_empty() { + let mut string_servers = Vec::new(); + for server in servers { + let mut tmp_string_servers = string_servers.clone(); + for stream in &server.streams { + if !stream.url.is_empty() && !tmp_string_servers.contains(&stream.height) { + tmp_string_servers.push(stream.height.clone()); + } + } + string_servers.extend(tmp_string_servers); + } + if !string_servers.is_empty() { + string_servers.sort(); + let mut int_servers = Vec::with_capacity(string_servers.len()); + for i in &string_servers { + match i.parse::() { + Ok(i) => int_servers.push(i), + Err(_) => { + int_servers.clear(); + break; + } + }; + } + int_servers.sort(); + text.push_str(&format!("Resolution: {}\n", + match int_servers.is_empty() { + true => string_servers.join(", "), + false => int_servers.iter().map(|i| i.to_string()).collect::>().join(", ") + } + )); + } + } if video.duration_in_ms > 0 { let mut seconds = video.duration_in_ms / 1000; let mut minutes = seconds / 60;