32 lines
795 B
Rust
32 lines
795 B
Rust
use std::str::FromStr;
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
|
use bytes::Bytes;
|
|
|
|
|
|
mod file;
|
|
mod web_parser;
|
|
|
|
|
|
fn main() {
|
|
let mut continue_flag = true;
|
|
let mut idx: i32;
|
|
let index = file::read_file_string("cache/index").expect("Read index error");
|
|
if index.is_empty() {
|
|
idx = 1;
|
|
} else {
|
|
idx = i32::from_str(&index).expect("Index Corrupted");
|
|
}
|
|
while continue_flag {
|
|
let name = web_parser::get_title(idx);
|
|
if name == "" {
|
|
continue_flag = false;
|
|
} else {
|
|
web_parser::download_images(idx, &name);
|
|
idx += 1;
|
|
}
|
|
thread::sleep(Duration::from_millis(300));
|
|
}
|
|
file::write_file("cache/index", Bytes::from(idx.to_string())).expect(&format!("Write index error: {}", idx));
|
|
} |