1.4.7 - Fixed 4 and 5 stars search in events.rs
This commit is contained in:
parent
67e1438a77
commit
539bdd8068
2 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "obsessed-yanqing"
|
name = "obsessed-yanqing"
|
||||||
version = "1.4.6"
|
version = "1.4.7"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Evann Regnault"]
|
authors = ["Evann Regnault"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -220,15 +220,17 @@ fn get_event_type(event: Node, description: &Option<(String, String)>) -> EventT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_banner_data(event: Node) -> Option<BannerData> {
|
fn get_banner_data(event: Node) -> Option<BannerData> {
|
||||||
let five_stars = event.find(Class("rarity-5").descendant(Name("picture")).descendant(Name("img"))).next().map(|x| x.attr("alt").expect("No alt on five star image").to_string());
|
let five_stars = event.find(Class("rarity-5").and(Class("avatar").or(Class("hsr-set-image"))).descendant(Name("picture").descendant(Name("img")))).next().map(|x|{
|
||||||
let four_stars = event.find(Class("rarity-4")).take(3).map(|four_stars_node| {
|
x.attr("alt").expect("Cannot get five star")
|
||||||
four_stars_node.find(Name("picture").descendant(Name("img"))).next().map(|x| x.attr("alt").expect("No alt on four star image").to_string()).expect("Cannot get four stars names")
|
}).or(None);
|
||||||
|
let four_stars = event.find(Class("rarity-4").and(Class("avatar").or(Class("hsr-set-image")))).take(3).map(|four_stars_node| {
|
||||||
|
four_stars_node.find(Name("picture").descendant(Name("img"))).next().map(|x| x.attr("alt").expect("Cannot get four stars").to_string()).expect("")
|
||||||
}).collect::<Vec<String>>();
|
}).collect::<Vec<String>>();
|
||||||
|
|
||||||
match five_stars {
|
match five_stars {
|
||||||
None => None,
|
None => None,
|
||||||
Some(x) => match four_stars.len() {
|
Some(x) => match four_stars.len() {
|
||||||
3 => Some(BannerData { five_stars: x, four_stars }),
|
3 => Some(BannerData { five_stars: x.to_string(), four_stars }),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue