ms: fix parser
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nyyu 2021-11-14 18:05:45 +01:00
parent 1bb8e6ce24
commit 0a9877eff1

View file

@ -7,7 +7,7 @@ use crate::Champion;
pub struct MSDataSource;
const CHAMP_PATTERN: &str = " href=\"https://www.metasrc.com/5v5/champion/";
const CHAMP_PATTERN: &str = " href=https://www.metasrc.com/5v5/champion/";
impl DataSource for MSDataSource {
fn get_alias(&self) -> &str {
@ -36,11 +36,11 @@ impl DataSource for MSDataSource {
while let Some(mut p) = pos {
p += CHAMP_PATTERN.len();
let role =
&page[p + page[p..].find('/').unwrap() + 1..p + page[p..].find('"').unwrap()];
&page[p + page[p..].find('/').unwrap() + 1..p + page[p..].find('>').unwrap()];
let k = p + page[p..].find("data-search-terms-like=\"").unwrap() + 24;
let k = p + page[p..].find("data-search-terms-like=").unwrap() + 23;
let pipe = k + page[k..].find('|').unwrap() + 1;
let key = &page[pipe..pipe + page[pipe..].find('"').unwrap()];
let key = &page[pipe..pipe + page[pipe..].find(' ').unwrap()].replace("\"", "");
let id = champion.data.get(key).unwrap().key.parse::<u32>().unwrap();