View unanswered posts | View active topics It is currently Tue May 21, 2013 8:20 pm



Reply to topic  [ 8 posts ] 
 Weather - 24 hr Forecast? 
Author Message

Joined: Nov 26, 2009
Posts: 924
Location: Kalispell, MT
Post Weather - 24 hr Forecast?
Hey,

Been looking through and experimenting with the weather scripts but can't seem to find one
that will show a simple forecast, e.g. Partly Cloudy, for the next 24 hr. or so.

It seems the accuweather script might have a forecast variable but after following the instructions very closely I can't get it working.
The event log fills endlessly with "2010-04-11 21:02:30 AccuWeather AccuWeather loop error occured: -1708"
The only way to stop it is to completely shutdown the computer.

Is the Accuweather 1.5 script current? The NOAA script works fine.

Thanks,

Carl


Sat Apr 10, 2010 8:20 pm
Profile

Joined: Mar 31, 2008
Posts: 738
Post Re: Weather - 24 hr Forecast?
Any followup to getting the eastern local forecast as a variable?

Does NOAA offer this somewhere?


Mon Nov 01, 2010 9:07 pm
Profile

Joined: Nov 26, 2009
Posts: 924
Location: Kalispell, MT
Post Re: Weather - 24 hr Forecast?
Hmmm, would seem no one needs a weather forecast variable.
How about one that could define the moon phase?

Carl


Fri Nov 05, 2010 12:59 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6655
Location: Austin, Texas
Post Re: Weather - 24 hr Forecast?
Above and beyond what was discussed in this thread?

_________________
Jay (Indigo Support)
Image


Fri Nov 05, 2010 1:49 pm
Profile WWW

Joined: Mar 31, 2008
Posts: 738
Post Re: Weather - 24 hr Forecast?
I found this website on a search for "applescript weather forecast variable"
http://www.macosxtips.co.uk/index_files ... ricks.html

I set up an applescript as follows (substituting my zip code):
Code: Select all
do shell script "curl -s http://www.wunderground.com/cgi-bin/findweather/getForecast?query=12345 | awk '/Today is/ || /Tomorrow is/' | textutil -convert txt -stdin -stdout -format html"
set Forecast to result
log Forecast


It puts out a long sentance, "Tomorrow is forecast to be nearly the same temperature as today"


Here's another from MacScripter:
http://macscripter.net/viewtopic.php?id=32823

Code: Select all
-- Get Weather
-- This is the city code. Search the code for your city on http://weather.yahoo.com/
set CityCode to 2400849
-- Temperature format
set t_format to "F"
-- Voiceover format
set v_format to "S"
-- Say present condition
set a_format to "Y"

set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode

-- Downloading the file using curl
set file_content to (do shell script "curl " & IURL)
-- Looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText

-- Today conditions found
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1

-- Looking for actual temperature temperature
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b

if t_format is equal to "C" then
   set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if

-- Looking for today forecast
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText

-- Maximum and minimum temperatures found
set today_min_temp to word 9 of sub_2
set today_max_temp to word 12 of sub_2
if t_format is equal to "C" then
   set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
   set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
end if

-- Looking for today forecast condition (a bit tricky)
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4

-- Looking for tomorrow forecast
set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5

-- Maximum and minimum temperatures found
set tomorrow_min_temp to word 9 of sub_6
set tomorrow_max_temp to word 12 of sub_6
if t_format is equal to "C" then
   set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
   set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
end if

-- Looking for tomorrow forecast condition (a bit tricky)
set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8



This one returns "showers early" and then "sunny" for today's and tomorrow's forecast. could work...


Fri Nov 05, 2010 2:46 pm
Profile

Joined: Nov 26, 2009
Posts: 924
Location: Kalispell, MT
Post Re: Weather - 24 hr Forecast?
jay wrote:Above and beyond what was discussed in this thread?


Doh again. I had an upper case letter in my variable that wasn't in my script.
All better.

Thanks,

Carl


Sat Nov 06, 2010 9:33 am
Profile

Joined: Nov 26, 2009
Posts: 924
Location: Kalispell, MT
Post Re: Weather - 24 hr Forecast?
Code: Select all
do shell script "curl -s http://www.wunderground.com/cgi-bin/findweather/getForecast?query=12345 | awk '/Today is/ || /Tomorrow is/' | textutil -convert txt -stdin -stdout -format html"
set Forecast to result
log Forecast


Can the above script be modified to populate a variable?

Thanks,

Carl


Wed Feb 23, 2011 11:17 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6655
Location: Austin, Texas
Post Re: Weather - 24 hr Forecast?
Add this line to the end of the script:

Code: Select all
set value of variable "YOURVARNAMEHERE" to Forecast


I'm assuming you're running it embedded: you should use a pretty short timeout on your curl command using the "--max-time" option since it can hang the server.

_________________
Jay (Indigo Support)
Image


Wed Feb 23, 2011 11:48 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.