jimmyday12 / fitzRoy

A set of functions to easily access AFL data
https://jimmyday12.github.io/fitzRoy
Other
125 stars 27 forks source link

fetch_player_details not returning any data #218

Closed jaytaytay closed 3 weeks ago

jaytaytay commented 1 month ago

I am unable to fetch any data using the fetch_player_details function.

As per the docs, I am expecting a tibble of player data to be returned.

I am using FitzRoy v1.3.0


player_details <- fetch_player_details(team = "Hawthorn", current = TRUE, comp="AFLM", source = "AFL")
→ Returning player details for current season (`2024`) from source `AFL`
Error in `map()`: details for Hawthorn, 2024
ℹ In index: 1.
Caused by error in `pmap()`:
ℹ In index: 1.
Caused by error in `parse_resp_afl()`:
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
In min(ids, na.rm = TRUE) : no non-missing arguments to min; returning Inf
✖ Fetching player details for Hawthorn, 2024 ... failed

Trying again without source (expecting the same result, as source should default to "AFL")

> player_details <- fetch_player_details(team = "Hawthorn", current = TRUE, comp="AFLM")
→ Returning player details for current season (`2024`) from source `AFL`
Error in `map()`: details for Hawthorn, 2024
ℹ In index: 1.
Caused by error in `pmap()`:
ℹ In index: 1.
Caused by error in `parse_resp_afl()`:
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
In min(ids, na.rm = TRUE) : no non-missing arguments to min; returning Inf
✖ Fetching player details for Hawthorn, 2024 ... failed

Trying again without source and comp (expecting the same result, as comp should default to "AFLM")

> player_details <- fetch_player_details(team = "Hawthorn", current = TRUE)
→ Returning player details for current season (`2024`) from source `AFL`
Error in `map()`: details for Hawthorn, 2024
ℹ In index: 1.
Caused by error in `pmap()`:
ℹ In index: 1.
Caused by error in `parse_resp_afl()`:
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
In min(ids, na.rm = TRUE) : no non-missing arguments to min; returning Inf
✖ Fetching player details for Hawthorn, 2024 ... failed

Trying again with current=FALSE

> player_details <- fetch_player_details(team = "Hawthorn", current = FALSE)
→ Returning player details from AFL website for seasons 2012 to 2024
Error in `map()`: details for Hawthorn, 2015
ℹ In index: 4.
Caused by error in `pmap()`:
ℹ In index: 1.
Caused by error in `parse_resp_afl()`:
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: Could not find a matching ID to the AFLM for 2012 
2: No player details data found for season 2012 on AFL.com.au for AFLM 
3: Could not find a matching ID to the AFLM for 2013 
4: No player details data found for season 2013 on AFL.com.au for AFLM 
5: Could not find a matching ID to the AFLM for 2014 
6: No player details data found for season 2014 on AFL.com.au for AFLM 
7: In min(ids, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
✖ Fetching player details for Hawthorn, 2015 ... failed

Trying again using "Richmond' as the team.

> player_details <- fetch_player_details(team = "Richmond", current = FALSE)
→ Returning player details from AFL website for seasons 2012 to 2024
Error in `map()`: details for Richmond, 2015
ℹ In index: 4.
Caused by error in `pmap()`:
ℹ In index: 1.
Caused by error in `parse_resp_afl()`:
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: Could not find a matching ID to the AFLM for 2012 
2: No player details data found for season 2012 on AFL.com.au for AFLM 
3: Could not find a matching ID to the AFLM for 2013 
4: No player details data found for season 2013 on AFL.com.au for AFLM 
5: Could not find a matching ID to the AFLM for 2014 
6: No player details data found for season 2014 on AFL.com.au for AFLM 
7: In min(ids, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
✖ Fetching player details for Richmond, 2015 ... failed

> rlang::last_trace()
<error/purrr_error_indexed>
Error in `map()`:
ℹ In index: 4.
Caused by error in `pmap()`:
ℹ In index: 1.
---
Backtrace:
     ▆
  1. ├─fitzRoy::fetch_player_details(team = "Richmond", current = FALSE)
  2. │ └─purrr::map_dfr(...)
  3. │   └─purrr::map(.x, .f, ...)
  4. │     └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
  5. │       ├─purrr:::with_indexed_errors(...)
  6. │       │ └─base::withCallingHandlers(...)
  7. │       ├─purrr:::call_with_cleanup(...)
  8. │       └─fitzRoy (local) .f(.x[[i]], ...)
  9. │         └─fitzRoy::fetch_player_details_afl(season = .x, team = team, comp = comp)
 10. │           └─purrr::pmap_dfr(args, fetch_squad_afl, season = season)
 11. │             └─purrr::pmap(.l, .f, ...)
 12. │               └─purrr:::pmap_("list", .l, .f, ..., .progress = .progress)
 13. │                 ├─purrr:::with_indexed_errors(...)
 14. │                 │ └─base::withCallingHandlers(...)
 15. │                 ├─purrr:::call_with_cleanup(...)
 16. │                 └─fitzRoy (local) .f(...)
 17. │                   └─fitzRoy:::parse_resp_afl(resp)
 18. │                     └─rlang::abort(...)
 19. │                       └─rlang:::signal_abort(cnd, .file)
 20. │                         └─base::signalCondition(cnd)
 21. └─purrr (local) `<fn>`(`<rlng_rrr>`)
 22.   └─cli::cli_abort(...)
Caused by error in `parse_resp_afl()`:
---
Backtrace:
     ▆
  1. └─fitzRoy::fetch_player_details(team = "Richmond", current = FALSE)
  2.   └─purrr::map_dfr(...)
  3.     └─purrr::map(.x, .f, ...)
  4.       └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
  5.         ├─purrr:::with_indexed_errors(...)
  6.         │ └─base::withCallingHandlers(...)
  7.         ├─purrr:::call_with_cleanup(...)
  8.         └─fitzRoy (local) .f(.x[[i]], ...)
  9.           └─fitzRoy::fetch_player_details_afl(season = .x, team = team, comp = comp)
 10.             └─purrr::pmap_dfr(args, fetch_squad_afl, season = season)
 11.               └─purrr::pmap(.l, .f, ...)
 12.                 └─purrr:::pmap_("list", .l, .f, ..., .progress = .progress)
 13.                   ├─purrr:::with_indexed_errors(...)
 14.                   │ └─base::withCallingHandlers(...)
 15.                   ├─purrr:::call_with_cleanup(...)
 16.                   └─fitzRoy (local) .f(...)
 17.                     └─fitzRoy:::parse_resp_afl(resp)
Run rlang::last_trace(drop = FALSE) to see 6 hidden frames.

Trying again with team = NULL (expecting this to provide all teams)

> player_details <- fetch_player_details(team = NULL, current = FALSE)
→ Returning player details from AFL website for seasons 2012 to 2024
Warning messages:
1: Could not find a matching ID to the AFLM for 2012 
2: No player details data found for season 2012 on AFL.com.au for AFLM 
3: Could not find a matching ID to the AFLM for 2013 
4: No player details data found for season 2013 on AFL.com.au for AFLM 
5: Could not find a matching ID to the AFLM for 2014 
6: No player details data found for season 2014 on AFL.com.au for AFLM 

I was wondering if my team string was invalid, so tried the following

> team_abr_afl("Richmond")
[1] "RICH"
> player_details <- fetch_player_details(team = "RICH", current = FALSE)
→ Returning player details from AFL website for seasons 2012 to 2024
Error in `map()`:
ℹ In index: 4.
Caused by error in `team_check_afl()`:
! RICH is not a valid input for afl teams.
Should be one of Adelaide, Brisbane Lions, Carlton, Collingwood, Essendon, Fremantle, GWS, Geelong, Gold Coast, Hawthorn, Melbourne, North Melbourne, Port Adelaide, Richmond, St Kilda, Sydney, West Coast, Western Bulldogs 
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: Could not find a matching ID to the AFLM for 2012 
2: No player details data found for season 2012 on AFL.com.au for AFLM 
3: Could not find a matching ID to the AFLM for 2013 
4: No player details data found for season 2013 on AFL.com.au for AFLM 
5: Could not find a matching ID to the AFLM for 2014 
6: No player details data found for season 2014 on AFL.com.au for AFLM 
jimmyday12 commented 1 month ago

I have a feeling that this is fixed in the dev version. Can you install from github using devtools::install_github("jimmyday12/fitzRoy") and retry?

jaytaytay commented 3 weeks ago

Thanks for the prompt response @jimmyday12. I am not experienced with devtools, so before I try that, I noticed that v1.4.0 is close to release, so I'll try again with that version when released.

jaytaytay commented 1 week ago

This issue has been resolved in fitzRoy v1.4.0. ty