fix ms datasource
This commit is contained in:
parent
16947d2734
commit
34d50b419d
1 changed files with 6 additions and 3 deletions
|
@ -7,7 +7,10 @@ use crate::Champion;
|
||||||
|
|
||||||
pub struct MSDataSource;
|
pub struct MSDataSource;
|
||||||
|
|
||||||
|
const CHAMP_PATTERN: &str = " href=\"https://www.metasrc.com/5v5/champion/";
|
||||||
|
|
||||||
impl DataSource for MSDataSource {
|
impl DataSource for MSDataSource {
|
||||||
|
|
||||||
fn get_alias(&self) -> &str {
|
fn get_alias(&self) -> &str {
|
||||||
"MS"
|
"MS"
|
||||||
}
|
}
|
||||||
|
@ -30,9 +33,9 @@ impl DataSource for MSDataSource {
|
||||||
.into_string()
|
.into_string()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut pos: Option<usize> = page.find(" href=\"/5v5/champion/");
|
let mut pos: Option<usize> = page.find(CHAMP_PATTERN);
|
||||||
while let Some(mut p) = pos {
|
while let Some(mut p) = pos {
|
||||||
p += 21;
|
p += CHAMP_PATTERN.len();
|
||||||
let role =
|
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()];
|
||||||
|
|
||||||
|
@ -44,7 +47,7 @@ impl DataSource for MSDataSource {
|
||||||
|
|
||||||
champs.insert(id, vec![role.to_string()]);
|
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 {
|
if let Some(n) = next {
|
||||||
pos = Some(p + n);
|
pos = Some(p + n);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue