summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Helper
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-08 18:07:01 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-08 18:07:01 +0200
commit8f657f59c7c306040f39057c02f705bb4a0c3158 (patch)
treea104fe056121c1c2bb2f1d509719dc478e7508c5 /lib/DBInfoscreen/Helper
parent44cdac57eed0f02c8801ed85d08be4e7daead991 (diff)
always calculate tripid via trainsearch.exe
Diffstat (limited to 'lib/DBInfoscreen/Helper')
-rw-r--r--lib/DBInfoscreen/Helper/HAFAS.pm68
1 files changed, 1 insertions, 67 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm
index 2eb156c..c4f0883 100644
--- a/lib/DBInfoscreen/Helper/HAFAS.pm
+++ b/lib/DBInfoscreen/Helper/HAFAS.pm
@@ -24,31 +24,6 @@ sub new {
}
-sub hafas_rest_req {
- my ( $self, $cache, $url ) = @_;
-
- if ( my $content = $cache->thaw($url) ) {
- return $content;
- }
-
- my $res
- = eval { $self->{user_agent}->get( $url => $self->{header} )->result; };
-
- if ($@) {
- $self->{log}->debug("hafas_rest_req($url): $@");
- return;
- }
- if ( $res->is_error ) {
- return;
- }
-
- my $json = decode_json( $res->body );
-
- $cache->freeze( $url, $json );
-
- return $json;
-}
-
sub hafas_json_req {
my ( $self, $cache, $url ) = @_;
@@ -282,48 +257,7 @@ sub get_route_timestamps {
}
}
- return ( $ret, $traindelay // {} );
-}
-
-sub get_tripid {
- my ( $self, $train ) = @_;
-
- my $cache = $self->{main_cache};
- my $eva = $train->station_uic;
-
- my $dep_ts = DateTime->now( time_zone => 'Europe/Berlin' );
- my $url
- = "https://2.db.transport.rest/stations/${eva}/departures?duration=5&when=$dep_ts";
-
- if ( $train->sched_departure ) {
- $dep_ts = $train->sched_departure->epoch;
- $url
- = "https://2.db.transport.rest/stations/${eva}/departures?duration=5&when=$dep_ts";
- }
- elsif ( $train->sched_arrival ) {
- $dep_ts = $train->sched_arrival->epoch;
- $url
- = "https://2.db.transport.rest/stations/${eva}/arrivals?duration=5&when=$dep_ts";
- }
-
- my $json = $self->hafas_rest_req( $cache, $url );
-
- #say "looking for " . $train->train_no . " in $url";
- for my $result ( @{ $json // [] } ) {
- my $trip_id = $result->{tripId};
- my $fahrt = $result->{line}{fahrtNr};
-
- #say "checking $fahrt";
- if ( $result->{line} and $result->{line}{fahrtNr} == $train->train_no )
- {
- #say "Trip ID is $trip_id";
- return $trip_id;
- }
- else {
- #say "unmatched Trip ID $trip_id";
- }
- }
- return;
+ return ( $ret, $traindelay // {}, $trainsearch_result );
}
# Input: (HAFAS TripID, line number)