diff options
-rwxr-xr-x | bin/dbris-m | 11 | ||||
-rw-r--r-- | lib/Travel/Status/DE/DBRIS.pm | 12 |
2 files changed, 18 insertions, 5 deletions
diff --git a/bin/dbris-m b/bin/dbris-m index 7a2cf26..253bd19 100755 --- a/bin/dbris-m +++ b/bin/dbris-m @@ -150,6 +150,15 @@ if ( $opt{station} ) { } elsif ( $opt{geoSearch} ) { for my $result ( $status->results ) { - printf( "%8d %s\n", $result->eva, $result->name ); + if ( defined $result->eva ) { + printf( "%8d %s\n", $result->eva, $result->name ); + } + } +} +elsif ( $opt{locationSearch} ) { + for my $result ( $status->results ) { + if ( defined $result->eva ) { + printf( "%8d %s\n", $result->eva, $result->name ); + } } } diff --git a/lib/Travel/Status/DE/DBRIS.pm b/lib/Travel/Status/DE/DBRIS.pm index 7743fce..2b19924 100644 --- a/lib/Travel/Status/DE/DBRIS.pm +++ b/lib/Travel/Status/DE/DBRIS.pm @@ -57,6 +57,10 @@ sub new { $req = "https://www.bahn.de/web/api/reiseloesung/orte/nearby?lat=${lat}&long=${lon}&radius=9999&maxNo=100"; } + elsif ( my $query = $conf{locationSearch} ) { + $req + = "https://www.bahn.de/web/api/reiseloesung/orte?suchbegriff=${query}&typ=ALL&limit=10"; + } # journey : https://www.bahn.de/web/api/reiseloesung/fahrt?journeyId=2%7C%23VN%231%23ST%231733779122%23PI%230%23ZI%23324190%23TA%230%23DA%23141224%231S%238000001%231T%231822%23LS%238000080%23LT%232050%23PU%2380%23RT%231%23CA%23DPN%23ZE%2326431%23ZB%23RE+26431%23PC%233%23FR%238000001%23FT%231822%23TO%238000080%23TT%232050%23&poly=true else { @@ -100,8 +104,8 @@ sub new { if ( $conf{station} ) { $self->parse_stationboard; } - elsif ( $conf{geoSearch} ) { - $self->parse_geosearch; + elsif ( $conf{geoSearch} or $conf{locationSearch} ) { + $self->parse_search; } return $self; @@ -129,7 +133,7 @@ sub new_p { if ( $conf{station} ) { $self->parse_stationboard; } - elsif ( $conf{geoSearch} ) { + elsif ( $conf{geoSearch} or $conf{locationSearch} ) { $self->parse_search; } else { @@ -237,7 +241,7 @@ sub get_with_cache_p { return $promise; } -sub parse_geosearch { +sub parse_search { my ($self) = @_; $self->{results} = []; |