summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/RHRD/rddb.pm14
-rwxr-xr-xlib/RHRD/utils.pm29
-rwxr-xr-xtest/get-dropboxes1
-rwxr-xr-xutils/rhrd-schedules1
-rwxr-xr-xutils/rhrd-show48
5 files changed, 70 insertions, 23 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index f89682a..e9f79ef 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -1237,6 +1237,8 @@ sub get_dropboxes
$entry->{'SHOWSTARTTIME'} = '????' unless((RHRD::utils::dropbox_param_starttime_ok($entry->{'SHOWSTARTTIME'}))[0]);
$entry->{'SHOWLEN'} = $p[4];
$entry->{'SHOWLEN'} = 0 unless((RHRD::utils::dropbox_param_len_ok($entry->{'SHOWLEN'}))[0]);
+ $entry->{'SHOWTYPE'} = $p[5];
+ $entry->{'SHOWTYPE'} = 'n' unless((RHRD::utils::dropbox_param_showtype_ok($entry->{'SHOWTYPE'}))[0]);
} elsif(defined($p[0]) && $p[0] eq "J") {
$entry->{'TYPE'} = 'jingle';
$entry->{'JINGLETITLE'} = $groupdesc;
@@ -1452,6 +1454,8 @@ sub list_shows
substr($p[3], 2, 0) = ':';
$entry->{'STARTTIME'} = $p[3];
$entry->{'LEN'} = int $p[4];
+ $entry->{'TYPE'} = 'n';
+ $entry->{'TYPE'} = $p[5] if(defined($p[5]));
push @show_dbs, $entry;
}
@@ -1712,6 +1716,8 @@ sub get_show_info
substr($p[3], 2, 0) = ':';
$entry->{'STARTTIME'} = $p[3];
$entry->{'LEN'} = int $p[4];
+ $entry->{'TYPE'} = 'n';
+ $entry->{'TYPE'} = $p[5] if(defined($p[5]));
return ($entry, 'OK', 'success');
}
@@ -1920,8 +1926,8 @@ sub create_show_macro_cart
sub create_show_dropbox
{
- my ($ctx, $groupname, $showid, $rhythm, $dow, $starttime, $len) = @_;
- my $param = join(';', ('S', $rhythm, $dow, $starttime, $len));
+ my ($ctx, $groupname, $showid, $rhythm, $dow, $starttime, $len, $type) = @_;
+ my $param = join(';', ('S', $rhythm, $dow, $starttime, $len, $type));
my $sql = qq{insert into DROPBOXES (STATION_NAME, GROUP_NAME, NORMALIZATION_LEVEL, AUTOTRIM_LEVEL, TO_CART, FIX_BROKEN_FORMATS, SET_USER_DEFINED) values (?, ?, ?, ?, ?, 'Y', ?)};
@@ -1938,8 +1944,8 @@ sub create_show_dropbox
sub update_show_dropbox
{
- my ($ctx, $showid, $rhythm, $dow, $starttime, $len) = @_;
- my $param = join(';', ('S', $rhythm, $dow, $starttime, $len));
+ my ($ctx, $showid, $rhythm, $dow, $starttime, $len, $type) = @_;
+ my $param = join(';', ('S', $rhythm, $dow, $starttime, $len, $type));
my $sql = qq{update DROPBOXES set SET_USER_DEFINED = ? where TO_CART = ?};
diff --git a/lib/RHRD/utils.pm b/lib/RHRD/utils.pm
index 63e51c4..834f9fa 100755
--- a/lib/RHRD/utils.pm
+++ b/lib/RHRD/utils.pm
@@ -69,6 +69,7 @@ use constant {
DB_PARAM_DOW_HINT => "must be between 1 and 7 (1=Monday, ..., 7=Sunday)",
DB_PARAM_STARTTIME_HINT => "must be in format HHMM (without seperator) in 24 hour format",
DB_PARAM_LEN_HINT => "must be a positive number below 1440",
+ DB_PARAM_SHOWTYPE_HINT => "only n, r and s are allowed with n -> normal, r -> re-run, s -> special",
CMDLINE_WEEK_HINT => "must be one of W1, W2, W3, W4",
CMDLINE_DOW_HINT => "must be one of MO, TU, WE, TH, FR, SA, SU",
@@ -103,8 +104,8 @@ sub dropbox_param_type_ok
{
my ($type) = @_;
- unless(defined($type) && ($type == 'S' || $type == 'M' || $type == 'J')) {
- return (0, "unkown type '" . (defined($type) ? $type : 'undef') . "'", DB_PARAM_TYPE_HINT);
+ unless(defined($type) && ($type eq 'S' || $type eq 'M' || $type eq 'J')) {
+ return (0, "unknown type '" . (defined($type) ? $type : 'undef') . "'", DB_PARAM_TYPE_HINT);
}
return (1, 'OK', DB_PARAM_TYPE_HINT);
}
@@ -149,6 +150,30 @@ sub dropbox_param_len_ok
return (1, 'OK', DB_PARAM_LEN_HINT);
}
+sub dropbox_param_showtype_ok
+{
+ my ($type) = @_;
+
+ unless(defined($type) && ($type eq 'n' || $type eq 'r' || $type eq 's')) {
+ return (0, "unknown show-type '" . (defined($type) ? $type : 'undef') . "'", DB_PARAM_SHOWTYPE_HINT);
+ }
+ return (1, 'OK', DB_PARAM_SHOWTYPE_HINT);
+}
+
+sub dropbox_param_showtype_to_string
+{
+ my ($type) = @_;
+
+ if($type eq 'n') {
+ return "regular";
+ } elsif($type eq 'r') {
+ return "re-run";
+ } elsif($type eq 's') {
+ return "special";
+ }
+ return "invalid show-type!";
+}
+
sub cmdline_rdweek
{
my ($dow) = @_;
diff --git a/test/get-dropboxes b/test/get-dropboxes
index 1b7bc0e..d7fc6e5 100755
--- a/test/get-dropboxes
+++ b/test/get-dropboxes
@@ -67,6 +67,7 @@ for my $href (@dropboxes) {
print " show-dayofweek:" . $href->{'SHOWDOW'} . "\n";
print " show-starttime:" . $href->{'SHOWSTARTTIME'} . "\n";
print " show-length:" . $href->{'SHOWLEN'} . "\n";
+ print " show-type:" . $href->{'SHOWTYPE'} . "\n";
} elsif($href->{'TYPE'} eq "jingle") {
print " jingle-title:" . $href->{'JINGLETITLE'} . "\n";
} elsif($href->{'TYPE'} eq "musicpool") {
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules
index b198a9e..26a2552 100755
--- a/utils/rhrd-schedules
+++ b/utils/rhrd-schedules
@@ -141,6 +141,7 @@ sub show__day_entry
{
my ($ctx, $week, $dow, $duration, $start_short, $pvid, $showid, $title) = @_;
+ ## TODO: handle `$show{'TYPE'}` (regular, re-run, and special)
my ($show, $status, $errorstring) = RHRD::rddb::get_show_info($ctx, $showid);
if(!defined $show) {
print "$status: $errorstring\n";
diff --git a/utils/rhrd-show b/utils/rhrd-show
index 97d74d3..8bdc4cf 100755
--- a/utils/rhrd-show
+++ b/utils/rhrd-show
@@ -31,8 +31,8 @@ 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 add <groupname> <name> <title> <num-carts> <rhythm> <dow> <starttime> <len> <type>\n" .
+ " rhrd-show edit <show-id> <title> <rhythm> <dow> <starttime> <len> <type>\n" .
"\n" .
" multi show handling:\n" .
" rhrd-show multi-list\n" .
@@ -71,8 +71,9 @@ sub search
next unless $show->{'TITLE'} =~ /$searchexp/i;
$show->{'DOW'} = 7 if $show->{'DOW'} == 0;
+ my $showtype = RHRD::utils::dropbox_param_showtype_to_string($show->{'TYPE'});
print $show->{'ID'} . ": " . $show->{'TITLE'} . ", ";
- print join(", ", $show->{'RHYTHM'}, Date::Calc::Day_of_Week_to_Text($show->{'DOW'}), $show->{'STARTTIME'}, ($show->{'LEN'} . " min"));
+ print join(", ", $show->{'RHYTHM'}, Date::Calc::Day_of_Week_to_Text($show->{'DOW'}), $show->{'STARTTIME'}, ($show->{'LEN'} . " min"), $showtype);
print ", group: " . $show->{'GROUP'} . "\n";
}
return 0;
@@ -93,15 +94,16 @@ sub show
return 1;
}
$show->{'DOW'} = 7 if $show->{'DOW'} == 0;
- print $show->{'TITLE'} . ": " . join(", ", $show->{'RHYTHM'}, Date::Calc::Day_of_Week_to_Text($show->{'DOW'}), $show->{'STARTTIME'}, ($show->{'LEN'} . " min")) . "\n";
- print " group: " . $show->{'GROUP'} . ", carts(" . scalar(@carts) . "): " . join(", ", @carts) . " \n";
+ my $showtype = RHRD::utils::dropbox_param_showtype_to_string($show->{'TYPE'});
+ print $show->{'TITLE'} . ": " . join(", ", $show->{'RHYTHM'}, Date::Calc::Day_of_Week_to_Text($show->{'DOW'}), $show->{'STARTTIME'}, ($show->{'LEN'} . " min"), $showtype) . "\n";
+ print " group: " . $show->{'GROUP'} . ", carts(" . scalar(@carts) . "): " . join(", ", @carts) . "\n";
return 0;
}
sub add__check_arguments
{
- my ($groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_;
+ my ($groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len, $type) = @_;
if($groupname !~ m/^[-a-zA-Z0-9_]{1,10}$/) {
print STDERR "name '" . $groupname . "' contains illegal characters or is too long/short\n";
@@ -144,14 +146,20 @@ sub add__check_arguments
return 1;
}
+ ($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type);
+ unless($result) {
+ print STDERR $err . "\n " . $hint . "\n";
+ return 1;
+ }
+
return 0;
}
sub add
{
- my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len) = @_;
+ my ($ctx, $groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len, $type) = @_;
- my $ret = add__check_arguments($groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len);
+ my $ret = add__check_arguments($groupname, $name, $title, $num_carts, $rhythm, $dow, $starttime, $len, $type);
if($ret) {
return $ret;
}
@@ -195,7 +203,7 @@ sub add
}
print " * created macro cart -> new show-id = " . $showid . "\n";
- ($result, $status, $errorstring) = RHRD::rddb::create_show_dropbox($ctx, $groupname, $showid, $rhythm, $dow, $starttime, $len);
+ ($result, $status, $errorstring) = RHRD::rddb::create_show_dropbox($ctx, $groupname, $showid, $rhythm, $dow, $starttime, $len, $type);
unless(defined $result) {
print STDERR $status . ": " . $errorstring . "\n";
return 1;
@@ -210,7 +218,7 @@ sub add
sub edit__check_arguments
{
- my ($showid, $title, $rhythm, $dow, $starttime, $len) = @_;
+ my ($showid, $title, $rhythm, $dow, $starttime, $len, $type) = @_;
my ($result, $err, $hint) = RHRD::utils::dropbox_param_rhythm_ok($rhythm);
unless($result) {
@@ -236,14 +244,20 @@ sub edit__check_arguments
return 1;
}
+ ($result, $err, $hint) = RHRD::utils::dropbox_param_showtype_ok($type);
+ unless($result) {
+ print STDERR $err . "\n " . $hint . "\n";
+ return 1;
+ }
+
return 0;
}
sub edit
{
- my ($ctx, $showid, $title, $rhythm, $dow, $starttime, $len) = @_;
+ my ($ctx, $showid, $title, $rhythm, $dow, $starttime, $len, $type) = @_;
- my $ret = edit__check_arguments($showid, $title, $rhythm, $dow, $starttime, $len);
+ my $ret = edit__check_arguments($showid, $title, $rhythm, $dow, $starttime, $len, $type);
if($ret) {
return $ret;
}
@@ -259,7 +273,7 @@ sub edit
return 1;
}
- ($result, $status, $errorstring) = RHRD::rddb::update_show_dropbox($ctx, $showid, $rhythm, $dow, $starttime, $len);
+ ($result, $status, $errorstring) = RHRD::rddb::update_show_dropbox($ctx, $showid, $rhythm, $dow, $starttime, $len, $type);
unless(defined $result) {
print STDERR $status . ": " . $errorstring . "\n";
return 1;
@@ -540,19 +554,19 @@ if(defined $ctx) {
}
}
elsif($cmd eq "add") {
- if($num_args != 9) {
+ if($num_args != 10) {
print_usage();
$ret = 1;
} else {
- $ret = add($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7], $ARGV[8]);
+ $ret = add($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7], $ARGV[8], $ARGV[9]);
}
}
elsif($cmd eq "edit") {
- if($num_args != 7) {
+ if($num_args != 8) {
print_usage();
$ret = 1;
} else {
- $ret = edit($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6]);
+ $ret = edit($ctx, $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7]);
}
}
elsif($cmd eq "multi-list") {