Beatsaber Rust Utilities: A Beatsaber V3 parsing library.
beatsaber beatmap
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 40 lines 1.2 kB view raw
1use bsru::difficulty::Difficulty; 2use bsru::info::Beatmap; 3use std::fs; 4 5#[test] 6#[ignore] 7fn parse_beatmaps() { 8 let paths = fs::read_dir("test_maps").unwrap().filter_map(|result| { 9 if let Ok(dir) = result { 10 if dir.path().is_dir() { 11 return Some(dir.path()); 12 } 13 } 14 None 15 }); 16 17 for path in paths { 18 println!("{path:?}"); 19 let mut info_path = path.clone(); 20 info_path.push("Info.dat"); 21 22 let info_file = fs::File::open(&info_path).expect("Map missing info file"); 23 let map: Beatmap = serde_json::from_reader(info_file).expect("Invalid info file"); 24 25 for set in map.difficulty_sets { 26 println!("\t{:?}", set.characteristic); 27 28 for dif in set.difficulties { 29 println!("\t\t{} ({:?})", dif.name, dif.rank); 30 31 let mut dif_path = path.clone(); 32 dif_path.push(dif.file); 33 34 let dif_file = fs::File::open(&dif_path).expect("Map missing difficulty file"); 35 let _: Difficulty = 36 serde_json::from_reader(dif_file).expect("Invalid difficulty file"); 37 } 38 } 39 } 40}