Loading bin/hafas-m +13 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,16 @@ sub parse_mot_options { } } sub show_similar_stops { my @candidates = $status->similar_stops; if (@candidates) { say 'You might want to try one of the following stops:'; for my $c (@candidates) { printf( "%s (%s)\n", $c->{name}, $c->{id} ); } } } sub display_result { my (@lines) = @_; Loading Loading @@ -141,6 +151,9 @@ sub display_result { if ( my $err = $status->errstr ) { say STDERR "Request error: ${err}"; if ( $status->errcode and $status->errcode eq 'H730' ) { show_similar_stops(); } exit 2; } Loading lib/Travel/Status/DE/HAFAS.pm +32 −2 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Carp qw(confess); use LWP::UserAgent; use POSIX qw(strftime); use Travel::Status::DE::HAFAS::Result; use Travel::Status::DE::HAFAS::StopFinder; use XML::LibXML; our $VERSION = '1.05'; Loading @@ -18,11 +19,13 @@ our $VERSION = '1.05'; my %hafas_instance = ( BVG => { url => 'http://bvg.hafas.de/bin/stboard.exe', stopfinder => 'http://bvg.hafas.de/bin/ajax-getstop.exe', name => 'Berliner Verkehrsgesellschaft', productbits => [qw[s u tram bus ferry ice regio ondemand]], }, DB => { url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe', stopfinder => 'http://reiseauskunft.bahn.de/bin/ajax-getstop.exe', name => 'Deutsche Bahn', productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]], Loading Loading @@ -102,6 +105,7 @@ sub new { developer_mode => $conf{developer_mode}, exclusive_mots => $conf{exclusive_mots}, excluded_mots => $conf{excluded_mots}, station => $conf{station}, post => { input => $conf{station}, date => $date, Loading Loading @@ -210,17 +214,43 @@ sub check_input_error { = $err->getAttribute('text') . ' (code ' . $err->getAttribute('code') . ')'; $self->{errcode} = $err->getAttribute('code'); } return; } sub errcode { my ($self) = @_; return $self->{errcode}; } sub errstr { my ($self) = @_; return $self->{errstr}; } sub similar_stops { my ($self) = @_; my $service = $self->{active_service}; if ( $service and exists $hafas_instance{$service}{stopfinder} ) { my $sf = Travel::Status::DE::HAFAS::StopFinder->new( url => $hafas_instance{$service}{stopfinder}, input => $self->{station}, ); if ( my $err = $sf->errstr ) { $self->{errstr} = $err; return; } return $sf->results; } return; } sub results { my ($self) = @_; my $mode = $self->{post}->{boardType}; Loading Loading
bin/hafas-m +13 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,16 @@ sub parse_mot_options { } } sub show_similar_stops { my @candidates = $status->similar_stops; if (@candidates) { say 'You might want to try one of the following stops:'; for my $c (@candidates) { printf( "%s (%s)\n", $c->{name}, $c->{id} ); } } } sub display_result { my (@lines) = @_; Loading Loading @@ -141,6 +151,9 @@ sub display_result { if ( my $err = $status->errstr ) { say STDERR "Request error: ${err}"; if ( $status->errcode and $status->errcode eq 'H730' ) { show_similar_stops(); } exit 2; } Loading
lib/Travel/Status/DE/HAFAS.pm +32 −2 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Carp qw(confess); use LWP::UserAgent; use POSIX qw(strftime); use Travel::Status::DE::HAFAS::Result; use Travel::Status::DE::HAFAS::StopFinder; use XML::LibXML; our $VERSION = '1.05'; Loading @@ -18,11 +19,13 @@ our $VERSION = '1.05'; my %hafas_instance = ( BVG => { url => 'http://bvg.hafas.de/bin/stboard.exe', stopfinder => 'http://bvg.hafas.de/bin/ajax-getstop.exe', name => 'Berliner Verkehrsgesellschaft', productbits => [qw[s u tram bus ferry ice regio ondemand]], }, DB => { url => 'http://reiseauskunft.bahn.de/bin/bhftafel.exe', stopfinder => 'http://reiseauskunft.bahn.de/bin/ajax-getstop.exe', name => 'Deutsche Bahn', productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand x x x x]], Loading Loading @@ -102,6 +105,7 @@ sub new { developer_mode => $conf{developer_mode}, exclusive_mots => $conf{exclusive_mots}, excluded_mots => $conf{excluded_mots}, station => $conf{station}, post => { input => $conf{station}, date => $date, Loading Loading @@ -210,17 +214,43 @@ sub check_input_error { = $err->getAttribute('text') . ' (code ' . $err->getAttribute('code') . ')'; $self->{errcode} = $err->getAttribute('code'); } return; } sub errcode { my ($self) = @_; return $self->{errcode}; } sub errstr { my ($self) = @_; return $self->{errstr}; } sub similar_stops { my ($self) = @_; my $service = $self->{active_service}; if ( $service and exists $hafas_instance{$service}{stopfinder} ) { my $sf = Travel::Status::DE::HAFAS::StopFinder->new( url => $hafas_instance{$service}{stopfinder}, input => $self->{station}, ); if ( my $err = $sf->errstr ) { $self->{errstr} = $err; return; } return $sf->results; } return; } sub results { my ($self) = @_; my $mode = $self->{post}->{boardType}; Loading