DBDB: only use apps-bahn wagon order API for now

This commit is contained in:
Daniel Friesel 2021-12-12 16:38:26 +01:00
parent a897144459
commit 2e5a1b0a79

View file

@ -30,7 +30,7 @@ sub has_wagonorder_p {
my ( $self, $ts, $train_no ) = @_; my ( $self, $ts, $train_no ) = @_;
my $api_ts = $ts->strftime('%Y%m%d%H%M'); my $api_ts = $ts->strftime('%Y%m%d%H%M');
my $url my $url
= "https://lib.finalrewind.org/dbdb/has_wagonorder/${train_no}/${api_ts}"; = "https://www.apps-bahn.de/wr/wagenreihung/1.0/${train_no}/${api_ts}";
my $cache = $self->{cache}; my $cache = $self->{cache};
my $promise = Mojo::Promise->new; my $promise = Mojo::Promise->new;
@ -43,14 +43,13 @@ sub has_wagonorder_p {
} }
} }
$self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} ) $self->{user_agent}->request_timeout(5)->head_p( $url => $self->{header} )
->then( ->then(
sub { sub {
my ($tx) = @_; my ($tx) = @_;
if ( $tx->result->is_success ) { if ( $tx->result->is_success ) {
my $body = $tx->result->body; $cache->set( $url, 'a' );
$cache->set( $url, $body ); $promise->resolve('a');
$promise->resolve($body);
} }
else { else {
$cache->set( $url, 'n' ); $cache->set( $url, 'n' );