diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-01-23 18:18:50 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-01-23 18:18:50 +0100 |
commit | 8157f3885496ed6949152f17b19ad4090217cc37 (patch) | |
tree | 450dc976e6872d1bc2450d119ae3e0514dfca23a /lib/Travelynx.pm | |
parent | 75363c35cc84f6411fbb73f0c380a41c5e55fdd3 (diff) |
JSON Status API: Add experimental and undocumented nextStops key
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-x | lib/Travelynx.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index f81375c..97c9384 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -3193,8 +3193,34 @@ sub startup { id => $status->{train_id}, }, actionTime => $status->{timestamp}->epoch, + nextStops => [], }; + for my $stop ( @{ $status->{route_after} // [] } ) { + if ( $status->{arr_name} and $stop->[0] eq $status->{arr_name} ) + { + last; + } + push( + @{ $ret->{nextStops} }, + { + name => $stop->[0], + scheduledArrival => $stop->[1]{sched_arr} + ? $stop->[1]{sched_arr}->epoch + : undef, + realArrival => $stop->[1]{rt_arr} + ? $stop->[1]{rt_arr}->epoch + : undef, + scheduledDeparture => $stop->[1]{sched_dep} + ? $stop->[1]{sched_dep}->epoch + : undef, + realDeparture => $stop->[1]{rt_dep} + ? $stop->[1]{rt_dep}->epoch + : undef, + } + ); + } + if ( $status->{dep_eva} ) { my @station_descriptions = Travel::Status::DE::IRIS::Stations::get_station( |