From 5339ae417c20382f9ac9156d820e1d4e3cd85f46 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 3 Aug 2016 22:54:07 +0200 Subject: Update: the metar resources have moved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- metar | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/metar b/metar index 9555025..5d66e7b 100755 --- a/metar +++ b/metar @@ -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/^.*.*$/\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 -- cgit v1.2.3-70-g09d2