summaryrefslogtreecommitdiff
path: root/bin/db-ris
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-06 16:21:28 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-06 16:21:28 +0200
commit6bbdc021707352f6655df14076edd29241ff8581 (patch)
tree7f96110676ee74e40027acbe316b8828fe4a4932 /bin/db-ris
parent999b777f890b3d101829cbd98985e1a7a5c2d5d9 (diff)
db-ris: Add option to ignore delayed trains
Diffstat (limited to 'bin/db-ris')
-rwxr-xr-xbin/db-ris26
1 files changed, 18 insertions, 8 deletions
diff --git a/bin/db-ris b/bin/db-ris
index bffe532..0d27e89 100755
--- a/bin/db-ris
+++ b/bin/db-ris
@@ -9,21 +9,25 @@ use Getopt::Long qw(:config no_ignore_case);
use List::Util qw(first max);
use Travel::Status::DE::DeutscheBahn;
-my ( $date, $time );
-my $types = q{};
my %train_type;
+
+my ( $date, $time );
my $filter_via;
+my $ignore_late = 0;
+my $types = q{};
+
my @output;
binmode( STDOUT, ':encoding(utf-8)' );
GetOptions(
- 'd|date=s' => \$date,
- 'h|help' => sub { show_help(0) },
- 'm|mot=s' => \$types,
- 't|time=s' => \$time,
- 'v|via=s' => \$filter_via,
- 'V|version' => \&show_version,
+ 'd|date=s' => \$date,
+ 'h|help' => sub { show_help(0) },
+ 'L|ignore-late' => \$ignore_late,
+ 'm|mot=s' => \$types,
+ 't|time=s' => \$time,
+ 'v|via=s' => \$filter_via,
+ 'V|version' => \&show_version,
) or show_help(1);
@@ -132,12 +136,18 @@ for my $d ( $status->results() ) {
my ( @via, @via_main, @via_show );
+ my $re_late = qr{ (?: ^ | , ) ca[.] \s \d+ \s Minuten \s sp.ter}ox;
+
@via = $d->route;
if ( $filter_via and not( first { $_ =~ m{$filter_via}io } @via ) ) {
next;
}
+ if ( $ignore_late and $d->info =~ $re_late ) {
+ next;
+ }
+
push(
@output,
[