2012-07-07, 06:28
Looks like NOAA has made some more changes that breaks a few things. Here's is a patch against weatherplus v3.0.1 to get things working again (cumulative with the patch I posted on 6 may 2012...):
There's still some weirdness with a missing icon or two that I haven't yet fixed (mostly because I haven't bothered trying to understand how NOAA icons get mapped to XBMC icons) but this patch should be sufficient to stop the script failure messages when using NOAA as the weather source...
Code:
--- noaa.py.orig 2012-07-07 00:17:01.658625504 -0400
+++ noaa.py 2012-07-07 00:16:53.730804446 -0400
@@ -229,7 +229,7 @@
pattern_current_heatindex = "<td><b>Heat Index</b>:</td>[^<]+<td align=[^>]+>(.+?)\°\;F"
pattern_current_block = "<data type=\"current observations\">"
- pattern_current_icon = "<icon-link>http://forecast.weather.gov/images/wtf/([^\d\s]+).jpg"
+ pattern_current_icon = "<icon-link>http://forecast.weather.gov/images/wtf/([^\d\s]+).png"
pattern_current_temp = "<temperature type=\"apparent\"[^>]+>(.+?)</temperature>"
pattern_current_dew = "<temperature type=\"dew point\"[^>]+>(.+?)</temperature>"
pattern_current_humidity = "<humidity[^>]+>(.+?)</humidity>"
@@ -239,17 +239,18 @@
pattern_current_pressure = "<pressure type=\"barometer\"[^>]+>(.+?)</pressure>"
pattern_current_brief = "<weather-conditions weather-summary=\"([^\"]+)\"/>"
- pattern_current_wind = "<td><b>Wind Speed</b>:</td>[^<]+<td align=[^>]+>(.+?)</td>"
+ pattern_current_wind = "<li><span[^>]+>Wind Speed</span>(.+?)</li>"
pattern_current_wind_2 = "<td><b>Wind Speed</b>:</td><td align=[^>]+>(.+?)<br>"
pattern_precip_amount = "no-repeat;\">([0-9]+)\%</td><td class=\"weekly_wind\">"
- pattern_outlook = ": </b>(.+?)<br><br>"
+ pattern_outlook_block = "class=\"point-forecast-7-day\"(.+?)</ul>"
+ pattern_outlook = "</span>(.+?)</li>"
pattern_sunrise = "sunrise will occur around (.+?)am"
pattern_sunset = "sunset will occur around (.+?)pm"
pattern_wind = "<td class=\"weekly_wind\"><img class=\"wind\" src=\"image/(.+?).png\" width=\"50\" height=\"22\" alt=\"[^\"]+\" /><br />(.+?)</td>"
pattern_xml_high_temp = "<value>(.[0-9]+)</value>"
pattern_xml_brief = "<weather-conditions weather-summary=\"(.+?)\"/>"
pattern_xml_days = "<start-valid-time period-name=\"(.+?)\">"
- pattern_icon = "<icon-link>(.+?).jpg</icon-link>"
+ pattern_icon = "<icon-link>(.+?).png</icon-link>"
pattern_alerts = "showsigwx.php[?]([^\"]+)\"><[^>]+>([^<]+)<"
@@ -282,7 +283,7 @@
current_icon = icondir.get( current_icon, "na" ) + ".png"
for count in range(0, 13-ampm):
icon += [ icondir.get ( re.findall( "([^\d\s]+)", icons[count].split("/")[-1] )[0], "na" ) ]
- # printlog("NOAA icons : " + ",".join(icon))
+ #printlog("NOAA icons : " + ",".join(icon))
# enumerate thru and combine the day with it's forecast
if ( len( icon ) ):
@@ -348,7 +349,8 @@
precip_amount = re.findall( pattern_precip_amount, htmlSource_2 )
# fetch forecasts
- outlook = re.findall( pattern_outlook, htmlSource )
+ outlook_block = re.findall( pattern_outlook_block, htmlSource, re.DOTALL )
+ outlook = re.findall( pattern_outlook, outlook_block[0] )
# fetch extra info
pressure = re.findall( pattern_current_pressure, current )[0]
@@ -377,10 +379,11 @@
for count in range(0, 13):
# make icon path
try :
- iconpath = "/".join( [ "special://temp", "weather", "128x128", icon[ count ] + ".png" ] )
+ printlog( "ICON " + str(count) + ": " + icon[count] + ".png" )
+ iconpath = "/".join( [ "special://temp", "weather", icon[ count ] + ".png" ] )
except :
printlog("Icon is not available")
- iconpath = "/".join( [ "special://temp", "weather", "128x128", "na.png" ] )
+ iconpath = "/".join( [ "special://temp", "weather", "na.png" ] )
# printlog( iconpath )
# date calculation for 6 day
year = time.strftime( "%Y", time.localtime() )
@@ -618,36 +621,39 @@
else:
outlook = "Rain Likely"
icon += "rain"
- elif ( snow[count] != "--" ):
- if ( rain[count] == "SChc" ):
- outlook = "Slight Chace of Snow"
- icon += "chance"
- elif ( rain[count] == "Chc" ):
- outlook = "Chance of Snow"
- icon += "chance"
- else:
- outlook = "Snow Likely"
- icon += "snow"
- elif ( freezing_rain[count] != "--" ):
- if ( rain[count] == "SChc" ):
- outlook = "Slight Chace of Freezing Rain"
- icon += "chance"
- elif ( rain[count] == "Chc" ):
- outlook = "Chance of Freezing Rain"
- icon += "chance"
- else:
- outlook = "Freezing Rain Likely"
- icon += "freeze"
- elif ( sleet[count] != "--" ):
- if ( rain[count] == "SChc" ):
- outlook = "Slight Chace of Sleet"
- icon += "chance"
- elif ( rain[count] == "Chc" ):
- outlook = "Chance of Sleet"
- icon += "chance"
- else:
- outlook = "Sleet Likely"
- icon += "sleet"
+ elif ( snow ):
+ if ( snow[count] != "--" ):
+ if ( rain[count] == "SChc" ):
+ outlook = "Slight Chace of Snow"
+ icon += "chance"
+ elif ( rain[count] == "Chc" ):
+ outlook = "Chance of Snow"
+ icon += "chance"
+ else:
+ outlook = "Snow Likely"
+ icon += "snow"
+ elif ( freezing_rain ):
+ if ( freezing_rain[count] != "--" ):
+ if ( rain[count] == "SChc" ):
+ outlook = "Slight Chace of Freezing Rain"
+ icon += "chance"
+ elif ( rain[count] == "Chc" ):
+ outlook = "Chance of Freezing Rain"
+ icon += "chance"
+ else:
+ outlook = "Freezing Rain Likely"
+ icon += "freeze"
+ elif ( sleet ):
+ if ( sleet[count] != "--" ):
+ if ( rain[count] == "SChc" ):
+ outlook = "Slight Chace of Sleet"
+ icon += "chance"
+ elif ( rain[count] == "Chc" ):
+ outlook = "Chance of Sleet"
+ icon += "chance"
+ else:
+ outlook = "Sleet Likely"
+ icon += "sleet"
elif ( int(wind[count]) > 20 ):
icon = "windy"
outlook = "Windy"
@@ -670,4 +676,4 @@
icon += "cloudy"
outlook = "Cloudy"
hour_temp += 1
- self.forecast += [ ( _localize_unit( hour, "time" ), dates[ count ], "special://temp/weather/128x128/%s.png" % icondir.get(icon, "na"), _localize_unit(temperature[ count ]), outlook, _english_localize_unit( feelslike ), precip[ count ], humidity[ count ], windir.get( wind_direction[ count ] ), _localize_unit( wind[ count ]+" mph", "speed" ), "" ) ]
+ self.forecast += [ ( _localize_unit( hour, "time" ), dates[ count ], "special://temp/weather/%s.png" % icondir.get(icon, "na"), _localize_unit(temperature[ count ]), outlook, _english_localize_unit( feelslike ), precip[ count ], humidity[ count ], windir.get( wind_direction[ count ] ), _localize_unit( wind[ count ]+" mph", "speed" ), "" ) ]
There's still some weirdness with a missing icon or two that I haven't yet fixed (mostly because I haven't bothered trying to understand how NOAA icons get mapped to XBMC icons) but this patch should be sufficient to stop the script failure messages when using NOAA as the weather source...