summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-03-24 13:07:46 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-03-24 13:07:46 (GMT)
commit35aa26e2a79aa7ece3346661233de40e0a494058 (patch)
tree9cd4b714404c8aa06ed964bc936c932ee01f1ac5
parentacf31921ba70a6b8fe0219905062196575ba5547 (diff)
fixed clear vs keep carts
cleanups git-svn-id: https://svn.helsinki.at/rhimport/trunk@24 7c65635b-ec39-4f67-a626-873dbafdd612
-rwxr-xr-xrhimport33
-rw-r--r--rhimport.pm18
2 files changed, 31 insertions, 20 deletions
diff --git a/rhimport b/rhimport
index 05fc757..26cea0f 100755
--- a/rhimport
+++ b/rhimport
@@ -38,26 +38,26 @@ my $DB = "rivendell";
my $HELP = 0;
my $FILE = "";
my $POOL = 0;
-my $EMPTYCARTS = 0;
+my $KEEPCARTS = 0;
my $DROPBOX = "";
my $LISTALLOWED = 0;
GetOptions ("help!" => \$HELP,
"file=s" => \$FILE,
"pool!" => \$POOL,
- "empty-carts!" => \$EMPTYCARTS,
+ "keep-carts!" => \$KEEPCARTS,
"dropbox=s" => \$DROPBOX,
"list-allowed!" => \$LISTALLOWED,
);
if($HELP) {
print << "EOF";
-usage: $0 --file <audio or playlist file> --pool --empty-carts --dropbox <path to dropbox> --list-allowed
+usage: $0 --file <audio or playlist file> --pool --keep-carts --dropbox <path to dropbox> --list-allowed
options:
--file the media file or playlist to import
--pool pool mode, import media files referneced by playlist
- --empty-carts emtpy out pool of carts before import
+ --keep-carts in pool mode keep existing carts instead of clearing them before import
--dropbox the path to the dropbox to use
--list-allowed list allowed dropboxes and exit
@@ -73,7 +73,7 @@ my @allowed_dbs = rhimport::get_dropboxes($dbh, $user);
if($LISTALLOWED) {
for my $href ( @allowed_dbs ) {
- print "$href->{'PATH'}\n";
+ print "$href->{'NAME'} \t-> $href->{'PATH'}\n";
}
$dbh->disconnect();
exit 0;
@@ -164,11 +164,11 @@ sub start_import_gui()
if($POOL) {
my $cb_clear_carts = $guixml->get_widget('cb_clear_carts');
if($cb_clear_carts->get_active) {
- rhimport::empty_carts($dbh, $group);
+ rhimport::clear_carts($dbh, $group);
}
$ret = rhimport::import_playlist($file, $dropbox);
} else {
- $ret = rhimport::import_file($file, $dropbox);
+ $ret = rhimport::import_single($file, $dropbox);
}
return $ret;
@@ -187,8 +187,11 @@ sub show_used_carts_gui()
my $l_status = $guixml->get_widget('l_status');
my ($low_cart, $high_cart) = rhimport::get_cart_range($dbh, $group);
- $l_status->set_label("Carts: $low_cart - $high_cart");
-
+ if($low_cart eq $high_cart) {
+ $l_status->set_label("Cart: $low_cart");
+ } else {
+ $l_status->set_label("Carts: $low_cart - $high_cart");
+ }
# my $usedcartswin = $guixml->get_widget('usedcartswin');
# $usedcartswin or die "can't find Widget";
@@ -216,10 +219,10 @@ if(!$FILE || !$DROPBOX) {
$co_dropbox->set_active(0);
my $cb_clear_carts = $guixml->get_widget('cb_clear_carts');
- if($EMPTYCARTS) {
- $cb_clear_carts->set_active(1);
- } else {
+ if($KEEPCARTS) {
$cb_clear_carts->set_active(0);
+ } else {
+ $cb_clear_carts->set_active(1);
}
if($POOL) {
@@ -262,13 +265,13 @@ if($group eq '') {
my $ret;
if($POOL) {
- if($EMPTYCARTS) {
- rhimport::empty_carts($dbh, $group);
+ if(!$KEEPCARTS) {
+ rhimport::clear_carts($dbh, $group);
}
$ret = rhimport::import_playlist($FILE, $DROPBOX);
} else {
- $ret = rhimport::import_file($FILE, $DROPBOX);
+ $ret = rhimport::import_single($FILE, $DROPBOX);
}
$dbh->disconnect();
diff --git a/rhimport.pm b/rhimport.pm
index 5827bb2..4db154c 100644
--- a/rhimport.pm
+++ b/rhimport.pm
@@ -38,8 +38,8 @@ sub get_dropboxes
$path =~ s/\/\*$//;
my $name = $path;
$name =~ s/^\/programm\///;
- if($name =~ /^([0-9]{2}-[A-Za-z]+)\/([0-9]{4})-([01]{4})-([0-9]{3})-(.*)$/) {
- $name = "$1 - $2: $5 ($3, $4)";
+ if($name =~ /^([0-9]{2}-[A-Za-z]+)\/([0-9]{2})([0-9]{2})-([01]{4})-([0-9]{3})-(.*)$/) {
+ $name = "$1 - $2:$3 - $6 ($4, $5)";
}
elsif($name =~ /^([0-9]{2}-[A-Za-z]+)\/programmvorschau_(.*)$/) {
$name = "Programmvorschau - $1 - $2";
@@ -92,12 +92,13 @@ sub get_used_carts
return @carts;
}
-sub empty_carts
+sub clear_carts
{
my $dbh = shift;
my $group = shift;
my ($low_cart, $high_cart) = get_cart_range($dbh, $group);
+ print "clearing Carts $low_cart - $high_cart\n";
my $cart = $low_cart;
while($cart <= $high_cart) {
my $sql = qq{select CUT_NAME from CUTS where CART_NUMBER='$cart';};
@@ -107,7 +108,7 @@ sub empty_carts
my $filename = "/var/snd/$cut_name.wav";
### call unlink!!!
- print "deleting $filename\n";
+ print " - deleting $filename\n";
}
$sth->finish();
@@ -143,11 +144,18 @@ sub import_playlist
return 0;
}
+sub import_single
+{
+ my ($file, $dropbox) = @_;
+ print "Starting import from file $file to $dropbox\n";
+ import_file($file, $dropbox);
+}
+
sub import_file
{
my ($file, $dropbox) = @_;
- print "importing $file to $dropbox .. ";
+ print " - importing $file to $dropbox .. ";
$| = 1;
sleep(1);