From b08b0fb921e7c5dc9afada0cd873b0cf980bd429 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 14 Jul 2019 17:17:44 +0200 Subject: handle ambiguous train numbers when requesting train details --- lib/Travelynx.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index aee93a5..c502b8c 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1763,8 +1763,16 @@ sub startup { if ( $suggestion->{depDate} eq $date_yy or $suggestion->{depDate} eq $date_yyyy ) { - $trainlink = $suggestion->{trainLink}; - last; + # Train numbers are not unique, e.g. IC 149 refers both to the + # InterCity service Amsterdam -> Berlin and to the InterCity service + # Koebenhavns Lufthavn st -> Aarhus. One workaround is making + # requests with the stationFilter=80 parameter. Checking the origin + # station seems to be the more generic solution, so we do that + # instead. + if ( $suggestion->{dep} eq $train->origin ) { + $trainlink = $suggestion->{trainLink}; + last; + } } } -- cgit v1.2.3