From 8053eb8835a0fec2171d153a4a99db72156c34aa Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 4 Jan 2020 23:33:11 +0100 Subject: Use correct Trip ID request for arrival-only trains --- lib/DBInfoscreen/Controller/Map.pm | 4 ++-- lib/DBInfoscreen/Controller/Stationboard.pm | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/DBInfoscreen/Controller') diff --git a/lib/DBInfoscreen/Controller/Map.pm b/lib/DBInfoscreen/Controller/Map.pm index df749bf..81c3b20 100644 --- a/lib/DBInfoscreen/Controller/Map.pm +++ b/lib/DBInfoscreen/Controller/Map.pm @@ -21,8 +21,8 @@ sub get_hafas_polyline { #say $url; my $res = $ua->get( -"https://2.db.transport.rest/trips/${trip_id}?lineName=${line}&polyline=true" - => { 'User-Agent' => "dbf.finalrewind.org/${dbf_version}" } )->result; + $url => { 'User-Agent' => "dbf.finalrewind.org/${dbf_version}" } ) + ->result; if ( $res->is_error ) { return; } diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index d593105..fb778dd 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -124,16 +124,19 @@ sub get_hafas_trip_id { my $eva = $train->station_uic; my $dep_ts = DateTime->now( time_zone => 'Europe/Berlin' ); + my $url + = "https://2.db.transport.rest/stations/${eva}/departures?duration=5&when=$dep_ts"; if ( $train->sched_departure ) { $dep_ts = $train->sched_departure->epoch; + $url + = "https://2.db.transport.rest/stations/${eva}/departures?duration=5&when=$dep_ts"; } elsif ( $train->sched_arrival ) { $dep_ts = $train->sched_arrival->epoch; + $url + = "https://2.db.transport.rest/stations/${eva}/arrivals?duration=5&when=$dep_ts"; } - my $url - = "https://2.db.transport.rest/stations/${eva}/departures?duration=5&when=$dep_ts"; - if ( my $content = $cache->get($url) ) { return $content; } @@ -141,8 +144,8 @@ sub get_hafas_trip_id { $ua->request_timeout(2); my $res = $ua->get( -"https://2.db.transport.rest/stations/${eva}/departures?duration=5&when=$dep_ts" - => { 'User-Agent' => "dbf.finalrewind.org/${dbf_version}" } )->result; + $url => { 'User-Agent' => "dbf.finalrewind.org/${dbf_version}" } ) + ->result; if ( $res->is_error ) { return; } -- cgit v1.2.3