mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 18:24:10 +02:00
handle team matches without match links
This commit is contained in:
parent
766d0333cd
commit
cc3ea78778
6 changed files with 6052 additions and 2743 deletions
|
|
@ -179,8 +179,8 @@ impl Parser for TeamMatchesParser {
|
||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
let result = match (opponent, points, points_opponent) {
|
let result = match (opponent, points, points_opponent, id) {
|
||||||
(Some(opponent), Some(point), Some(points_opponent)) => {
|
(Some(opponent), Some(point), Some(points_opponent), Some(_)) => {
|
||||||
MatchResult::Played {
|
MatchResult::Played {
|
||||||
id: id.ok_or(ParseError::ElementNotFound {
|
id: id.ok_or(ParseError::ElementNotFound {
|
||||||
selector: SELECTOR_SEASON_MATCH_PAGE,
|
selector: SELECTOR_SEASON_MATCH_PAGE,
|
||||||
|
|
@ -193,7 +193,7 @@ impl Parser for TeamMatchesParser {
|
||||||
match_points_opponent: points_opponent,
|
match_points_opponent: points_opponent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Some(opponent), None, None) => MatchResult::Pending {
|
(Some(opponent), None, None, Some(_)) => MatchResult::Pending {
|
||||||
id: id.ok_or(ParseError::ElementNotFound {
|
id: id.ok_or(ParseError::ElementNotFound {
|
||||||
selector: SELECTOR_SEASON_MATCH_PAGE,
|
selector: SELECTOR_SEASON_MATCH_PAGE,
|
||||||
role: "match page link",
|
role: "match page link",
|
||||||
|
|
@ -202,6 +202,7 @@ impl Parser for TeamMatchesParser {
|
||||||
score,
|
score,
|
||||||
score_opponent,
|
score_opponent,
|
||||||
},
|
},
|
||||||
|
(Some(opponent), _, _, None) => MatchResult::Unknown { opponent },
|
||||||
_ => MatchResult::ByeWeek,
|
_ => MatchResult::ByeWeek,
|
||||||
};
|
};
|
||||||
Ok(TeamSeasonMatch {
|
Ok(TeamSeasonMatch {
|
||||||
|
|
|
||||||
3379
tests/data/team_matches_2157.html
Normal file
3379
tests/data/team_matches_2157.html
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -61,6 +61,7 @@ fn test_parse_team_roster_history_html(input: &str, name: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test_case("team_matches_7861.html", "team_matches")]
|
#[test_case("team_matches_7861.html", "team_matches")]
|
||||||
|
#[test_case("team_matches_2157.html", "team_matches_old")]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn test_parse_team_matches_html(input: &str, name: &str) {
|
fn test_parse_team_matches_html(input: &str, name: &str) {
|
||||||
let body = read_to_string(format!("tests/data/{input}")).unwrap();
|
let body = read_to_string(format!("tests/data/{input}")).unwrap();
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
147
tests/snapshots/snapshot__parse_team_matches_old_html.snap
Normal file
147
tests/snapshots/snapshot__parse_team_matches_old_html.snap
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
---
|
||||||
|
source: tests/snapshot.rs
|
||||||
|
expression: parsed
|
||||||
|
---
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"season": 1,
|
||||||
|
"matches": [
|
||||||
|
{
|
||||||
|
"division": "Steel",
|
||||||
|
"week": 1,
|
||||||
|
"date": "Sun Oct 28",
|
||||||
|
"side": "visiting",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[$0.00]",
|
||||||
|
"id": 2137
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_gravelpit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 2,
|
||||||
|
"date": "Sun Nov 04",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "-DeX-",
|
||||||
|
"id": 2130
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_gravelpit"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 3,
|
||||||
|
"date": "Sun Nov 11",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[UGS]",
|
||||||
|
"id": 2127
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_dustbowl"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 4,
|
||||||
|
"date": "Sun Nov 18",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "bye_week"
|
||||||
|
},
|
||||||
|
"map": "cp_dustbowl"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 6,
|
||||||
|
"date": "Mon Dec 10",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": ".tKd",
|
||||||
|
"id": 2169
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "ctf_impact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 7,
|
||||||
|
"date": "Mon Dec 17",
|
||||||
|
"side": "visiting",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[FOoM]",
|
||||||
|
"id": 2172
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_science2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 11,
|
||||||
|
"date": "Mon Jan 14",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[SWAT]",
|
||||||
|
"id": 2188
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_junction"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 12,
|
||||||
|
"date": "Mon Jan 21",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[FOoM]",
|
||||||
|
"id": 2172
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_castle3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 13,
|
||||||
|
"date": "Mon Jan 28",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[=1=]",
|
||||||
|
"id": 2197
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_dustbowl"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"division": "Platinum",
|
||||||
|
"week": 14,
|
||||||
|
"date": "Mon Feb 04",
|
||||||
|
"side": "home",
|
||||||
|
"result": {
|
||||||
|
"state": "unknown",
|
||||||
|
"opponent": {
|
||||||
|
"name": "[FOoM]",
|
||||||
|
"id": 2172
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"map": "cp_science"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -298,6 +298,9 @@ pub enum MatchResult {
|
||||||
score_opponent: u8,
|
score_opponent: u8,
|
||||||
},
|
},
|
||||||
ByeWeek,
|
ByeWeek,
|
||||||
|
Unknown {
|
||||||
|
opponent: TeamRef,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MatchResult {
|
impl MatchResult {
|
||||||
|
|
@ -305,7 +308,7 @@ impl MatchResult {
|
||||||
match self {
|
match self {
|
||||||
MatchResult::Played { id, .. } => Some(*id),
|
MatchResult::Played { id, .. } => Some(*id),
|
||||||
MatchResult::Pending { id, .. } => Some(*id),
|
MatchResult::Pending { id, .. } => Some(*id),
|
||||||
MatchResult::ByeWeek => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue