summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-show53
1 files changed, 27 insertions, 26 deletions
diff --git a/utils/rhrd-show b/utils/rhrd-show
index dad0800..d4646ba 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> <week>:<show-id> [ <week>:<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";
}
@@ -333,80 +333,81 @@ sub multi_list
}
-sub multi_add__check_shows
+sub multi_add__parse_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);
+ my %shows = ( 1 => 0, 2 => 0, 3 => 0, 4 => 0 );
+ foreach my $show (@_) {
+ 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;
+ print STDERR "'" . $show . "' is invalid, needs to have format <week>=<showid>\n";
+ return undef;
}
$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;
+ return undef;
}
- if($weeks{$week} != 0) {
- print STDERR "week " . $week . " is already set to show-id $weeks{$week}\n";
- return 1;
+ if($shows{$week} != 0) {
+ print STDERR "week " . $week . " is already set to show-id $shows{$week}\n";
+ return undef;
}
$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;
+ return undef;
}
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;
+ return undef;
}
(my $exists, my $status, $errorstring) = RHRD::rddb::check_show_exists($ctx, $show_id);
unless(defined $exists) {
print STDERR $status . ": " . $errorstring . "\n";
- return 1;
+ return undef;
}
if($exists != 1) {
print STDERR "show with id '" . $show_id . "' does not exist!\n";
- return 1;
+ return undef;
}
(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;
+ return undef;
}
- $weeks{$week} = $show_id;
+ $shows{$week} = $show_id;
- print "W$week: ($show_id) $title\n";
+ print " - W$week: ($show_id) $title\n";
}
- return 0;
+ return \%shows;
}
sub multi_add
{
my $ctx = shift;
my $title = shift;
- my @shows = @_;
- my $ret = multi_add__check_shows($ctx, @shows);
- if($ret) {
- return $ret;
+ print " * creating multi-show: " . $title . "\n";
+
+ my %shows = %{multi_add__parse_shows($ctx, @_)};
+ unless(%shows) {
+ return 1;
}
- my ($result, $status, $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, @shows);
+ my ($result, $status, $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, \%shows);
unless(defined $result) {
print STDERR $status . ": " . $errorstring . "\n";
return 1;
}
+ print " * finished\n";
+
return 0;
}