This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_data
executable file
·70 lines (62 loc) · 2.6 KB
/
get_data
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
#!/bin/bash
# fetch metaskirando data
# Copyright (C) Nathanael Schaeffer
# Copyright (C) Camptocamp Association
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
curl='curl --max-time 300 --silent'
ua='metaskirando bot'
odir="/var/www/metaskirando.camptocamp.org/private/data"
t=180
mfadrs="http://www.meteofrance.com/mf3-rpc-portlet/rest/relevemontagne/releve/"
mfadresai="/type/imgnivosesai"
mfadre7j="/type/imgnivose7j"
nivadrs="http:\/\/www.meteofrance.com\/integration\/sim-portail"
download () {
TMP=$(mktemp)
sleep $((RANDOM % $t))
if test -z "$3"; then
$curl -H "User-Agent: $ua" $2 > $TMP
else
$curl -H "User-Agent: $ua" -H "Host: $3" $2 > $TMP
fi
CHARSET="$(file -bi $TMP|awk -F "=" '{print $2}')"
if [ "$CHARSET" != utf-8 ]; then
echo "change encoding from $CHARSET to utf-8"
iconv -f "$CHARSET" -t utf8 $TMP -o $odir/"$1".web && rm $TMP
else
mv $TMP $odir/"$1".web
fi
if [ $? == 0 ]; then
echo "fetched $2"
else
echo "failed fetching $2"
rm -f $TMP
fi
}
download skitour "http://www.skitour.fr/topos/dernieres-sorties.php?nbr=100" &
download volo "http://www.volopress.net/volo/spip.php?rubrique2" &
download c2c "https://api.camptocamp.org/outings?act=skitouring&pl=fr" &
download SNGM "http://www.montagneinfo.net/flux/activites.php?NoIDActivite=11" &
download gulliver.sr "http://www.gulliver.it/sci-ripido/" &
download gulliver.sa "http://www.gulliver.it/scialpinismo/" &
download bivouak "http://www.bivouak.net/accueil/index.php?id_sport=1" &
TMP=$(mktemp)
for i in BONNE PORTE ECRIN AIGRG BELLE GRPAR ROCHI MEIJE AIGLE CHEVR ALLAN STHIL LEGUA PARPA MILLE RESTE AGNEL ORCIE MANIC SPOND CANIG PAULA MAUPA PUIGN HOSPI LARDI MAUPA SOUMC AIGTE; do
$curl "${mfadrs}ZONE_${i}${mfadresai}" | sed "s/^\"/ZONE_${i}_SAI:\"${nivadrs}/" >> $TMP
echo "" >> $TMP
$curl "${mfadrs}ZONE_${i}${mfadre7j}" | sed "s/^\"/ZONE_${i}:\"${nivadrs}/" >> $TMP
echo "" >> $TMP
done
mv $TMP "$odir/nivo_links.web"