summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-10 10:41:32 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-10 10:41:32 +0200
commit2f8567d38b418dba31111e6886b2558548790496 (patch)
treec0de62f8c2b513eb66394e95af630f498a132510 /lib
parent0ebd8e6bb379dba71239050ee643ff78058a95e5 (diff)
add -s/-u support
Diffstat (limited to 'lib')
-rw-r--r--lib/Travel/Status/DE/HAFAS.pm20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm
index fe8cf2e..6589359 100644
--- a/lib/Travel/Status/DE/HAFAS.pm
+++ b/lib/Travel/Status/DE/HAFAS.pm
@@ -27,9 +27,9 @@ sub new {
my $date = $conf{date} // strftime( '%d.%m.%Y', localtime(time) );
my $time = $conf{time} // strftime( '%H:%M', localtime(time) );
- my $lang = $conf{language} // 'd';
- my $mode = $conf{mode} // 'dep';
- my $service = $conf{service} // 'DB';
+ my $lang = $conf{language} // 'd';
+ my $mode = $conf{mode} // 'dep';
+ my $service = $conf{service};
my %lwp_options = %{ $conf{lwp_options} // { timeout => 10 } };
@@ -43,6 +43,10 @@ sub new {
confess('You need to specify a station');
}
+ if ( not defined $service and not defined $conf{url} ) {
+ $service = 'DB';
+ }
+
my $ref = {
active_service => $service,
developer_mode => $conf{developer_mode},
@@ -60,7 +64,7 @@ sub new {
$ref->set_productfilter;
- my $url = $hafas_instance{$service}{url} . '/' . $lang . 'n';
+ my $url = ( $conf{url} // $hafas_instance{$service}{url} ) . "/${lang}n";
$reply = $ua->post( $url, $ref->{post} );
@@ -100,8 +104,10 @@ sub set_productfilter {
my $service = $self->{active_service};
- $self->{post}{productsFilter}
- = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );
+ if ($service) {
+ $self->{post}{productsFilter}
+ = '1' x ( scalar @{ $hafas_instance{$service}{productbits} } );
+ }
}
sub check_input_error {
@@ -207,7 +213,7 @@ sub get_services {
sub get_service {
my ($self) = @_;
- return %{ $hafas_instance{ $self->active_service } };
+ return %{ $hafas_instance{ $self->{active_service} } };
}
1;