aboutsummaryrefslogtreecommitdiff
path: root/src/series.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/series.rs')
-rw-r--r--src/series.rs63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/series.rs b/src/series.rs
new file mode 100644
index 0000000..d111fb8
--- /dev/null
+++ b/src/series.rs
@@ -0,0 +1,63 @@
1use super::tags;
2use super::tags::Tag;
3use super::dl_list;
4use super::dl_list::DLListItem;
5use super::section;
6use super::section::Section;
7use super::regex::Regex;
8use super::tiles;
9
10use std::collections::HashMap;
11
12#[derive(Debug, Serialize)]
13pub struct Names {
14 pub english: String,
15 pub aliases: String,
16 pub romaji: String,
17 pub furigana: String,
18 pub japanese: String,
19}
20
21#[derive(Debug, Serialize)]
22pub struct Series {
23 pub name: Names,
24}
25
26impl Names {
27 pub fn new() -> Self {
28 Names {
29 String::new(), String::new(), String::new(), String::new(), String::new()
30 }
31 }
32}
33
34impl Series {
35 pub fn new() -> Self {
36 Series {
37 name: Names::new()
38 }
39 }
40
41 pub fn parse(&mut self, buf: &str) {
42 let mut sections = get_sections();
43 section::process(&buf, &mut sections);
44
45 {
46 let name: &Section = &sections["name".into()];
47
48 self.name.english = name["english".into()];
49 self.name.aliases = name["aliases".into()];
50 self.name.romaji = name["romaji".into()];
51 self.name.furigana = name["furigana".into()];
52 self.name.japanese = name["japanese".into()];
53 }
54 }
55}
56
57fn get_sections() -> HashMap<String, Section> {
58 let mut s: HashMap<String, Section> = HashMap::new();
59
60 s.insert("name".into(), Section::new("name", r#"(?is)English Title.*?<TD>(.*?)</TD>.*?Aliases.*?<TD>(.*?)?</TD>.*?Romaji Title.*?<TD.*?>(.*?)</TD>.*?Furigana Title.*?<TD.*?>(.*?)</TD>.*?Japanese Title.*?<TD.*?>(.*?)</TD>"#, vec!["english", "aliases", "romaji", "furigana", "japanese"]));
61
62 s
63}