summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-14 14:54:54 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-14 14:54:54 (GMT)
commit0966b894742c543b0a6a8ecb854dcaaea6813e15 (patch)
tree3ee713494cc6aef4e11484ba32349e3d2a1f196d /utils
parent20ff694433ef9f658cc58da64484f008f95545da (diff)
adding multi-show works now
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-schedules12
-rwxr-xr-xutils/rhrd-show64
2 files changed, 73 insertions, 3 deletions
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) {