diff options
author | Mattias Andrée <maandree@kth.se> | 2016-08-03 22:54:07 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-08-03 22:54:07 +0200 |
commit | 5339ae417c20382f9ac9156d820e1d4e3cd85f46 (patch) | |
tree | ab94abbd8b7cccb98b50a9b40b312c9ba146b430 | |
parent | m (diff) | |
download | metar-5339ae417c20382f9ac9156d820e1d4e3cd85f46.tar.gz metar-5339ae417c20382f9ac9156d820e1d4e3cd85f46.tar.bz2 metar-5339ae417c20382f9ac9156d820e1d4e3cd85f46.tar.xz |
Update: the metar resources have moved1.2.2
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rwxr-xr-x | metar | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -2,6 +2,17 @@ set -e + +metar_url () +{ + url="http://tgftp.nws.noaa.gov/data/observations/metar/decoded" + if test $# = 1; then + echo "${url}/${1}.TXT" + else + echo "${url}/" + fi +} + usage () { echo "usage: $0 (get | print | set STATION | list [PREFIX] | closest [LATITUDE LONGITUDE] [LIST])" @@ -49,14 +60,14 @@ list_stations () if test -z "$file"; then exit 1 fi - if ! curl -s "http://weather.noaa.gov/pub/data/observations/metar/decoded/" > "$file"; then + if ! curl -s "$(metar_url)" > "$file"; then unlink "$file" exit 1 fi list="$(sed -n 's/^.*<a href="\('"$1"'[A-Za-z0-9]*\)\.TXT">.*$/\1/p' "$file")" unlink "$file" for icao in $list; do - curl -s "http://weather.noaa.gov/pub/data/observations/metar/decoded/${icao}.TXT" | head -n 1 + curl -s "$(metar_url "${icao}")" | head -n 1 done } @@ -101,7 +112,7 @@ EOF } if test $# = 1 && test "$1" = "get"; then - curl -s "http://weather.noaa.gov/pub/data/observations/metar/decoded/$(get_station).TXT" || exit 1 + curl -s "$(metar_url "$(get_station)")" || exit 1 elif test $# = 1 && test "$1" = "print"; then get_station elif test $# = 2 && test "$1" = "set"; then |