about summary refs log tree commit diff
diff options
context:
space:
mode:
-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()