forked from jeremysolarz/windguru-date-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
executable file
·72 lines (57 loc) · 1.55 KB
/
cli
File metadata and controls
executable file
·72 lines (57 loc) · 1.55 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
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
## please set spots & spot_ids here manually
## e.g.:
# spots=("El_Gouna")
# spot_ids=(25164)
spots=("DK_Kloster")
spot_ids=(500768)
idu_from_arg=${1:-1505322}
month_day_from="05-01"
month_day_to="05-30"
function weather() {
idu=$1
spot=$2
spot_id=$3
year=$4
date_from="$year-$month_day_from"
date_to="$year-$month_day_to"
data="date_from=$date_from&date_to=$date_to&id_spot=$spot_id&step=3&pwindspd=1&psmer=1&ptmp=1&id_model=3&id_stats_type=1"
mkdir -p $spot
echo "Spot: $spot and $year >>"
curl -s 'https://www.windguru.cz/ajax/ajax_archive.php' \
-H "Cookie: idu=${idu}" \
--data $data > "${spot}/${spot}_$year".html
sed -i -e "1s/^/\<b\>$year\<\/b\>\<br\>/" ${spot}/${spot}_${year}.html
wkhtmltoimage ${spot}/${spot}_${year}.html ${spot}/${spot}_${year}.jpg
convert ${spot}/${spot}_${year}.jpg -gravity East -chop 250x0 ${spot}/${spot}_${year}.jpg
}
if [[ -z "$idu_from_arg" ]] ; then
echo "Please provide an idu token!"
exit 1
fi
if [[ -z "$spots" || -z "$spot_ids" ]] ; then
echo "Please set both spots & spot_ids in the file manually!"
exit 1
fi
# cleanup
for spot in "${spots[@]}"
do
rm -rf $spot
done
for year in 2020 2019 2018 2017 2016 2015 2014
# for year in 2019
do
echo "Creating for year: $year"
i=0
for spot in "${spots[@]}"
do
weather $idu_from_arg $spot ${spot_ids[$i]} $year
i=$i+1
done
done
# delete html + html-e files
for spot in "${spots[@]}"
do
rm ${spot}/*.html ${spot}/*.html-e 2>/dev/null
done
# convert -append El_Gouna/*.jpg El_Gouna/El_Gouna_overview.jpg