mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-09 17:54:22 +02:00
polybar-weather: also log first forecast time
This commit is contained in:
parent
7c39cfb940
commit
0129d85f70
1 changed files with 10 additions and 5 deletions
|
@ -158,16 +158,21 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# Grab current weather and forecast
|
# Grab current weather and forecast
|
||||||
current_weather = get_weather(options.owm_api_key, *location, "weather")
|
current_weather = get_weather(options.owm_api_key, *location, "weather")
|
||||||
forecast_weather = get_weather(
|
if options.forecasts:
|
||||||
options.owm_api_key, *location, "forecast", count=options.forecasts
|
forecast_weather = get_weather(
|
||||||
)
|
options.owm_api_key, *location, "forecast", count=options.forecasts
|
||||||
|
)["list"]
|
||||||
|
logger.info(f"first forecast: {forecast_weather[0]['dt_txt']} UTC")
|
||||||
|
else:
|
||||||
|
forecast_weather = []
|
||||||
description = current_weather["weather"][0]["description"]
|
description = current_weather["weather"][0]["description"]
|
||||||
city = current_weather["name"]
|
city = current_weather["name"]
|
||||||
logger.info(f"current weather at {city}: {description}")
|
logger.info(f"current weather at {city}: {description}")
|
||||||
|
|
||||||
# Format output
|
# Format output
|
||||||
conditions = [format_weather(data)
|
conditions = [
|
||||||
for data in [current_weather] + forecast_weather["list"]]
|
format_weather(data) for data in [current_weather] + forecast_weather
|
||||||
|
]
|
||||||
while len(conditions) >= 2:
|
while len(conditions) >= 2:
|
||||||
if conditions[-1] == conditions[-2]:
|
if conditions[-1] == conditions[-2]:
|
||||||
conditions.pop()
|
conditions.pop()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue