diff --git a/plugins/weather/openweather_ b/plugins/weather/openweather_ index d8a5a51e..47b1c128 100644 --- a/plugins/weather/openweather_ +++ b/plugins/weather/openweather_ @@ -5,48 +5,135 @@ # This part is taken from the original plugin # Example usage: # Do -# ln -s /path/to/openweather_ openweather__ -# where is currently ignored (formerly one of -# [station, weather]) and is a suitable -# city id from http://openweathermap.org/ -# These parameters translate directly into a URL formed like this: -# http://openweathermap.org/data//weather?id= +# ln -s /path/to/openweather_ openweather_ +# where is either a search query "q_Paris" or +# or an id search "id_2988507" # -# Example config: -# [openweather_*] +# These parameters translate directly into a URL formed like this: +# http://api.openweathermap.org/data//weather? # -entity_id=${0##*_} +query_string=$(printf '%s' "${0#*_}" | tr '_' '=') TMPFILE=$(mktemp) trap 'rm -f $TMPFILE' EXIT +# API returns temp in K, we have to convert it in C KELVIN_BIAS=273 -curl -s "http://openweathermap.org/data/2.5/weather?id=${entity_id}" | tr ':{},' ' \n' > $TMPFILE +curl -s "http://api.openweathermap.org/data/2.5/weather?mode=xml&${query_string}" > $TMPFILE -while read KEY VALUE EXTRA -do - [ "$KEY" = '"main"' ] && KEY=$VALUE && VALUE=$EXTRA - [ "$KEY" = '"temp"' ] && { - VALUE=${VALUE%%.*} - [ "$1" != "config" ] && echo "temp.value $(( $VALUE - $KELVIN_BIAS ))" - } +CITY=$(fgrep " + + + + FR + + + + + + + + + + + + + + + +EOF