From dc6fac9033c9d4e7b9f4e2d258c948de94ebcc08 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 26 Jun 2024 13:47:58 -0700 Subject: [PATCH] Update locationdata.py --- locationdata.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/locationdata.py b/locationdata.py index 3c8d904..e732734 100644 --- a/locationdata.py +++ b/locationdata.py @@ -84,13 +84,10 @@ def get_weather(lat=0, lon=0, unit=0): if float(lat) == 0 and float(lon) == 0: return NO_DATA_NOGPS - if unit == 0: - # default to imperial units - weather_url = "https://forecast.weather.gov/MapClick.php?FcstType=text&lat=" + str(lat) + "&lon=" + str(lon) - else: - # metric units - weather_url = "https://forecast.weather.gov/MapClick.php?FcstType=text&unit=1&lat=" + str(lat) + "&lon=" + str(lon) - + weather_url = "https://forecast.weather.gov/MapClick.php?FcstType=text&lat=" + str(lat) + "&lon=" + str(lon) + if unit == 1: + weather_url += "&unit=0" + try: weather_data = requests.get(weather_url, timeout=URL_TIMEOUT) if not weather_data.ok: