Expand description
BMS difficulty table fetching and parsing
Provides building a complete BMS difficulty table data structure from a web page or a header JSON, covering the header, courses, trophies, and chart items. Combined with feature flags, it implements network fetching and HTML parsing, suitable for CLI tools, server programs, or data-processing pipelines.
§Feature overview
- Parse header JSON into
BmsTableHeader, preserving unrecognized fields inextrafor forward compatibility; - Parse chart data into
BmsTableData, supporting a plain array ofChartItemstructure; - Courses automatically convert
md5/sha256lists into chart items, filling missinglevelwith “0”; - Extract the header JSON URL from HTML
<meta name="bmstable">; - One-stop network fetching APIs (web page → header JSON → chart data);
- Support fetching a list of difficulty tables into
BmsTableList. An example source page.
§Feature flags
serde: enable serialization/deserialization support for types (enabled by default).scraper: enable HTML parsing and bmstable header URL extraction (enabled by default; implicitly enabled byreqwest).reqwest: enable the network fetching implementation (enabled by default; requires thetokioruntime).
§Quick start (network fetching)
use bms_table::fetch::reqwest::{fetch_table, make_lenient_client};
let client = make_lenient_client()?;
let table = fetch_table(&client, "https://stellabms.xyz/sl/table.html").await?;
println!("{}: {} charts", table.header.name, table.data.charts.len());§Offline usage (parse JSON directly)
use bms_table::{BmsTable, BmsTableHeader, BmsTableData};
let header_json = r#"{ "name": "Test", "symbol": "t", "data_url": "charts.json", "course": [], "level_order": [] }"#;
let data_json = r#"[]"#;
let header: BmsTableHeader = serde_json::from_str(header_json)?;
let data: BmsTableData = serde_json::from_str(data_json)?;
let _table = BmsTable { header, data };§Example: fetch table list
use bms_table::fetch::reqwest::{fetch_table_list, make_lenient_client};
let client = make_lenient_client()?;
let listes = fetch_table_list(&client, "https://example.com/table_list.json").await?;
assert!(!listes.is_empty());Hint: enabling the reqwest feature implicitly enables scraper to support locating the bmstable header URL from page content.
Modules§
Structs§
- BmsTable
- Top-level BMS difficulty table data structure.
- BmsTable
Data - BMS table data.
- BmsTable
Header - BMS header information.
- BmsTable
Info - BMS difficulty table list item.
- BmsTable
List - Wrapper type for the list of BMS difficulty tables.
- BmsTable
Raw - Complete set of original JSON strings.
- Chart
Item - Chart data item.
- Course
Info - Course information.
- Trophy
- Trophy information.