handle roster history without steam group

This commit is contained in:
Robin Appelman 2024-02-25 13:44:40 +01:00
commit c81cc2f717
5 changed files with 2460 additions and 10 deletions

View file

@ -172,7 +172,7 @@ pub struct Record {
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[non_exhaustive]
pub struct TeamRosterData {
pub steam_group: String,
pub steam_group: Option<String>,
pub history: Vec<RosterHistory>,
}

View file

@ -49,16 +49,10 @@ impl Parser for TeamRosterHistoryParser {
fn parse(&self, document: &str) -> Result<Self::Output> {
let document = Html::parse_document(document);
let steam_group = document.select(&self.selector_steam_group).next().ok_or(
ParseError::ElementNotFound {
selector: SELECTOR_STEAM,
role: "team steam group",
},
)?;
let steam_group = document.select(&self.selector_steam_group).next();
let steam_group = steam_group
.attr("href")
.unwrap_or_default()
.replace("http://http", "http");
.and_then(|link| link.attr("href"))
.map(|href| href.replace("http://http", "http"));
let history = document
.select(&self.selector_item)