From ffe5fd7570f5626198ee86ca3c9e21301faa4d2b Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 28 Dec 2023 07:34:33 +0100 Subject: Helper/HAFAS: Remove now-unused get_json_p function --- lib/DBInfoscreen/Helper/HAFAS.pm | 57 ---------------------------------------- 1 file changed, 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 ) = @_; -- cgit v1.2.3