updates for upstream data

This commit is contained in:
Matthew Slowe 2022-02-18 09:36:52 +00:00
parent cbf8bcfbf2
commit fdcd4e5fe1

16
new.pl
View File

@ -59,22 +59,14 @@ foreach my $station (@stations) {
my $lastupdate;
my $watercourse;
my $datum;
if ($res->is_success and $res->content =~ m~station: {~) {
$res->content =~ m~station: ({.*})~;
if ($res->is_success and $res->content =~ m~window.flood.model = \{~) {
$res->content =~ m~({.*})\s*<\/script>~sug;
my $stationdata = from_json($1);
$res->content =~ m~chart: (\[.*\])~;
my $leveldata = from_json($1);
$stationname = $stationdata->{'name'};
# $level = $leveldata->[0]->{_};
$res->content =~ /"recentValue":{"ts":"([^"]+)","_":(\d+.\d+),"err":false}}/;
# $res->content =~ m~Latest recorded level <strong class="bold-small">(-?[\d\.]+)m~;
$level = $2;
# $res->content =~ m~Recorded at (.*)~;
# $res->content =~ m~Recorded at ([^<]+)<~;
my $lastupdate_str = $1;
$level = $stationdata->{recentValue}->{_};
my $lastupdate_str = $stationdata->{recentValue}->{ts};
$lastupdate = UnixDate($lastupdate_str, "%Y-%m-%dT%T.000Z");
# $lastupdate = UnixDate($leveldata->[0]->{ts}, "%Y-%m-%dT%T.000Z");
print STDERR "[$station] $stationname is $level at $lastupdate\n" if $ENV{R_DEBUG};
if($ENV{R_GPLOT}) {