tGrab weather forecast - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit a645bb4874435f0e83ec23fda311012107afe31e
 (DIR) parent 61b07a657d5fe9e3dbc5b569f1527cf6e3b8be8b
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Fri, 21 Nov 2014 19:09:10 +0100
       
       Grab weather forecast
       
       Diffstat:
         A weather                             |      18 ++++++++++++++++++
       
       1 file changed, 18 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/weather b/weather
       t@@ -0,0 +1,18 @@
       +#!/bin/sh
       +#
       +# z3bra - (c) wtfpl 2014
       +# fetch weather and temperature using openweathermap API
       +
       +CITY=${1:-aix-en-provence}
       +FORECAST=${FORECAST:-5}
       +UNITS=${UNITS:-metric}
       +
       +URL="http://api.openweathermap.org/data/2.5/forecast/daily/?q=$CITY&cnt=$FORECAST&mode=xml&units=$UNITS"
       +
       +curl -s "$URL" | sed -e 's/.*time day="\([^" ]*\).*/\1,/p'          \
       +                     -e 's/^.*symbol.*name="\([^"]*\).*$/\1,/p'     \
       +                     -e 's/^.*temperature.*day="\([^"]*\).*$/\1°C/p'\
       +                     -e 'd'                                         \
       +               | paste -d "" - - -                                  \
       +               | sed 's/^\(.*\),\(.*\),\(.*\)/\1,\3,\2/'            \
       +               | column -t -s, -o" - "