Spaces:
Sleeping
Sleeping
Update app.R
Browse files
app.R
CHANGED
|
@@ -458,23 +458,13 @@ server <- function(input, output, session) {
|
|
| 458 |
# } else {
|
| 459 |
# y <- paste("https://midfield.mlbstatic.com/v1/people/","/milb/300?circle=false",sep = id)
|
| 460 |
# }
|
| 461 |
-
tryCatch({
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
# If MLB URL fails, try MiLB URL
|
| 469 |
-
tryCatch({
|
| 470 |
-
y <- paste0("https://midfield.mlbstatic.com/v1/people/", id, "/milb/300?circle=false")
|
| 471 |
-
# Attempt to use the MiLB URL
|
| 472 |
-
# For example: response <- httr::GET(y)
|
| 473 |
-
}, error = function(e) {
|
| 474 |
-
# If both fail, you can handle it here
|
| 475 |
-
stop("Both MLB and MiLB URLs failed")
|
| 476 |
-
})
|
| 477 |
-
})
|
| 478 |
photo <- tempfile()
|
| 479 |
download.file(y, photo, mode = 'wb')
|
| 480 |
img <- readPNG(photo)
|
|
|
|
| 458 |
# } else {
|
| 459 |
# y <- paste("https://midfield.mlbstatic.com/v1/people/","/milb/300?circle=false",sep = id)
|
| 460 |
# }
|
| 461 |
+
y <- tryCatch({
|
| 462 |
+
# Try MLB URL first
|
| 463 |
+
paste0("https://midfield.mlbstatic.com/v1/people/", id, "/mlb/300?circle=false")
|
| 464 |
+
}, error = function(e) {
|
| 465 |
+
# If MLB URL fails, return MiLB URL instead
|
| 466 |
+
paste0("https://midfield.mlbstatic.com/v1/people/", id, "/milb/300?circle=false")
|
| 467 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
photo <- tempfile()
|
| 469 |
download.file(y, photo, mode = 'wb')
|
| 470 |
img <- readPNG(photo)
|