mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-15 23:27:48 +02:00
polybar-weather: discard first forecast if in less than two hours
This commit is contained in:
parent
6749e99d06
commit
8fd82af49f
1 changed files with 7 additions and 2 deletions
|
@ -160,9 +160,14 @@ if __name__ == "__main__":
|
||||||
current_weather = get_weather(options.owm_api_key, *location, "weather")
|
current_weather = get_weather(options.owm_api_key, *location, "weather")
|
||||||
if options.forecasts:
|
if options.forecasts:
|
||||||
forecast_weather = get_weather(
|
forecast_weather = get_weather(
|
||||||
options.owm_api_key, *location, "forecast", count=options.forecasts
|
options.owm_api_key, *location, "forecast", count=options.forecasts+1
|
||||||
)["list"]
|
)["list"]
|
||||||
logger.info(f"first forecast: {forecast_weather[0]['dt_txt']} UTC")
|
if forecast_weather[0]['dt'] - time.time() < 7200:
|
||||||
|
logger.debug("discard first forecast, too soon")
|
||||||
|
forecast_weather = forecast_weather[1:]
|
||||||
|
else:
|
||||||
|
forecast_weather.pop()
|
||||||
|
logger.info(f"next forecast: {forecast_weather[0]['dt_txt']} UTC")
|
||||||
else:
|
else:
|
||||||
forecast_weather = []
|
forecast_weather = []
|
||||||
description = current_weather["weather"][0]["description"]
|
description = current_weather["weather"][0]["description"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue