fix(katana): parse wishlist from lookup
So if there's no koibito then the Wishlisted section will move up... Also fixes parsing when wl > 1000 because it'll have a "," to make it easier for human to read.
This commit is contained in:
parent
8eb622f479
commit
95288e7c1e
@ -211,15 +211,31 @@ pub fn parse_cards_from_katana_klu_lookup(content: &String) -> Option<Card> {
|
|||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
// Wishlist
|
// Wishlist
|
||||||
let mut line_split = lines.nth(1).unwrap().split(" · ");
|
let mut line_split: Option<std::str::Split<'_, &str>> = None;
|
||||||
let wishlist = match line_split.nth(1) {
|
while line_split.is_none() {
|
||||||
Some(series) => {
|
line_split = match lines.next() {
|
||||||
let mut series_string = series.to_string();
|
Some(line) => {
|
||||||
series_string.remove_matches("**");
|
if line.contains("Wishlisted") {
|
||||||
match series_string.parse::<u32>() {
|
Some(line.split(" · "))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
error!("Failed to parse wishlist number: {}", content);
|
||||||
|
return None;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let wishlist = match line_split?.nth(1) {
|
||||||
|
Some(wl) => {
|
||||||
|
let mut wl_string = wl.to_string();
|
||||||
|
wl_string.remove_matches("**");
|
||||||
|
wl_string.remove_matches(",");
|
||||||
|
match wl_string.parse::<u32>() {
|
||||||
Ok(wishlist) => wishlist,
|
Ok(wishlist) => wishlist,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
error!("Failed to parse wishlist number: {}", series_string);
|
error!("Failed to parse wishlist number: {}", wl_string);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user