From a22a30b1b62cb2268a5d9ef23771ba3ad97369a5 Mon Sep 17 00:00:00 2001 From: Benjamin Howell Date: Sun, 25 Feb 2024 22:48:39 -0500 Subject: [PATCH 1/2] updating documentation and package build --- R/pwhl_pbp.R | 2 +- man/pwhl_pbp.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/pwhl_pbp.R b/R/pwhl_pbp.R index f626ade..793fe94 100644 --- a/R/pwhl_pbp.R +++ b/R/pwhl_pbp.R @@ -2,7 +2,7 @@ #' @description PWHL Play-by-play #' #' @param game_id Game ID that you want play-by-play for -#' @return A data frame with play-by-play data +#' @return A data frame with play-by-play data from the PWHL #' @import jsonlite #' @import dplyr #' @import httr diff --git a/man/pwhl_pbp.Rd b/man/pwhl_pbp.Rd index 938a236..ead2aef 100644 --- a/man/pwhl_pbp.Rd +++ b/man/pwhl_pbp.Rd @@ -10,7 +10,7 @@ pwhl_pbp(game_id) \item{game_id}{Game ID that you want play-by-play for} } \value{ -A data frame with play-by-play data +A data frame with play-by-play data from the PWHL } \description{ PWHL Play-by-play From f60b19867d65c22b6eacc0d508d39ea530f98138 Mon Sep 17 00:00:00 2001 From: Benjamin Howell Date: Sun, 25 Feb 2024 22:59:16 -0500 Subject: [PATCH 2/2] making pbp calls more flexible --- R/pwhl_pbp.R | 3 ++- R/pwhl_schedule.R | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/R/pwhl_pbp.R b/R/pwhl_pbp.R index 793fe94..019aa81 100644 --- a/R/pwhl_pbp.R +++ b/R/pwhl_pbp.R @@ -19,7 +19,8 @@ pwhl_pbp <- function(game_id) { res <- httr::RETRY("GET", URL) res <- res %>% httr::content(as = "text", encoding = "utf-8") - res <- gsub("angular.callbacks._8\\(", "", res) + callback_pattern <- "angular.callbacks._\\d+\\(" + res <- gsub(callback_pattern, "", res) res <- gsub("}}])", "}}]", res) r <- res %>% jsonlite::parse_json() diff --git a/R/pwhl_schedule.R b/R/pwhl_schedule.R index f1c8876..3f43b71 100644 --- a/R/pwhl_schedule.R +++ b/R/pwhl_schedule.R @@ -25,8 +25,10 @@ pwhl_schedule <- function(season) { res <- res %>% httr::content(as = "text", encoding = "utf-8") - - res <- gsub("angular.callbacks._1\\(", "", res) + callback_pattern <- "angular.callbacks._\\d+\\(" + res <- gsub(callback_pattern, "", res) + # res <- gsub("\\}\\]\\)$", "}}]", res) + # res <- gsub("angular.callbacks._1\\(", "", res) res <- gsub("}}]}]}])", "}}]}]}]", res) r <- res %>%