Ticket #4226: 4226_diff.2.patch
File 4226_diff.2.patch, 2.6 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 # … … 97 93 $results{'observation_time_rfc822'} = rfc822($1); 98 94 } 99 95 } 100 96 101 97 if ($inside{dt}) { 102 98 if ($_[0] =~ /(Temperature)/) { $scratch = 1; return; } 103 99 if ($_[0] =~ /(Pressure)\/ Tendency/) { $scratch = 2; return; } 104 100 if ($_[0] =~ /(Visibility)/) { $scratch = 3; return; } 105 101 if ($_[0] =~ /(Humidity)/) { $scratch = 4; return; } 106 102 if ($_[0] =~ /(Dewpoint)/) { $scratch = 5; return; } 107 if ($_[0] =~ /(Wind)/) { $scratch = 6; return; } 103 if ($_[0] =~ /(Wind Chill)/ ) { $scratch = 6; return; } 104 if ($_[0] =~ /(Wind)/) { $scratch = 7; return; } 108 105 } 109 106 110 107 if ($inside{dd}) { 111 if ($scratch == 1) { $_[0] =~ /( \d*).*/; $results{'temp'} = $1; $results{'windchill'} = $1; $results{'appt'} = $1; }108 if ($scratch == 1) { $_[0] =~ /(-?\d*).*/; $results{'temp'} = $1; } 112 109 if ($scratch == 2) { $_[0] =~ /(\d*\.\d+) kPa.*/; $results{'pressure'} = $1 * 10; } 113 110 if ($scratch == 3) { $_[0] =~ /(\d*) km/; $results{'visibility'} = $1; } 114 111 if ($scratch == 4) { $_[0] =~ /(\d*) \%/; $results{'relative_humidity'} = $1; } 115 112 if ($scratch == 5) { $_[0] =~ /(-?\d*).*/; $results{'dewpoint'} = $1; } 116 if ($scratch == 6) { 113 if ($scratch == 6) { $_[0] =~ /(-?\d*).*/; $results{'appt'} = $1; $results{'windchill'} = $1; } 114 if ($scratch == 7) { 117 115 $_[0] =~ /.?(\w+) (\d+) km\/h/; 118 116 $results{'wind_dir'} = $directions{$1}; 119 117 $results{'wind_speed'} = $2;