use super::tags; use super::tags::Tag; use super::dl_list; use super::dl_list::DLListItem; use super::section; use super::section::Section; use super::regex::Regex; use super::tiles; use std::collections::HashMap; #[derive(Debug, Serialize)] pub struct Names { pub english: String, pub aliases: String, pub romaji: String, pub furigana: String, pub japanese: String, } #[derive(Debug, Serialize)] pub struct Series { pub name: Names, } impl Names { pub fn new() -> Self { Names { String::new(), String::new(), String::new(), String::new(), String::new() } } } impl Series { pub fn new() -> Self { Series { name: Names::new() } } pub fn parse(&mut self, buf: &str) { let mut sections = get_sections(); section::process(&buf, &mut sections); { let name: &Section = §ions["name".into()]; self.name.english = name["english".into()]; self.name.aliases = name["aliases".into()]; self.name.romaji = name["romaji".into()]; self.name.furigana = name["furigana".into()]; self.name.japanese = name["japanese".into()]; } } } fn get_sections() -> HashMap { let mut s: HashMap = HashMap::new(); s.insert("name".into(), Section::new("name", r#"(?is)English Title.*?(.*?).*?Aliases.*?(.*?)?.*?Romaji Title.*?(.*?).*?Furigana Title.*?(.*?).*?Japanese Title.*?(.*?)"#, vec!["english", "aliases", "romaji", "furigana", "japanese"])); s }