Skip Menu |

This queue is for tickets about the Weather-Underground CPAN distribution.

Report information
The Basics
Id: 65027
Status: open
Priority: 0/
Queue: Weather-Underground

People
Owner: Nobody in particular
Requestors: adrian [...] likins.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: patch for weather::underground temp fetching
Date: Sat, 22 Jan 2011 17:35:56 -0500
To: bug-Weather-Underground [...] rt.cpan.org
From: Adrian Likins <adrian [...] likins.com>
Looks like the format Weather Underground shows temperature in my have changed recently. Attached is a (not great) patch for getting temperature working again. Adrian

Message body is not shown because sender requested not to inline it.

Show quoted text
> Looks like the format Weather Underground shows temperature in my > have changed recently. Attached is a (not great) patch for > getting temperature working again.
A little regression in your patch. You use the same regex for °C and °F so the same value is put in temperature_celsius and temperature_fahrenheit. Replace the regex "/(-?([?[0-9]*\.?[0-9]+))/i" by : * /(-?([?[0-9]*\.?[0-9]+))&deg;c/i) for celsius * /(-?([?[0-9]*\.?[0-9]+))&deg;f/i) for fahrenheit seems to work better (but I'm not sure that the "&deg;(c|f)" format is always used) See corrected patch file enclosed.
Subject: Underground-format-change.diff.txt
diff --git a/Weather-Underground-3.02/Underground.pm b/Weather-Underground-3.02/Underground.pm index 3506d03..f334ce4 100644 --- a/Weather-Underground-3.02/Underground.pm +++ b/Weather-Underground-3.02/Underground.pm @@ -443,7 +443,7 @@ sub get_weather { $ua->timeout($self->{timeout}); } $oldagent = $ua->agent(); - $ua->agent("Weather::Underground version $VERSION"); + $ua->agent("curl version $VERSION"); $document = get($self->{_url}); $ua->agent($oldagent); @@ -763,8 +763,10 @@ sub _state2result { } $stateref->{"content_TEMPERATURE"} =~ s/\s//g; - ($temperature_celsius) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?c/i); - ($temperature_fahrenheit) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?f/i); + #($temperature_celsius) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?c/i); + #($temperature_fahrenheit) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?f/i); + ($temperature_celsius) = ($stateref->{"content_TEMPERATURE"} =~ /(-?([?[0-9]*\.?[0-9]+))&deg;c/i); + ($temperature_fahrenheit) = ($stateref->{"content_TEMPERATURE"} =~ /(-?([?[0-9]*\.?[0-9]+))&deg;f/i); if (!length($temperature_celsius) && length($temperature_fahrenheit)) { $temperature_celsius = ($temperature_fahrenheit - 32) / 1.8; } @@ -773,8 +775,10 @@ sub _state2result { } $stateref->{"content_DEW_POINT"} =~ s/\s//g; - ($dewpoint_celsius) = ($stateref->{"content_DEW_POINT"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?c/i); - ($dewpoint_fahrenheit) = ($stateref->{"content_DEW_POINT"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?f/i); + ($dewpoint_celsius) = ($stateref->{"content_DEW_POINT"} =~ /(-?([?[0-9]*\.?[0-9]+))&deg;c/i); + + ($dewpoint_fahrenheit) = ($stateref->{"content_DEW_POINT"} =~ /(-?([?[0-9]*\.?[0-9]+))&deg;f/i); + if (!length($dewpoint_celsius) && length($dewpoint_fahrenheit)) { $dewpoint_celsius = ($dewpoint_fahrenheit - 32) / 1.8; }