Show resolution in view

master
blank X 2 years ago
parent 787b22a1c1
commit 11402254e1
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 2
      src/main.rs
  4. 33
      src/structs.rs

2
Cargo.lock generated

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

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

@ -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")

@ -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::<i32>() {
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::<Vec<_>>().join(", ")
}
));
}
}
if video.duration_in_ms > 0 {
let mut seconds = video.duration_in_ms / 1000;
let mut minutes = seconds / 60;

Loading…
Cancel
Save