diff options
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/rhrd-show | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/utils/rhrd-show b/utils/rhrd-show index c52d63d..0c87c1e 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -21,17 +21,25 @@ # use strict; +use lib "../lib/"; use RHRD::rddb; use RHRD::utils; use Date::Calc; +use Data::Dumper::Simple; + sub print_usage { print STDERR "Usage: rhrd-show list [ <group> ]\n" . " rhrd-show search <expression>\n" . " rhrd-show (show|remove) <show-id>\n" . " rhrd-show add <groupname> <name> <title> <num-carts> <rhythm> <dow> <starttime> <len>\n" . - " rhrd-show edit <show-id> <title> <rhythm> <dow> <starttime> <len>\n"; + " rhrd-show edit <show-id> <title> <rhythm> <dow> <starttime> <len>\n" . + " 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-id|multi-remove-id) <multi-show-id> <show-id> [ <show-id> [ .. ] ]\n"; } sub list @@ -306,6 +314,43 @@ sub remove return 0; } +sub multi_list +{ + my ($ctx) = @_; + + my @mshows = RHRD::rddb::list_multi_shows($ctx); + if(!defined $mshows[0] && defined $mshows[1]) { + print STDERR "$mshows[1]: $mshows[2]"; + return 1; + } + my @sorted = sort { lc($a->{'TITLE'}) cmp lc($b->{'TITLE'}) } @mshows; + for my $href (@sorted) { + print $href->{'ID'} . ": " . Dumper($href) . "\n"; +# print $href->{'ID'} . ": " . $href->{'TITLE'} . ": (" . join(@$href->{'SHOWS'}, ", ") . ")\n"; + } + return 0; +} + + +sub multi_add +{ + my $ctx = shift; + my $title = shift; + my @shows = @_; + + ## TODO check shows: needs to have format <week>:<showid> + + my ($result, $status, $errorstring) = RHRD::rddb::create_multi_show($ctx, $title, @shows); + unless(defined $result) { + print STDERR $status . ": " . $errorstring . "\n"; + return 1; + } + + return 0; +} + + + my $num_args = $#ARGV + 1; if($num_args < 1) { print_usage(); @@ -364,6 +409,24 @@ if(defined $ctx) { $ret = edit($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6]); } } + elsif($cmd eq "multi-list") { + if($num_args != 1) { + print_usage(); + $ret = 1; + } else { + $ret = multi_list($ctx) + } + } + elsif($cmd eq "multi-add") { + if($num_args < 3) { + print_usage(); + $ret = 1; + } else { + shift @ARGV; + my $title = shift @ARGV; + $ret = multi_add($ctx, $title, @ARGV) + } + } else { print_usage(); $ret = 1; |