From f12b977e9996439d8fc7d5987ca9581b07966a2d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 18 Sep 2015 22:31:56 +0200 Subject: switch to HAFAS backend, also improved legacy / sub-backend support --- index.pl | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'index.pl') diff --git a/index.pl b/index.pl index c36d92e..f1d9fad 100644 --- a/index.pl +++ b/index.pl @@ -11,7 +11,7 @@ use List::Util qw(first); use List::MoreUtils qw(any); use App::VRR::Fakedisplay; -use Travel::Status::DE::DeutscheBahn; +use Travel::Status::DE::HAFAS; use Travel::Status::DE::ASEAG; use Travel::Status::DE::EFA; @@ -52,12 +52,19 @@ sub get_results { lock_level => Cache::File::LOCK_LOCAL(), ); - if ( $backend =~ m{ [.] }x ) { - ($sub_backend) = ( $backend =~ m{ [.] (.+) $ }x ); + # legacy values + if ( not defined $backend or $backend eq 'vrr' ) { + $backend = 'efa.VRR'; + } + + if ( $backend =~ s{ [.] (.+) $ }{}x ) { + $sub_backend = $1; - if ( not $sub_backend ~~ \@efa_services ) { - $sub_backend = undef; - $backend =~ s{ [.] (.+) $ }{}x; + if ( $backend eq 'efa' and not $sub_backend ~~ \@efa_services ) { + return { + results => [], + errstr => "efa sub-backend '$sub_backend' not supported" + }; } } @@ -72,18 +79,9 @@ sub get_results { } my $status; if ( $backend eq 'db' ) { - $status = Travel::Status::DE::DeutscheBahn->new( - station => "${stop}, ${city}", - mot => { - ice => 0, - ic_ec => 0, - d => 0, - nv => 0, - s => 1, - bus => 1, - u => 1, - tram => 1, - }, + $status = Travel::Status::DE::HAFAS->new( + station => "${stop}, ${city}", + excluded_mots => [qw[ice ic_ec d regio]], ); } elsif ( $backend eq 'aseag' ) { -- cgit v1.2.3