OwenStOnge commited on
Commit
6701d18
·
verified ·
1 Parent(s): 4962d99

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +15 -4
app.R CHANGED
@@ -2369,10 +2369,21 @@ removeModal()
2369
 
2370
  # Scrape button
2371
  observeEvent(input$scrape_btn, {
2372
- if (input$start_date > input$end_date) {
2373
- scrape_status_msg("Error: Start date must be before end date.")
2374
- return()
2375
- }
 
 
 
 
 
 
 
 
 
 
 
2376
 
2377
  n_days <- as.numeric(input$end_date - input$start_date) + 1
2378
  scrape_status_msg(paste0("Scraping ", n_days, " day(s)... please wait."))
 
2369
 
2370
  # Scrape button
2371
  observeEvent(input$scrape_btn, {
2372
+ scrape_status_msg("Testing FTP connection...")
2373
+
2374
+ result <- tryCatch({
2375
+ ftp_url <- paste0("ftp://", Sys.getenv("FTP_USERNAME"), ":",
2376
+ Sys.getenv("FTP_PASSWORD"),
2377
+ "@ftp.trackmanbaseball.com/v3/2025/04/01/CSV/")
2378
+ file_list <- RCurl::getURL(ftp_url, ftp.use.epsv = FALSE,
2379
+ dirlistonly = TRUE, connecttimeout = 10)
2380
+ paste("Connected! Files found:", nchar(file_list), "chars")
2381
+ }, error = function(e) {
2382
+ paste("FTP failed:", e$message)
2383
+ })
2384
+
2385
+ scrape_status_msg(result)
2386
+ })
2387
 
2388
  n_days <- as.numeric(input$end_date - input$start_date) + 1
2389
  scrape_status_msg(paste0("Scraping ", n_days, " day(s)... please wait."))