I find the weather script that comes with Indigo a bit lacking, and at times a little slow. Also, I prefer using the weather feed from Yahoo since it matches up to the weather widget in my dashboard.
You’ll first need to get the right parameter for your local weather. Go to Yahoo Weather and type in your city/zip code. Just look at the URL and you should have something like: http://weather.yahoo.com/forecast/USGA0028.html
Grab what comes after ‘forecast/’ and before ‘.html’ and replace ‘USGA0028′ in the script below.
property fetchTimeout : 15 -- don't wait for query response for more than 15 seconds...
try
with timeout of fetchTimeout seconds
do shell script "curl -s 'http://xml.weather.yahoo.com/forecastrss?p=USGA0028' | grep -E '(<yweather:condition|/\\>)' | sed -e 's/^.*temp=\"//' -e 's/\".*$//'"
set temperature to result
do shell script "curl -s 'http://xml.weather.yahoo.com/forecastrss?p=USGA0028' | grep -E '(<yweather:condition|/\\>)' | sed -e 's/^.*text=\"//' -e 's/\".*$//'"
set conditions to result
do shell script "curl -s 'http://xml.weather.yahoo.com/forecastrss?p=USGA0028' | grep -E '(<yweather:forecast day=\"|/\\>)' | sed -e 's/^.*high=\"//' -e 's/\".*$//' -e 'q'"
set high to result
do shell script "curl -s 'http://xml.weather.yahoo.com/forecastrss?p=USGA0028' | grep -E '(<yweather:forecast day=\"|/\\>)' | sed -e 's/^.*low=\"//' -e 's/\".*$//' -e 'q'"
set low to result
tell application "IndigoServer"
if not (variable "weatherTemperature" exists) then
make new variable with properties {name:"weatherTemperature", value:temperature}
else
if value of variable "weatherTemperature" is not temperature then
set value of variable "weatherTemperature" to temperature
end if
end if
if not (variable "weatherConditions" exists) then
make new variable with properties {name:"weatherConditions", value:conditions}
else
if value of variable "weatherConditions" is not conditions then
set value of variable "weatherConditions" to conditions
end if
end if
if not (variable "weatherTemperatureHigh" exists) then
make new variable with properties {name:"weatherTemperatureHigh", value:high}
else
if value of variable "weatherTemperatureHigh" is not high then
set value of variable "weatherTemperatureHigh" to high
end if
end if
if not (variable "weatherTemperatureLow" exists) then
make new variable with properties {name:"weatherTemperatureLow", value:low}
else
if value of variable "weatherTemperatureLow" is not low then
set value of variable "weatherTemperatureLow" to low
end if
end if
end tell
end timeout
end try
