From fd0953bfb5fc0ecfc02576e61014a1e189db7dac Mon Sep 17 00:00:00 2001 From: Mitch Ross Date: Sat, 7 Feb 2026 17:56:45 -0500 Subject: [PATCH] up --- routes/satellite.py | 14 ++++++++++++++ utils/weather_sat_predict.py | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/routes/satellite.py b/routes/satellite.py index 8fb9054..8a4e3c8 100644 --- a/routes/satellite.py +++ b/routes/satellite.py @@ -30,6 +30,20 @@ ALLOWED_TLE_HOSTS = ['celestrak.org', 'celestrak.com', 'www.celestrak.org', 'www # Local TLE cache (can be updated via API) _tle_cache = dict(TLE_SATELLITES) +# Auto-refresh TLEs from CelesTrak on startup (non-blocking) +import threading + +def _auto_refresh_tle(): + try: + updated = refresh_tle_data() + if updated: + logger.info(f"Auto-refreshed TLE data for: {', '.join(updated)}") + except Exception as e: + logger.warning(f"Auto TLE refresh failed: {e}") + +# Delay import — refresh_tle_data is defined later in this module +threading.Timer(2.0, _auto_refresh_tle).start() + def _fetch_iss_realtime(observer_lat: Optional[float] = None, observer_lon: Optional[float] = None) -> Optional[dict]: """ diff --git a/utils/weather_sat_predict.py b/utils/weather_sat_predict.py index b5d6f2d..8d6432f 100644 --- a/utils/weather_sat_predict.py +++ b/utils/weather_sat_predict.py @@ -42,6 +42,15 @@ def predict_passes( from skyfield.almanac import find_discrete from data.satellites import TLE_SATELLITES + # Use live TLE cache from satellite module if available (refreshed from CelesTrak) + tle_source = TLE_SATELLITES + try: + from routes.satellite import _tle_cache + if _tle_cache: + tle_source = _tle_cache + except ImportError: + pass + ts = load.timescale() observer = wgs84.latlon(lat, lon) t0 = ts.now() @@ -53,7 +62,7 @@ def predict_passes( if not sat_info['active']: continue - tle_data = TLE_SATELLITES.get(sat_info['tle_key']) + tle_data = tle_source.get(sat_info['tle_key']) if not tle_data: continue