-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweather-gismeteo
More file actions
executable file
·60 lines (52 loc) · 1.53 KB
/
Copy pathweather-gismeteo
File metadata and controls
executable file
·60 lines (52 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
if [ ${GM_TOKEN-x} = x ]; then
echo "GM_TOKEN not specified!"
exit 1
fi
API="https://api.gismeteo.net/v2"
# -s "'$API/weather/current/1365/?lang=en'" \
# -s "'$API/weather/forecast/1365/?lang=en&days=5'" \
# -s "'$API/search/cities/?lang=en&query=brussels'" \
# -s "'$API/city/1365?lang=en'" \
#curl -H "'X-Gismeteo-Token: $GM_TOKEN'" \
# -vL "'$API/city/1365?lang=en'"
#exit
curl -H "'X-Gismeteo-Token: $GM_TOKEN'" \
-H "'Accept-Encoding: gzip'" \
-s "'$API/weather/forecast/1365/?lang=en&days=5'" \
| gunzip --force \
| jq -r \
'
def temp_with_padding:
.temperature.air.C | tonumber | round
| (if fabs < 10 then " " else "" end) as $pad
| tostring + "°"
| if startswith("-") then . else "+" + . end
| $pad + .;
def wind_with_padding:
(.wind.speed.m_s|tonumber|round) as $a
| @text "\($a) m/s"
| if $a < 10 then " " + . else . end;
def fmt:
{
time: .date.local|split(" ")[1]|rtrimstr(":00"),
temp: temp_with_padding,
wind: wind_with_padding,
rh: @text "RH \(.humidity.percent)%",
uv: "",
prec: .precipitation|(
if .amount and (.amount|tonumber > 0)
then @text " \(.amount) mm"
else "" end
),
desc: (" " + .description.full)
}
| @text "\(.time) \(.temp) \(.wind) \(.rh)\(.uv)\(.desc)\(.prec)";
.response
| group_by(.date.local|split(" ")[0])[]
| {(.[0].date.local|split(" ")[0]): [.[]|fmt]}
| to_entries[0]
| @text "\n\(.key)\n\n\(.value|join("\n"))"
' \
| less
#> sample.json