ansiweather

Weather in terminal, with ANSI colors and Unicode symbols
Log | Files | Refs | README | LICENSE

commit 3d8318ad890f28bf3da8ce1d50dd04be06e470b7
parent c9b16d9d61dc3a3eb78951ebb8045d3ecbaec7ad
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sun, 16 Aug 2015 15:44:57 +0200

Detect all numeric locations and switching from 'q' to 'id' API query parameter in this case

Diffstat:
Mansiweather | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ansiweather b/ansiweather @@ -154,7 +154,15 @@ thunderstorm=$(get_config "thunderstorm" || echo "\xe2\x9a\xa1") ###[ Fetch Weather data ]###################################################### api_cmd=$([ "$forecast" != 0 ] && echo "forecast/daily" || echo "weather") -weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?q=$location&units=$units") + +if [ "$location" -gt 0 ] 2> /dev/null +then + # Location is all numeric + weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?id=$location&units=$units") +else + # Location is a string + weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?q=$location&units=$units") +fi if [ -z "$weather" ] then