From fb639e553f15022e865233742914a9e7af99c9f3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 6 Apr 2021 10:40:52 +0200 Subject: trainsearch: handle unknown train types IRIS reports unknown train types as "-"; HAFAS wants the train type to be left out in this case --- lib/DBInfoscreen/Helper/HAFAS.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/DBInfoscreen') diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 8d4c89f..249d308 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -204,6 +204,10 @@ sub trainsearch_p { $opt{date_yyyy} = $now->strftime('%d.%m.%Y'); } + # IRIS reports trains with unknown type as type "-". HAFAS thinks otherwise + # and prefers the type to be left out entirely in this case. + $opt{train_req} =~ s{^- }{}; + my $promise = Mojo::Promise->new; $self->get_json_p( $self->{realtime_cache}, -- cgit v1.2.3