Ticket #4226: 4226_diff.patch
File 4226_diff.patch, 2.9 KB (added by , 16 years ago) |
---|
-
mythplugins/mythweather/mythweather/scripts/envcan.pl
148 148 } 149 149 } 150 150 } else { 151 $results{'wind_spdgst'} = sprintf("%.2f (%.2f) kph", $results{'wind_speed'}, $results{'wind_gust'});151 $results{'wind_spdgst'} = sprintf("%.2f (%.2f)", $results{'wind_speed'}, $results{'wind_gust'}); 152 152 } 153 153 154 154 -
mythplugins/mythweather/mythweather/scripts/ENVCANParser.pm
3 3 # This script parses the HTML of an Environment Canada weather forecast 4 4 # page as returned from http://www.weatheroffice.gc.ca. 5 5 # 6 # TODO Not exactly sure how Environment Canada reports windchill. Looks7 # like they don't report it in the summer time. Using temperature8 # as a value for now.9 #10 6 # TODO Environment Canada only reports 5 day forecasts. 6 day forecast 11 7 # layout is used to report 5 day information. 12 8 # … … 36 32 $inside{"$tag-class"} = $attr{class} if defined $attr{class}; 37 33 $inside{"$tag-src"} = $attr{src} if defined $attr{src}; 38 34 $inside{"$tag-longdesc"} = $attr{longdesc} if defined $attr{longdesc}; 35 $inside{"$tag-href"} = $attr{href} if defined $attr{href}; 39 36 40 37 doIMG() if $inside{img}; 41 38 } … … 97 94 $results{'observation_time_rfc822'} = rfc822($1); 98 95 } 99 96 } 100 97 101 98 if ($inside{dt}) { 102 99 if ($_[0] =~ /(Temperature)/) { $scratch = 1; return; } 103 100 if ($_[0] =~ /(Pressure)\/ Tendency/) { $scratch = 2; return; } 104 101 if ($_[0] =~ /(Visibility)/) { $scratch = 3; return; } 105 102 if ($_[0] =~ /(Humidity)/) { $scratch = 4; return; } 106 103 if ($_[0] =~ /(Dewpoint)/) { $scratch = 5; return; } 107 if ($_[0] =~ /(Wind)/) { $scratch = 6; return; } 104 if ($_[0] =~ /(Wind Chill)/ ) { $scratch = 6; return; } 105 if ($_[0] =~ /(Wind)/) { $scratch = 7; return; } 108 106 } 109 107 110 108 if ($inside{dd}) { 111 if ($scratch == 1) { $_[0] =~ /( \d*).*/; $results{'temp'} = $1; $results{'windchill'} = $1; $results{'appt'} = $1; }109 if ($scratch == 1) { $_[0] =~ /(-?\d*).*/; $results{'temp'} = $1; } 112 110 if ($scratch == 2) { $_[0] =~ /(\d*\.\d+) kPa.*/; $results{'pressure'} = $1 * 10; } 113 111 if ($scratch == 3) { $_[0] =~ /(\d*) km/; $results{'visibility'} = $1; } 114 112 if ($scratch == 4) { $_[0] =~ /(\d*) \%/; $results{'relative_humidity'} = $1; } 115 113 if ($scratch == 5) { $_[0] =~ /(-?\d*).*/; $results{'dewpoint'} = $1; } 116 if ($scratch == 6) { 114 if ($scratch == 6) { $_[0] =~ /(-?\d*).*/; $results{'appt'} = $1; $results{'windchill'} = $1; } 115 if ($scratch == 7) { 117 116 $_[0] =~ /.?(\w+) (\d+) km\/h/; 118 117 $results{'wind_dir'} = $directions{$1}; 119 118 $results{'wind_speed'} = $2;