Show resolution in view

This commit is contained in:
blank X 2021-02-03 16:04:39 +07:00
parent 787b22a1c1
commit 11402254e1
4 changed files with 36 additions and 3 deletions

2
Cargo.lock generated
View File

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

View File

@ -1,6 +1,6 @@
[package] [package]
name = "hanimers" name = "hanimers"
version = "0.1.1" version = "0.1.2"
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.1") .version("0.1.2")
.setting(AppSettings::SubcommandRequiredElseHelp) .setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand( .subcommand(
SubCommand::with_name("search") SubCommand::with_name("search")

View File

@ -82,6 +82,39 @@ impl fmt::Display for HentaiInfo {
false => "No" 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 { 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;