summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Helper
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2023-01-29 17:40:27 +0100
committerDaniel Friesel <derf@finalrewind.org>2023-01-29 17:40:27 +0100
commit6526ae6a64c14f9d64a791b778b157f502a5aa0a (patch)
tree1d31b11010b2e3ae8d6f0fdc24315888cefbf692 /lib/DBInfoscreen/Helper
parenta32109701fc567defbd6673e9cdf6bdf10b83ec7 (diff)
add hafas (bus, ubahn, tram) support
Diffstat (limited to 'lib/DBInfoscreen/Helper')
-rw-r--r--lib/DBInfoscreen/Helper/HAFAS.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm
index a6769aa..6111a5b 100644
--- a/lib/DBInfoscreen/Helper/HAFAS.pm
+++ b/lib/DBInfoscreen/Helper/HAFAS.pm
@@ -181,7 +181,19 @@ sub get_route_timestamps_p {
my $promise = Mojo::Promise->new;
my $now = DateTime->now( time_zone => 'Europe/Berlin' );
- if ( $opt{train} ) {
+ my $hafas_promise;
+
+ if ( $opt{trip_id} ) {
+ $hafas_promise = Travel::Status::DE::HAFAS->new_p(
+ journey => {
+ id => $opt{trip_id},
+ },
+ cache => $self->{realtime_cache},
+ promise => 'Mojo::Promise',
+ user_agent => $self->{user_agent}->request_timeout(10)
+ );
+ }
+ elsif ( $opt{train} ) {
$opt{date_yy} = $opt{train}->start->strftime('%d.%m.%y');
$opt{date_yyyy} = $opt{train}->start->strftime('%d.%m.%Y');
$opt{train_req} = $opt{train}->type . ' ' . $opt{train}->train_no;
@@ -193,7 +205,7 @@ sub get_route_timestamps_p {
$opt{date_yyyy} = $now->strftime('%d.%m.%Y');
}
- $self->trainsearch_p(%opt)->then(
+ $hafas_promise //= $self->trainsearch_p(%opt)->then(
sub {
my ($trainsearch_result) = @_;
my $trip_id = $trainsearch_result->{trip_id};
@@ -208,7 +220,9 @@ sub get_route_timestamps_p {
user_agent => $self->{user_agent}->request_timeout(10)
);
}
- )->then(
+ );
+
+ $hafas_promise->then(
sub {
my ($hafas) = @_;
my $journey = $hafas->result;