aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 2123c6b..97b3094 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,4 @@
1extern crate regex; 1extern crate regex;
2use regex::Regex;
3 2
4extern crate walkdir; 3extern crate walkdir;
5use walkdir::WalkDir; 4use walkdir::WalkDir;
@@ -7,7 +6,8 @@ use walkdir::WalkDir;
7use std::io::prelude::*; 6use std::io::prelude::*;
8use std::fs::File; 7use std::fs::File;
9use std::env; 8use std::env;
10use std::path::{Path, PathBuf}; 9use std::path::Path;
10use std::collections::HashMap;
11 11
12mod pre_process; 12mod pre_process;
13use pre_process::Section; 13use pre_process::Section;
@@ -17,12 +17,13 @@ fn main() {
17 let base_path = Path::new(&raw_files); 17 let base_path = Path::new(&raw_files);
18 18
19 let mut sections: Vec<Section> = vec![]; 19 let mut sections: Vec<Section> = vec![];
20 sections.push(Section::new("name", r#"(?is)Romaji Name.*?<TD>(.*?)\s?</TD>.*?Japanese Name.*?<TD>(.*?)\s?</TD>"#, vec!["romaji".into(), "japanese".into()]));
20 sections.push(Section::new("image", r#"(?is)<H3 id="section99">.*<img src="(.*?)" alt=.*?></a><p><a href="(.*?)">View Full Size Image"#, vec!["thumb".into(), "full".into()])); 21 sections.push(Section::new("image", r#"(?is)<H3 id="section99">.*<img src="(.*?)" alt=.*?></a><p><a href="(.*?)">View Full Size Image"#, vec!["thumb".into(), "full".into()]));
21 22
22 for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { 23 for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) {
23 let mut f = File::open(entry.path()).expect("could not open file"); 24 let mut f = File::open(entry.path()).expect("could not open file");
24 let mut buf = String::new(); 25 let mut buf = String::new();
25 if let Err(e) = f.read_to_string(&mut buf) { 26 if let Err(_) = f.read_to_string(&mut buf) {
26 println!("invalid file: {}", entry.path().to_str().unwrap()); 27 println!("invalid file: {}", entry.path().to_str().unwrap());
27 continue; 28 continue;
28 } 29 }
@@ -31,6 +32,11 @@ fn main() {
31 32
32 pre_process::split_sections(&buf, &mut sections); 33 pre_process::split_sections(&buf, &mut sections);
33 34
34 println!("{:?}", sections[0].data); 35 let mut char: HashMap<String, HashMap<String, String>> = HashMap::new();
36 for s in &sections {
37 char.insert(s.name.clone(), s.data.clone());
38 }
39
40 println!("{:?}", char);
35 } 41 }
36} 42}