gismeteo.sh

Bash client for Gismeteo weather forecast service
[raw]

01: #!/bin/bash
02: # @desc Bash client for Gismeteo weather forecast service
03: URL_CACHE="$HOME/.cache/gismeteo"
04: if [ "$#" -eq 0 ] && [ -r "$URL_CACHE" ]
05: then
06:     xargs curl -Ls < "$URL_CACHE" |xml sel -t -m '/document/GetHHForecastResult' -v '@cityName' -o ', ' -v '@country_name' -n -t -m '//HHForecast|//HHWeather' -v 'time' -o '      ' -v 't' -o '°C ' -v 'fullDesc' -n
07:     exit;
08: fi
09: ENDPOINT="http://c31b3236.services.gismeteo.ru/inform-service"
10: HASH=$(curl -sL "$ENDPOINT/register/?id=13371" |xml sel -t -v '/document/data/hash')
11: URL="$ENDPOINT/$HASH"
12: CITY="${1:-moscow}"
13: CITY_ID=$(curl -Ls "$URL/cities/?startsWith=$CITY&searchAll=0&lang=en" |xml sel -t -v '/document/data/LocationInfoFull[1]/id')
14: DATA_URL="$URL/forecast/?city=$CITY_ID&lang=en"
15: echo -n "$DATA_URL" > "$URL_CACHE"
16: curl -Ls "$DATA_URL"|xml sel -t -m '/document/GetHHForecastResult' -v '@cityName' -o ', ' -v '@country_name' -n -t -m '//HHForecast|//HHWeather' -v 'time' -o '      ' -v 't' -o '°C ' -v 'fullDesc' -n
17: