scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit a645bb4874435f0e83ec23fda311012107afe31e
parent 61b07a657d5fe9e3dbc5b569f1527cf6e3b8be8b
Author: z3bra <willy@mailoo.org>
Date:   Fri Nov 21 19:09:10 +0100

Grab weather forecast

Diffstat:
weather | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/weather b/weather @@ -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" - "