diff options
Diffstat (limited to 'lib/DBInfoscreen/Helper')
-rw-r--r-- | lib/DBInfoscreen/Helper/HAFAS.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 6ff147f..ad21c58 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -72,9 +72,23 @@ sub get_route_p { return Mojo::Promise->reject( "journeyMatch($opt{train_req}) found no results"); } + + my $result = $results[0]; + if ( @results > 1 ) { + for my $journey (@results) { + if ( $opt{train_origin} + and ( $journey->route )[0]->loc->name eq + $opt{train_origin} ) + { + $result = $journey; + last; + } + } + } + return Travel::Status::DE::HAFAS->new_p( journey => { - id => $results[0]->id, + id => $result->id, }, language => $opt{language}, cache => $self->{realtime_cache}, |