diff --git a/NEWS.md b/NEWS.md index 672e556..e57fd35 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # getRad (development version) * Clarify HTTP 429 error for the Netherlands (#165). +* For Romania match deviating file format (thanks to Sorin Burcea, #167). # getRad 0.2.4 diff --git a/R/get_pvol_ro.R b/R/get_pvol_ro.R index bc52ff8..6a7d0e6 100644 --- a/R/get_pvol_ro.R +++ b/R/get_pvol_ro.R @@ -3,5 +3,19 @@ get_pvol_ro <- function(radar, time, ..., call = rlang::caller_env()) { urls <- glue::glue( "https://opendata.meteoromania.ro/radar/{toupper(substr(radar,3,5))}/{toupper(substr(radar,3,5))}_{strftime(time,'%Y%m%d%H%M', tz='UTC')}0200{params}.hdf" ) - read_pvol_from_url_per_param(urls, param = "all", call = call) + tryCatch( + read_pvol_from_url_per_param(urls, param = "all", call = call), + error = function(cnd) { + urls_updated <- glue::glue( + "https://opendata.meteoromania.ro/radar/{toupper(substr(radar,3,5))}/{toupper(substr(radar,3,5))}_{strftime(time,'%Y%m%d%H%M', tz='UTC')}0300{params}.hdf" + ) + if ( + rlang::has_name(cnd, "parent") && inherits(cnd$parent, "httr2_http_404") + ) { + read_pvol_from_url_per_param(urls_updated, param = "all", call = call) + } else { + return(cnd) + } + } + ) }