# HG changeset patch # User Matti Hamalainen # Date 1421660084 -7200 # Node ID 56af82fb7a6def2b7a5738b6e8ecc772d6445fe1 # Parent f36c26b3c38be59b3b0ad888fadc0c2138284b89 Use lower case. diff -r f36c26b3c38b -r 56af82fb7a6d fetch_weather.pl --- a/fetch_weather.pl Mon Jan 12 16:17:41 2015 +0200 +++ b/fetch_weather.pl Mon Jan 19 11:34:44 2015 +0200 @@ -252,13 +252,18 @@ return defined($_[0]->[$_[2]]{"nodes"}[0]{$_[1]}) ? $_[0]->[$_[2]]{"nodes"}[0]{$_[1]} : ""; } +sub get_node_lc($$$) +{ + return lc(get_node($_[0], $_[1], $_[2])); +} + my %th_rain_states = ( - "Pouta" => "Poutaa", - "Heikko" => "Heikkoa sadetta", - "Kohtalainen" => "Kohtalaista sadetta", - "Voimakas" => "Voimakasta sadetta", + "Pouta" => "poutaa", + "Heikko" => "heikkoa sadetta", + "Kohtalainen" => "kohtalaista sadetta", + "Voimakas" => "voimakasta sadetta", ); my $th_rain_states_k = join("|", map {quotemeta} sort { length($b)<=>length($a) } keys %th_rain_states); @@ -266,7 +271,7 @@ sub translate_th_rain($) { my $tmp = $_[0]; - $tmp =~ s/($th_rain_states_k)/$th_rain_states{$1}/go; + $tmp =~ s/($th_rain_states_k)/$th_rain_states{$1}/igo; return $tmp; } @@ -277,6 +282,12 @@ } +sub plonk_data_lc($) +{ + return defined($_[0]) ? lc($_[0]) : ""; +} + + ### ### Configuration handling ### @@ -435,11 +446,11 @@ [ 0, parse_timestamp(get_node($fdata, "text", 1), $time_base), - get_node($fdata, "text", 2), - get_node($fdata, "text", 3), + get_node_lc($fdata, "text", 2), + get_node_lc($fdata, "text", 3), translate_th_rain(get_node($fdata, "text", 4)), "", - get_node($fdata, "text", 5), + get_node_lc($fdata, "text", 5), ]; } } @@ -513,10 +524,12 @@ [ 1, plonk_data($flol->{"time"}), - plonk_data($flol->{"temp"}), + plonk_data($flol->{"temperature"}), "", "", plonk_data($flol->{"humidity"}), + plonk_data($flol->{"windspeedms"}), + plonk_data($flol->{"totalcloudcover"}), ]; } }