mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 18:24:10 +02:00
extract region
This commit is contained in:
parent
98b690356c
commit
8fd98b708f
5 changed files with 51 additions and 1 deletions
|
|
@ -5,8 +5,9 @@ use crate::parser::{
|
|||
};
|
||||
use crate::{ParseError, Result, ScrapeError};
|
||||
use scraper::{Html, Selector};
|
||||
use std::str::FromStr;
|
||||
use time::{Date, PrimitiveDateTime, Time, UtcOffset};
|
||||
use ugc_scraper_types::GameMode;
|
||||
use ugc_scraper_types::{GameMode, Region};
|
||||
|
||||
const SELECTOR_TEAM_NAME: &str = ".container .col-md-12 h1 > b";
|
||||
const SELECTOR_TEAM_TAG: &str = ".container .col-md-12 h1 > span";
|
||||
|
|
@ -171,6 +172,14 @@ impl Parser for TeamParser {
|
|||
})?
|
||||
.to_string();
|
||||
|
||||
let region = division
|
||||
.split(' ')
|
||||
.find_map(|part| Region::from_str(part).ok())
|
||||
.ok_or_else(|| ParseError::InvalidText {
|
||||
text: division.clone(),
|
||||
role: "team region",
|
||||
})?;
|
||||
|
||||
let timezone = select_text(root, &self.selector_team_timezone).map(String::from);
|
||||
|
||||
let description = select_text(root, &self.selector_team_description)
|
||||
|
|
@ -354,6 +363,7 @@ impl Parser for TeamParser {
|
|||
results,
|
||||
members,
|
||||
name_changes,
|
||||
region,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue