Loading bin/hafas-m +27 −15 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ use List::MoreUtils qw(uniq); use List::Util qw(first max); use Travel::Status::DE::HAFAS; my ( $date, $time ); my ( $date, $time, $language ); my $arrivals = 0; my $types = q{}; my $developer_mode; Loading @@ -33,6 +33,7 @@ GetOptions( 'a|arrivals' => \$arrivals, 'd|date=s' => \$date, 'h|help' => sub { show_help(0) }, 'l|language=s' => \$language, 'm|mot=s' => \$types, 's|service=s' => \$service, 't|time=s' => \$time, Loading @@ -44,9 +45,13 @@ GetOptions( ) or show_help(1); if ($list_services) { printf( "%-40s %-14s\n\n", 'operator', 'abbr. (-s)' ); printf( "%-40s %-14s %s\n\n", 'operator', 'abbr. (-s)', 'languages (-l)' ); for my $service ( Travel::Status::DE::HAFAS::get_services() ) { printf( "%-40s %-14s\n", @{$service}{qw(name shortname)} ); printf( "%-40s %-14s %s\n", @{$service}{qw(name shortname)}, join( q{ }, @{ $service->{languages} // [] } ) ); } exit 0; } Loading @@ -60,6 +65,7 @@ my %opt = ( arrivals => $arrivals, developer_mode => $developer_mode, service => $service, language => $language, ); if ( $opt{station} =~ m{ ^ (?<lat> [0-9.]+ ) : (?<lon> [0-9].+ ) $ }x ) { Loading Loading @@ -369,11 +375,11 @@ hafas-m - Interface to the DeutscheBahn/HAFAS online departure monitor =head1 SYNOPSIS B<hafas-m> [B<-d> I<date>] [B<-t> I<time>] [B<-m> I<motlist>] [B<-s> I<service>] I<station> [B<-s> I<service>] [B<-l> I<language>] I<station> B<hafas-m> [B<-s> I<service>] B<?>I<query>|I<lat>B<:>I<lon> B<hafas-m> [B<-s> I<service>] I<journeyID> B<hafas-m> [B<-s> I<service>] [B<-l> I<language>] I<journeyID> =head1 VERSION Loading Loading @@ -442,6 +448,12 @@ Print result(s) as JSON. This is a dump of internal data structures and not guaranteed to remain stable between minor versions. Please use the Travel::Status::DE::HAFAS(3pm) module if you need a proper API. =item B<-l>, B<--language> I<language> Request free-text messages to be provided in I<language>. See B<--list> for a list of languages supported by individual HAFAS instances. Note that requesting an invalid/unsupported language may lead to garbage output. =item B<--list> List known HAFAS installations and exit. Use B<-s>|B<--service> to select an Loading lib/Travel/Status/DE/HAFAS.pm +11 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ my %hafas_instance = ( name => 'Deutsche Bahn', productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand]], salt => 'bdI8UVj4' . '0K5fvxwf', languages => [qw[de en fr es]], request => { client => { id => 'DB', Loading Loading @@ -339,6 +340,10 @@ sub new { }; } if ( $conf{language} ) { $req->{lang} = $conf{language}; } $self->{strptime_obj} //= DateTime::Format::Strptime->new( pattern => '%Y%m%dT%H%M%S', time_zone => 'Europe/Berlin', Loading Loading @@ -986,6 +991,12 @@ If this option is set, only the modes of transport appearing in I<mot1>, I<mot2>, ... will be returned. The supported modes depend on B<service>, use B<get_services> or B<get_service> to get the supported values. =item B<language> => I<language> Request text messages to be provided in I<language>. Supported languages depend on B<service>, use B<get_services> or B<get_service> to get the supported values. Providing an unsupported or invalid value may lead to garbage output. =item B<lookahead> => I<int> (station) Request arrivals/departures that occur up to I<int> minutes after the specified datetime. Loading Loading
bin/hafas-m +27 −15 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ use List::MoreUtils qw(uniq); use List::Util qw(first max); use Travel::Status::DE::HAFAS; my ( $date, $time ); my ( $date, $time, $language ); my $arrivals = 0; my $types = q{}; my $developer_mode; Loading @@ -33,6 +33,7 @@ GetOptions( 'a|arrivals' => \$arrivals, 'd|date=s' => \$date, 'h|help' => sub { show_help(0) }, 'l|language=s' => \$language, 'm|mot=s' => \$types, 's|service=s' => \$service, 't|time=s' => \$time, Loading @@ -44,9 +45,13 @@ GetOptions( ) or show_help(1); if ($list_services) { printf( "%-40s %-14s\n\n", 'operator', 'abbr. (-s)' ); printf( "%-40s %-14s %s\n\n", 'operator', 'abbr. (-s)', 'languages (-l)' ); for my $service ( Travel::Status::DE::HAFAS::get_services() ) { printf( "%-40s %-14s\n", @{$service}{qw(name shortname)} ); printf( "%-40s %-14s %s\n", @{$service}{qw(name shortname)}, join( q{ }, @{ $service->{languages} // [] } ) ); } exit 0; } Loading @@ -60,6 +65,7 @@ my %opt = ( arrivals => $arrivals, developer_mode => $developer_mode, service => $service, language => $language, ); if ( $opt{station} =~ m{ ^ (?<lat> [0-9.]+ ) : (?<lon> [0-9].+ ) $ }x ) { Loading Loading @@ -369,11 +375,11 @@ hafas-m - Interface to the DeutscheBahn/HAFAS online departure monitor =head1 SYNOPSIS B<hafas-m> [B<-d> I<date>] [B<-t> I<time>] [B<-m> I<motlist>] [B<-s> I<service>] I<station> [B<-s> I<service>] [B<-l> I<language>] I<station> B<hafas-m> [B<-s> I<service>] B<?>I<query>|I<lat>B<:>I<lon> B<hafas-m> [B<-s> I<service>] I<journeyID> B<hafas-m> [B<-s> I<service>] [B<-l> I<language>] I<journeyID> =head1 VERSION Loading Loading @@ -442,6 +448,12 @@ Print result(s) as JSON. This is a dump of internal data structures and not guaranteed to remain stable between minor versions. Please use the Travel::Status::DE::HAFAS(3pm) module if you need a proper API. =item B<-l>, B<--language> I<language> Request free-text messages to be provided in I<language>. See B<--list> for a list of languages supported by individual HAFAS instances. Note that requesting an invalid/unsupported language may lead to garbage output. =item B<--list> List known HAFAS installations and exit. Use B<-s>|B<--service> to select an Loading
lib/Travel/Status/DE/HAFAS.pm +11 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ my %hafas_instance = ( name => 'Deutsche Bahn', productbits => [qw[ice ic_ec d regio s bus ferry u tram ondemand]], salt => 'bdI8UVj4' . '0K5fvxwf', languages => [qw[de en fr es]], request => { client => { id => 'DB', Loading Loading @@ -339,6 +340,10 @@ sub new { }; } if ( $conf{language} ) { $req->{lang} = $conf{language}; } $self->{strptime_obj} //= DateTime::Format::Strptime->new( pattern => '%Y%m%dT%H%M%S', time_zone => 'Europe/Berlin', Loading Loading @@ -986,6 +991,12 @@ If this option is set, only the modes of transport appearing in I<mot1>, I<mot2>, ... will be returned. The supported modes depend on B<service>, use B<get_services> or B<get_service> to get the supported values. =item B<language> => I<language> Request text messages to be provided in I<language>. Supported languages depend on B<service>, use B<get_services> or B<get_service> to get the supported values. Providing an unsupported or invalid value may lead to garbage output. =item B<lookahead> => I<int> (station) Request arrivals/departures that occur up to I<int> minutes after the specified datetime. Loading