about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-12-01 11:53:10 -0600
committerStarfall <us@starfall.systems>2022-12-01 11:53:10 -0600
commitd528ba125fae31e3caa76471136fa0a821867884 (patch)
tree94b34fe29597558fe7de8d75e82c1970764e5a21
parentd39f6c9ec558fe2d6d5761e88a13ef9dd4152054 (diff)
shorten results for forecast after today/tonite
-rwxr-xr-xmeteor.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/meteor.py b/meteor.py
index a63d304..f19a834 100755
--- a/meteor.py
+++ b/meteor.py
@@ -24,7 +24,7 @@ def handle_args():
 
 def print_alerts(county, zone): 
     # in some areas, alerts are not published for the zone but only for the county
-    # you can request both like this rather than making two requests
+    # you can request both like this rather than making two requestsfork
     alerts = requests.get(base_url + f'/alerts/active?zone={county},{zone}',
                           headers=headers).json()
 
@@ -69,11 +69,16 @@ def print_forecast(forecast_url):
 
     print(f'{term.BOLD}forecast')
     print(f'===================={term.RESET}')
-    for period in forecast.get('periods'):
-        # TODO parse isDaytime true/false to squish a day together
+    periods = forecast.get('periods')
+    # print today and tonight in long format
+    for period in periods[:2]:
         print(f'{term.BOLD}{period.get("name")}{term.RESET}:')
         print(f'  {period.get("temperature")}°{period.get("temperatureUnit")}, wind {period.get("windSpeed")} {period.get("windDirection")}')
         print(f'  {period.get("detailedForecast")}')
+    # print further forecasted periods in short format
+    for period in periods[2:]:
+        # TODO parse isDaytime true/false to squish a day together
+        print(f'{term.BOLD}{period.get("name").ljust(15)}{term.RESET}: {period.get("shortForecast")} - {period.get("temperature")}°{period.get("temperatureUnit")}, {period.get("windSpeed")} {period.get("windDirection")}')
 
 def main():
     args = handle_args()