This commit is contained in:
parent
3f7de3abac
commit
1c0dbb7bba
1 changed files with 8 additions and 12 deletions
20
src/main.rs
20
src/main.rs
|
@ -45,12 +45,11 @@ const USER_AGENT_VALUE: &str =
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0";
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0";
|
||||||
const LOL_CHAMPS_DIR: &str = ".\\champs";
|
const LOL_CHAMPS_DIR: &str = ".\\champs";
|
||||||
|
|
||||||
fn main() {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
SimpleLogger::new()
|
SimpleLogger::new()
|
||||||
.with_level(LevelFilter::Info)
|
.with_level(LevelFilter::Info)
|
||||||
.with_module_level("ureq", LevelFilter::Error)
|
.with_module_level("ureq", LevelFilter::Error)
|
||||||
.init()
|
.init()?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
info!("CGG Item Sets");
|
info!("CGG Item Sets");
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ fn main() {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(_e) => PathBuf::from(LOL_CHAMPS_DIR),
|
Err(_e) => PathBuf::from(LOL_CHAMPS_DIR),
|
||||||
};
|
};
|
||||||
info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap());
|
info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap_or(LOL_CHAMPS_DIR));
|
||||||
|
|
||||||
let client = ureq::AgentBuilder::new()
|
let client = ureq::AgentBuilder::new()
|
||||||
.timeout(Duration::from_secs(10))
|
.timeout(Duration::from_secs(10))
|
||||||
|
@ -67,10 +66,8 @@ fn main() {
|
||||||
let realm: Realm = client
|
let realm: Realm = client
|
||||||
.get("https://ddragon.leagueoflegends.com/realms/euw.json")
|
.get("https://ddragon.leagueoflegends.com/realms/euw.json")
|
||||||
.set(USER_AGENT_KEY, USER_AGENT_VALUE)
|
.set(USER_AGENT_KEY, USER_AGENT_VALUE)
|
||||||
.call()
|
.call()?
|
||||||
.unwrap()
|
.into_json()?;
|
||||||
.into_json()
|
|
||||||
.unwrap();
|
|
||||||
info!("LoL version: {}", realm.v);
|
info!("LoL version: {}", realm.v);
|
||||||
|
|
||||||
let champion: Champion = client
|
let champion: Champion = client
|
||||||
|
@ -79,10 +76,8 @@ fn main() {
|
||||||
realm.v
|
realm.v
|
||||||
))
|
))
|
||||||
.set(USER_AGENT_KEY, USER_AGENT_VALUE)
|
.set(USER_AGENT_KEY, USER_AGENT_VALUE)
|
||||||
.call()
|
.call()?
|
||||||
.unwrap()
|
.into_json()?;
|
||||||
.into_json()
|
|
||||||
.unwrap();
|
|
||||||
info!("LoL numbers of champs: {}", champion.data.len());
|
info!("LoL numbers of champs: {}", champion.data.len());
|
||||||
|
|
||||||
let data_sources: [Box<dyn DataSource>; 3] = [
|
let data_sources: [Box<dyn DataSource>; 3] = [
|
||||||
|
@ -129,6 +124,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_champ_from_key(champs: &Champion, key: &str) -> String {
|
fn get_champ_from_key(champs: &Champion, key: &str) -> String {
|
||||||
|
|
Loading…
Add table
Reference in a new issue