TimStats commited on
Commit
6dc8bb1
·
verified ·
1 Parent(s): 37cc215

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +7 -17
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
- # Try MLB URL first
463
- y <- paste0("https://midfield.mlbstatic.com/v1/people/", id, "/mlb/300?circle=false")
464
- # Attempt to use the URL (replace this with your actual usage code)
465
- # For example: response <- httr::GET(y)
466
- # If it succeeds, it will use this URL
467
- }, error = function(e) {
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)