From d528ba125fae31e3caa76471136fa0a821867884 Mon Sep 17 00:00:00 2001 From: Starfall Date: Thu, 1 Dec 2022 11:53:10 -0600 Subject: shorten results for forecast after today/tonite --- meteor.py | 11 ++++++++--- 1 file 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() -- cgit