From b379de3fc961fb8118ccc02caa327d8e92351f29 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 1 Aug 2012 01:26:45 +0100 Subject: [PATCH] Guard against incomplete data in the MetOffice feed, if a period contains no data then skip over it --- .../mythweather/scripts/uk_metoffice/metoffice_fivedayapi.pl | 4 ++++ .../scripts/uk_metoffice/metoffice_threehourapi.pl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_fivedayapi.pl b/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_fivedayapi.pl index 9a33b5ec9be..7182ac4abe8 100755 --- a/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_fivedayapi.pl +++ b/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_fivedayapi.pl @@ -139,6 +139,10 @@ foreach $item (@{$xml->{DV}->{Location}->{Period}}) { + if (ref($item->{Rep}) ne 'ARRAY') { + next; + } + my ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($item->{val}); $year += 1900; # Returns year as offset from 1900 $month += 1; # Returns month starting at zero diff --git a/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_threehourapi.pl b/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_threehourapi.pl index 574f47482e4..8910d3a29ae 100755 --- a/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_threehourapi.pl +++ b/mythplugins/mythweather/mythweather/scripts/uk_metoffice/metoffice_threehourapi.pl @@ -139,6 +139,10 @@ foreach $item (@{$xml->{DV}->{Location}->{Period}}) { + if (ref($item->{Rep}) ne 'ARRAY') { + next; + } + foreach my $rep (@{$item->{Rep}}) { my $datetime = DateTime::Format::ISO8601->parse_datetime(substr($item->{val}, 0, -1));