diff --git a/src/ms_data_source.rs b/src/ms_data_source.rs index 6ca29cd..e8b37b6 100644 --- a/src/ms_data_source.rs +++ b/src/ms_data_source.rs @@ -7,7 +7,10 @@ use crate::Champion; pub struct MSDataSource; +const CHAMP_PATTERN: &str = " href=\"https://www.metasrc.com/5v5/champion/"; + impl DataSource for MSDataSource { + fn get_alias(&self) -> &str { "MS" } @@ -30,9 +33,9 @@ impl DataSource for MSDataSource { .into_string() .unwrap(); - let mut pos: Option = page.find(" href=\"/5v5/champion/"); + let mut pos: Option = page.find(CHAMP_PATTERN); while let Some(mut p) = pos { - p += 21; + p += CHAMP_PATTERN.len(); let role = &page[p + page[p..].find('/').unwrap() + 1..p + page[p..].find('"').unwrap()]; @@ -44,7 +47,7 @@ impl DataSource for MSDataSource { champs.insert(id, vec![role.to_string()]); - let next = page[p..].find(" href=\"/5v5/champion/"); + let next = page[p..].find(CHAMP_PATTERN); if let Some(n) = next { pos = Some(p + n); } else {