This commit is contained in:
parent
1c0dbb7bba
commit
0db7d4f990
1 changed files with 19 additions and 19 deletions
38
src/main.rs
38
src/main.rs
|
@ -57,7 +57,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
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_or(LOL_CHAMPS_DIR));
|
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))
|
||||||
|
@ -97,27 +100,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
);
|
);
|
||||||
|
|
||||||
for (id, positions) in &champs {
|
for (id, positions) in &champs {
|
||||||
let mut champ_id: String = id.to_owned();
|
let mut champ_id = id.to_owned();
|
||||||
|
|
||||||
if !champion.data.contains_key(&champ_id) {
|
if !champion.data.contains_key(&champ_id) {
|
||||||
champ_id = get_champ_from_key(&champion, &champ_id);
|
if let Some(c_id) = get_champ_from_key(&champion, &champ_id) {
|
||||||
|
champ_id = c_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if champion.data.contains_key(&champ_id) {
|
if let Some(champ) = champion.data.get(&champ_id) {
|
||||||
let path = lol_champs_dir.join(&champ_id).join("Recommended");
|
|
||||||
fs::create_dir_all(&path).unwrap();
|
|
||||||
if positions.is_empty() {
|
if positions.is_empty() {
|
||||||
error!("{} missing positions", &champ_id);
|
error!("{} missing positions", &champ_id);
|
||||||
}
|
} else {
|
||||||
for pos in positions {
|
let path = lol_champs_dir.join(&champ_id).join("Recommended");
|
||||||
data_source.write_item_set(
|
fs::create_dir_all(&path)?;
|
||||||
&champion.data.get(&champ_id).unwrap(),
|
for pos in positions {
|
||||||
&pos,
|
data_source.write_item_set(&champ, &pos, &patch, &path, &client);
|
||||||
&patch,
|
thread::sleep(Duration::from_millis(data_source.get_timeout()));
|
||||||
&path,
|
}
|
||||||
&client,
|
|
||||||
);
|
|
||||||
thread::sleep(Duration::from_millis(data_source.get_timeout()));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!("{} not found in LoL champs", &champ_id);
|
error!("{} not found in LoL champs", &champ_id);
|
||||||
|
@ -127,13 +127,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_champ_from_key(champs: &Champion, key: &str) -> String {
|
fn get_champ_from_key(champs: &Champion, key: &str) -> Option<String> {
|
||||||
for champ in champs.data.values() {
|
for champ in champs.data.values() {
|
||||||
if key == champ.key {
|
if key == champ.key {
|
||||||
return champ.id.to_owned();
|
return Some(champ.id.to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String::new()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue