summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa-m33
1 files changed, 19 insertions, 14 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 3367a2f..3dc1ca8 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -4,7 +4,7 @@ use warnings;
use 5.010;
use utf8;
-our $VERSION = '3.09';
+our $VERSION = '3.18';
binmode( STDOUT, ':encoding(utf-8)' );
@@ -16,7 +16,6 @@ use Travel::Status::DE::EFA;
my $service = 'VRR';
my $efa_url;
-my $efa_encoding;
my $use_cache = 1;
my $cache;
my ( $json_output, $raw_json_output );
@@ -99,12 +98,15 @@ if ($use_cache) {
my ( $place, $input, $coord, $stopseq, $stopfinder );
if ( @ARGV == 1 ) {
- if ( $ARGV[0] =~ m{ ^ ([^@]*) @ ([^@]*) [(] ([^)]*) [)] (.*) $ }x ) {
+ if ( $ARGV[0]
+ =~ m{ ^ ([^@]*) @ ([^@]*) [(] ([^T]*) T ([^)]*) [)] (.*) $ }x )
+ {
$stopseq = {
stateless => $1,
stop_id => $2,
date => $3,
- key => $4
+ time => $4,
+ key => $5
};
}
elsif ( $ARGV[0] =~ m{ ^ [?] (?<name> .*) $ }x ) {
@@ -156,8 +158,7 @@ elsif ($service) {
);
exit 1;
}
- $efa_encoding = $service_ref->{encoding};
- $efa_url = undef;
+ $efa_url = undef;
}
sub new_efa {
@@ -168,7 +169,6 @@ sub new_efa {
cache => $cache,
date => $date,
developer_mode => $developer_mode,
- efa_encoding => $efa_encoding,
full_routes => $full_routes,
place => $place,
name => $input,
@@ -353,6 +353,7 @@ sub show_stopseq {
);
say q{};
+ my $occupancy_len = 0;
my $delay_len = 0;
my $inner_delay_len = 0;
my $max_delay = max map { abs( $_->delay // 0 ) } $trip->route;
@@ -360,6 +361,9 @@ sub show_stopseq {
$inner_delay_len = length($max_delay) + 1;
$delay_len = length( sprintf( '(%+d)', $max_delay ) ) + 1;
}
+ if ( first { $_->occupancy } $trip->route ) {
+ $occupancy_len = 2;
+ }
if ( first { $_->is_cancelled } $trip->route and $delay_len < 3 ) {
$delay_len = 3;
@@ -367,7 +371,7 @@ sub show_stopseq {
for my $stop ( $trip->route ) {
printf(
- "%s → %s%${delay_len}s %s (%s) %s\n",
+ "%s → %s%${delay_len}s %-${occupancy_len}s%s (%s) %s\n",
$stop->arr ? $stop->arr->strftime('%H:%M')
: q{ },
$stop->dep ? $stop->dep->strftime('%H:%M')
@@ -378,9 +382,10 @@ sub show_stopseq {
? sprintf( " (%+${inner_delay_len}d)", $stop->delay )
: q{}
),
+ $stop->occupancy ? format_occupancy( $stop->occupancy ) : q{},
$stop->full_name,
- $stop->niveau,
- $stop->platform
+ $stop->niveau // q{?},
+ $stop->platform // q{}
);
}
}
@@ -585,14 +590,14 @@ if ( my $err = $efa->errstr ) {
if ($json_output) {
if ($stopseq) {
- say JSON->new->convert_blessed->encode( $efa->result );
+ say JSON->new->canonical->convert_blessed->encode( $efa->result );
}
else {
- say JSON->new->convert_blessed->encode( [ $efa->results ] );
+ say JSON->new->canonical->convert_blessed->encode( [ $efa->results ] );
}
}
elsif ($raw_json_output) {
- say JSON->new->convert_blessed->encode( $efa->{response} );
+ say JSON->new->canonical->convert_blessed->encode( $efa->{response} );
}
elsif ($coord) {
show_coord();
@@ -628,7 +633,7 @@ B<efa-m> [B<-s> I<service>] I<tripid>
=head1 VERSION
-version 3.09
+version 3.18
=head1 DESCRIPTION