diff options
-rwxr-xr-x | lib/RHRD/rddb.pm | 10 | ||||
-rwxr-xr-x | utils/rhrd-schedules | 12 | ||||
-rwxr-xr-x | utils/rhrd-show | 64 |
3 files changed, 81 insertions, 5 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 62f43bd..38abb1d 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -149,6 +149,12 @@ sub get_cart_range return ($low_cart, $high_cart, $chunk_size); } +sub get_showid_range +{ + my ($ctx) = @_; + return get_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'shows'}) +} + sub get_next_free_slot { my ($ctx, $groupname) = @_; @@ -1984,7 +1990,7 @@ sub list_multi_shows my $entry = {}; $entry->{'ID'} = $id; $entry->{'TITLE'} = $title; - $entry->{'SHOWS'} = @showlist; + $entry->{'SHOWS'} = \@showlist; push @mshows, $entry; } @@ -2024,7 +2030,7 @@ sub create_multi_show { my $ctx = shift; my $title = shift; - my $shows = join(@_, ";"); + my $shows = join(";", @_); my ($number, $status, $errorstring) = get_next_free_multi_showid($ctx); unless (defined $number) { diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules index 92dc9be..aab258f 100755 --- a/utils/rhrd-schedules +++ b/utils/rhrd-schedules @@ -63,7 +63,17 @@ sub generate $errcnt++; next; } - my ($exists, $status, $errorstring) = RHRD::rddb::check_show_exists($ctx, $showid); + my ($showid_min, $showid_max, $errorstring) = RHRD::rddb::get_showid_range($ctx); + unless(defined $showid_min) { + print "$showid_max: $errorstring\n"; + return 1; + } + if ($showid < $showid_min || $showid > $showid_max) { + print "WARNING: skipping entry whith out of range automation id ($showid) -> $start: $title ($pvid)\n"; + next; + } + + (my $exists, my $status, $errorstring) = RHRD::rddb::check_show_exists($ctx, $showid); unless(defined $exists) { print "$status: $errorstring\n"; return 1; diff --git a/utils/rhrd-show b/utils/rhrd-show index 0c87c1e..950e898 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -38,7 +38,7 @@ sub print_usage " multi show handling:\n" . " rhrd-show multi-list\n" . " rhrd-show (multi-show|multi-remove) <multi-show-id>\n" . - " rhrd-show (multi-add) <title> <show-id> [ <show-id> [ .. ] ]\n" . + " rhrd-show (multi-add) <title> <week>:<show-id> [ <week>:<show-id> [ .. ] ]\n" . " rhrd-show (multi-add-id|multi-remove-id) <multi-show-id> <show-id> [ <show-id> [ .. ] ]\n"; } @@ -332,13 +332,73 @@ sub multi_list } +sub multi_add__check_shows +{ + my $ctx = shift; + my @shows = @_; + + my %weeks = ( 1 => 0, 2 => 0, 3 => 0, 4 => 0 ); + + foreach my $show (@shows) { + my ($week, $show_id) = split(':', $show, 2); + unless(defined $week && defined $show_id) { + print STDERR "'" . $show . "' is invalid, needs to have format <week>:<showid>\n"; + return 1; + } + + $week = int($week); + if($week < 1 || $week > 4) { + print STDERR "week '" . $week . "' is out of range (needs to be 1,2,3 or 4)\n"; + return 1; + } + if($weeks{$week} != 0) { + print STDERR "week " . $week . " is already set to show-id $weeks{$week}\n"; + return 1; + } + + $show_id = int($show_id); + my ($show_id_min, $show_id_max, $errorstring) = RHRD::rddb::get_showid_range($ctx); + unless(defined $show_id_min) { + print STDERR $show_id_max . ": " . $errorstring . "\n"; + return 1; + } + if ($show_id < $show_id_min || $show_id > $show_id_max) { + print STDERR "show-id '" . $show_id . "' is out of range (min: $show_id_min, max: $show_id_max)\n"; + return 1; + } + (my $exists, my $status, $errorstring) = RHRD::rddb::check_show_exists($ctx, $show_id); + unless(defined $exists) { + print STDERR $status . ": " . $errorstring . "\n"; + return 1; + } + if($exists != 1) { + print STDERR "show with id '" . $show_id . "' does not exist!\n"; + return 1; + } + + (my $title, undef, $status, $errorstring) = RHRD::rddb::get_show_title_and_log($ctx, $show_id); + unless(defined $title) { + print STDERR $status . ": " . $errorstring . "\n"; + return 1; + } + $weeks{$week} = $show_id; + + print "W$week: ($show_id) $title\n"; + } + + return 0; +} + sub multi_add { my $ctx = shift; my $title = shift; my @shows = @_; - ## TODO check shows: needs to have format <week>:<showid> + my $ret = multi_add__check_shows($ctx, @shows); + if($ret) { + return $ret; + } my ($result, $status, $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, @shows); unless(defined $result) { |