diff options
Diffstat (limited to 'meteor.py')
-rwxr-xr-x | meteor.py | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/meteor.py b/meteor.py index 4e41a64..8b7ab2c 100755 --- a/meteor.py +++ b/meteor.py @@ -3,9 +3,6 @@ from argparse import ArgumentParser import requests import fscache as fs -# doco is at https://www.weather.gov/documentation/services-web-api -# openAPI spec is at https://api.weather.gov/openapi.json - base_url = 'https://api.weather.gov' headers = { 'user-agent': 'meteor.py/0.2 (us@starfall.systems)', @@ -29,9 +26,6 @@ def print_alerts(county, zone): alerts = requests.get(base_url + f'/alerts/active?zone={county},{zone}', headers=headers).json() - # this title was cooler when we requested only one zone - # e.g. it would end with "for Holmes County (MSC051) MS" - # but now it's just "current watches, warnings, and advisories" print(f'{term.BOLD}{alerts.get("title")}') print(f'===================={term.RESET}') for alert in alerts.get('@graph'): @@ -39,9 +33,6 @@ def print_alerts(county, zone): print(f' {alert.get("severity")} - {alert.get("certainty")} - {alert.get("urgency")}') print(f' Until: {alert.get("expires")}') print(f'{alert.get("description")}') - # TODO description can be quite long - # short desc appears to be available as parameters.NWSheadline[0] - # and follow up with instruction when it exists print('--------------------') # many more cool fields available. @@ -55,8 +46,6 @@ def print_alerts(county, zone): print() def print_forecast(point): - # TODO pick up gridId AFC (AER/ALU), AFG, AJK, BOX< CAE, DLH, FSD, HGX, HNX, LIX, LWX, MAF, MFR, MLB, MRX, MTR, PIH and reduce gridX and gridY by 1 - known issue - cache_key = f'{point.get("gridId")}-{point.get("gridX")},{point.get("gridY")}' try: @@ -64,14 +53,6 @@ def print_forecast(point): except fs.CacheMiss: forecast_url = point.get('forecast') forecast = requests.get(forecast_url, headers=headers).json() - # TODO retry on 500 - known issue - # TODO query param units=si - - # TODO replace the whole thing with /gridpoints/{point.gridId}/{gridX},{gridY} and create our own forecast - # there is lots more information there that would be useful - # probabilityOfPrecipitation is the neatest one that's not in .../forecast or .../forecast/hourly - # but there's also relativeHumidity, apparentTemperature (and, separately, windChill), skyCover, windGust - # downside, it appears to always convert the F/mph measurements into C/kph for no reason. e.g. all temps are measured in 9ths of C buffer = f'{term.BOLD}forecast for {point.get("relativeLocation").get("city")}, {point.get("relativeLocation").get("state")} ({cache_key})' buffer += '\n' + f'===================={term.RESET}' @@ -83,7 +64,6 @@ def print_forecast(point): buffer += '\n' + 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 buffer += '\n' + 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")}' cache.write(cache_key, buffer) |