From a5ef3f6569aa435759168080498db7bff91fc659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6lfer?= Date: Sat, 4 Oct 2025 11:11:13 +0200 Subject: [PATCH] More parsing --- src/main.rs | 2 +- src/worldsdc/scoringdance.rs | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6fd7f2a..543dbdd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ clippy::cast_possible_wrap, reason = "Disable this for most of the time, enable this for cleanup later" )] - +#![feature(hash_map_macro)] #![feature(never_type)] use mwbot::{ diff --git a/src/worldsdc/scoringdance.rs b/src/worldsdc/scoringdance.rs index 3f25e9c..ab0a232 100644 --- a/src/worldsdc/scoringdance.rs +++ b/src/worldsdc/scoringdance.rs @@ -3,7 +3,7 @@ use scraper::{ElementRef, Html, Selector}; use crate::{ app_signature, - dance_info::DanceInfo, + dance_info::{DanceInfo, DanceRank}, worldsdc::{DanceInfoError, DanceInfoParser}, }; @@ -49,7 +49,24 @@ fn parse_details(d: &[Vec]) { } fn parse_stats(d: &[Vec]) { - let chapters = d.chunk_by(|_, b| b.len() != 1); + let chapters = d.chunk_by(|_, b| b.len() != 1).map(|v| { + let (a, b) = v.split_first().unwrap(); + let a = a.first().unwrap(); + let b = b + .iter() + .map(|v| [v.first().unwrap(), v.last().unwrap()]) + .collect::>(); + (a, b) + }); + + hash_map! { + "Champions" => DanceRank::Champions, + "All-Stars" => DanceRank::AllStars, + "Advanced" => DanceRank::Advanced, + "Intermediate" => DanceRank::Intermediate, + "Newcomer" => DanceRank::Newcomer, + "Novice" => DanceRank::Novice, + }; dbg!(chapters.collect::>()); }