Loading share/xml2json +34 −7 Original line number Diff line number Diff line Loading @@ -11,6 +11,11 @@ use XML::LibXML; # old / new / renamed / reappeared / missing my $mode = shift; my $extra = shift // q{}; if ( $extra eq 'if-active' ) { use Travel::Status::DE::IRIS; } my $json = JSON->new->utf8; my $json_str = read_file('stations.json'); Loading Loading @@ -109,6 +114,21 @@ sub delete_old_station { } @{$old_stations}; } sub has_departures { my ($eva) = @_; my $status = Travel::Status::DE::IRIS->new( station => $eva, lookbehind => 120, lookahead => 240 ); if ( $status->results ) { return 1; } return; } # TODO falls ein eintrag aus old_stations im XML auftaucht sollte er aus old_stations raus und wieder in stations rein if ( -e 'missing.txt' ) { Loading Loading @@ -205,16 +225,23 @@ for my $station ( $tree->findnodes('//station') ) { { printf( "%30s has re-appeared as %s %d\n", $name, $ds100, $eva ); if ( not $mode or $mode eq 'reappeared' ) { if ( $extra ne 'if-active' or has_departures($eva) ) { if ( ref($old) eq 'ARRAY' ) { for my $o ( @{$old} ) { delete_old_station( $o->{name}, $o->{ds100}, $o->{eva} ); delete_old_station( $o->{name}, $o->{ds100}, $o->{eva} ); } } else { delete_old_station( $old->{name}, $old->{ds100}, $old->{eva} ); delete_old_station( $old->{name}, $old->{ds100}, $old->{eva} ); } add_station( $name, $ds100, $eva ); } if ( $extra eq 'if-active' ) { sleep(1); } } } if ( not $found Loading Loading
share/xml2json +34 −7 Original line number Diff line number Diff line Loading @@ -11,6 +11,11 @@ use XML::LibXML; # old / new / renamed / reappeared / missing my $mode = shift; my $extra = shift // q{}; if ( $extra eq 'if-active' ) { use Travel::Status::DE::IRIS; } my $json = JSON->new->utf8; my $json_str = read_file('stations.json'); Loading Loading @@ -109,6 +114,21 @@ sub delete_old_station { } @{$old_stations}; } sub has_departures { my ($eva) = @_; my $status = Travel::Status::DE::IRIS->new( station => $eva, lookbehind => 120, lookahead => 240 ); if ( $status->results ) { return 1; } return; } # TODO falls ein eintrag aus old_stations im XML auftaucht sollte er aus old_stations raus und wieder in stations rein if ( -e 'missing.txt' ) { Loading Loading @@ -205,16 +225,23 @@ for my $station ( $tree->findnodes('//station') ) { { printf( "%30s has re-appeared as %s %d\n", $name, $ds100, $eva ); if ( not $mode or $mode eq 'reappeared' ) { if ( $extra ne 'if-active' or has_departures($eva) ) { if ( ref($old) eq 'ARRAY' ) { for my $o ( @{$old} ) { delete_old_station( $o->{name}, $o->{ds100}, $o->{eva} ); delete_old_station( $o->{name}, $o->{ds100}, $o->{eva} ); } } else { delete_old_station( $old->{name}, $old->{ds100}, $old->{eva} ); delete_old_station( $old->{name}, $old->{ds100}, $old->{eva} ); } add_station( $name, $ds100, $eva ); } if ( $extra eq 'if-active' ) { sleep(1); } } } if ( not $found Loading