diff --git a/main.py b/main.py index 80d4992..af05a17 100755 --- a/main.py +++ b/main.py @@ -64,12 +64,21 @@ def display_full(data): wind_speed = infos["data"]["instant"]["details"]["wind_speed"] - wind_direction = display_wind_direction( + wind_dir = display_wind_direction( infos["data"]["instant"]["details"]["wind_from_direction"] ) - cur_humidity = infos["data"]["instant"]["details"]["relative_humidity"] - print(f" {time} : {temperature}° / {cur_humidity}% / {wind_direction} {wind_speed} m/s") + icon_str = '' + if "next_12_hours" in infos["data"]: + icon_str = infos["data"]["next_12_hours"]["summary"]["symbol_code"] + if "next_6_hours" in infos["data"]: + icon_str = infos["data"]["next_6_hours"]["summary"]["symbol_code"] + if "next_1_hours" in infos["data"]: + icon_str = infos["data"]["next_1_hours"]["summary"]["symbol_code"] + icon = display_icon(icon_str) + + humidity = infos["data"]["instant"]["details"]["relative_humidity"] + print(f" {time} : {icon} {temperature}° / {humidity}% / {wind_dir} {wind_speed} m/s") def display_wind_direction(degrees: float) -> str: @@ -98,6 +107,30 @@ def display_wind_direction(degrees: float) -> str: return '↓' +def display_icon(string: str) -> str: + """ """ + # https://www.nerdfonts.com/cheat-sheet + t = { + 'clearsky_day': fg.yellow + '' + fg.rs, + 'clearsky_night': '', + 'cloudy': '', + 'fog': '󰖑', + 'lightrain': '', + 'heavyrain': '', + 'partlycloudy_night': '', + 'partlycloudy_day': '', + 'rain': '', + 'lightrainshowers_night': '', + 'lightrainshowers_day':'', + 'fair_day': fg.yellow + '' + fg.rs, + 'fair_night': '', + } + + if string in t: + return t[string] + + return string + def coloring_temperature(temperature: float) -> str: """ A partir de la température retourne une chaine de caractères colorisée """