From 1af26b2fdcfb9233503a1c0e630b41ced5864069 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 13 Jan 2021 20:32:29 +0100 Subject: remove bundled zugbildungsplan, use daily updates from dbdb instead --- lib/DBInfoscreen.pm | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index 3a429e7..acb741b 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -101,25 +101,31 @@ sub startup { $self->attr( ice_type_map => sub { - my $ice_type_map = JSON->new->utf8->decode( - scalar read_file('share/zugbildungsplan.json') ); - my $ret; - while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) { - if ( $v->{type} ) { - $ret->{$k} = [ - $v->{type}, $v->{shortType}, - exists $v->{wagons} ? 1 : 0 - ]; + if ( -r 'share/zugbildungsplan.json' ) { + my $ice_type_map = JSON->new->utf8->decode( + scalar read_file('share/zugbildungsplan.json') ); + my $ret; + while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) { + if ( $v->{type} ) { + $ret->{$k} = [ + $v->{type}, $v->{shortType}, + exists $v->{wagons} ? 1 : 0 + ]; + } } + return $ret; } - return $ret; + return {}; } ); $self->attr( train_details_db => sub { - return JSON->new->utf8->decode( - scalar read_file('share/zugbildungsplan.json') )->{train}; + if ( -r 'share/zugbildungsplan.json' ) { + return JSON->new->utf8->decode( + scalar read_file('share/zugbildungsplan.json') )->{train}; + } + return {}; } ); -- cgit v1.2.3