optional team image

This commit is contained in:
Robin Appelman 2025-04-14 23:11:31 +02:00
commit f6e157363c
6 changed files with 980 additions and 21 deletions

View file

@ -138,19 +138,14 @@ impl Parser for TeamParser {
_ => {}
};
let image =
document
.select(&self.selector_image)
.next()
.ok_or(ParseError::ElementNotFound {
selector: SELECTOR_TEAM_IMAGE,
role: "team image",
})?;
let image = image
.attr("data-cfsrc")
.or_else(|| image.attr("src"))
.unwrap_or_default()
.to_string();
let image = document.select(&self.selector_image).next();
let image = image.and_then(|image| {
image
.attr("data-cfsrc")
.or_else(|| image.attr("src"))
.filter(|image| !image.ends_with("team_avatar_placeholder.png"))
.map(String::from)
});
let format = select_text(root, &self.selector_team_format)
.ok_or(ParseError::ElementNotFound {