diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-12-28 07:34:33 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-12-28 07:34:33 +0100 |
commit | ffe5fd7570f5626198ee86ca3c9e21301faa4d2b (patch) | |
tree | 02c0a69f444626c724a73b081e9712a4a5e10e15 | |
parent | 5452677f38fcd596776a3dd4fc04edd4d1e56eaa (diff) |
Helper/HAFAS: Remove now-unused get_json_p function
-rw-r--r-- | lib/DBInfoscreen/Helper/HAFAS.pm | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 3a74ea9..5b8870d 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -29,63 +29,6 @@ sub new { } -sub get_json_p { - my ( $self, $cache, $url ) = @_; - - my $promise = Mojo::Promise->new; - - if ( my $content = $cache->thaw($url) ) { - return $promise->resolve($content); - } - - $self->{log}->debug("get_json_p($url)"); - - $self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} ) - ->then( - sub { - my ($tx) = @_; - - if ( my $err = $tx->error ) { - $self->{log}->warn( - "hafas->get_json_p($url): HTTP $err->{code} $err->{message}" - ); - $promise->reject( - "GET $url returned HTTP $err->{code} $err->{message}"); - return; - } - my $body - = encode( 'utf-8', decode( 'ISO-8859-15', $tx->res->body ) ); - - $body =~ s{^TSLs[.]sls = }{}; - $body =~ s{;$}{}; - $body =~ s{(}{(}g; - $body =~ s{)}{)}g; - - my $json = decode_json($body); - - if ( not $json ) { - $self->{log}->debug("hafas->get_json_p($url): empty response"); - $promise->reject("GET $url returned empty response"); - return; - } - - $cache->freeze( $url, $json ); - - $promise->resolve($json); - return; - } - )->catch( - sub { - my ($err) = @_; - $self->{log}->warn("hafas->get_json_p($url): $err"); - $promise->reject($err); - return; - } - )->wait; - - return $promise; -} - sub get_route_timestamps_p { my ( $self, %opt ) = @_; |