Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Mac Community > Picture Gallery > UI Customization

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 11, 2013, 11:28 PM   #1
WeatherWarning
macrumors newbie
 
Join Date: Jul 2012
Updated Hazardous Weather Warning Script

I wanted to post updated code for the hazardous weather warning script. The original script broke after NOAA redesigned their site.

The updated AppleScript is as follows:
Code:
tell application "Finder"
	set AppleScript's text item delimiters to ""
	set warn to do shell script "curl \"http://forecast.weather.gov/MapClick.php?lat=[YOUR LAT HERE]&lon=[YOUR LONG HERE]&unit=0&lg=english&FcstType=dwml\""
	
	-- count every warning!!
	set AppleScript's text item delimiters to "<hazard"
	set warn_string to every text item of (warn as string)
	
	set amo_warn to 1
	repeat with i in items of warn_string
		if (i as string) contains "headline=\"" then
			set amo_warn to amo_warn + 1
		end if
	end repeat
	
	-- getting the warnings
	set warnings to ""
	set warn_number to 1
	
	repeat until warn_number = (amo_warn)
		set warn_number to warn_number + 1
		try
			set AppleScript's text item delimiters to "<hazard headline=\""
			set temp_warnings to text item warn_number of (warn as string)
			set AppleScript's text item delimiters to "\">"
			set temp_warnings to text item 1 of temp_warnings
			set AppleScript's text item delimiters to ""
			set warnings to warnings & temp_warnings & return
		end try
	end repeat
	
	if warnings = "" then
		set warnings to " "
	end if
	
	return warnings
	
end tell
The script requires subscribing to the the XML from NOAA's forecast page for your area. On a typical forecast page, there should be a big orange XML button linking to the appropriate page.

The final product should look like this (with the Coastal Flood Statement being the hazardous condition):

Enjoy!
WeatherWarning is offline   0 Reply With Quote

Reply
MacRumors Forums > Mac Community > Picture Gallery > UI Customization

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Weather script used in GeekTool no longer displaying conditions ideal.dreams Mac Applications and Mac App Store 13 Jun 26, 2014 03:39 PM
Geektool: GeekTools Weather Script problems wild4life2013 UI Customization 3 Oct 3, 2013 10:05 AM
Yahoo! Weather updated back to their old icon WhackyNinja iPhone and iPod touch Apps 2 Jul 22, 2013 07:21 PM
Yelp Updated With 'Nearby' Recommendations Based on Location, Weather and More MacRumors iOS Blog Discussion 13 Jun 14, 2013 09:13 AM
Weather app icon updated? dazed iOS 6 30 Jun 25, 2012 08:20 AM

Forum Jump

All times are GMT -5. The time now is 02:59 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC