summaryrefslogtreecommitdiff
path: root/rhimport-nw
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-05-27 14:36:11 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-05-27 14:36:11 (GMT)
commit7527a99f52dd26015b20aa31b49ddf80268f07de (patch)
tree26eb88345a3658c11568039044535e58cccf22e9 /rhimport-nw
parent8b4bc84d55ec6021912b7ca605c0842ca9a8ba9a (diff)
netwatcher has a rebroadcast now
Diffstat (limited to 'rhimport-nw')
-rwxr-xr-xrhimport-nw24
1 files changed, 18 insertions, 6 deletions
diff --git a/rhimport-nw b/rhimport-nw
index e2db9b8..470aa1e 100755
--- a/rhimport-nw
+++ b/rhimport-nw
@@ -61,13 +61,17 @@ my $group = "netwatcher";
my $dbh = DBI->connect("DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr";
my @allowed_dbs = rhimport::get_dropboxes($dbh, $user, $group);
-if(scalar(@allowed_dbs) != 1) {
- print "found more or less than 1 Dropbox for this group?!\n";
+my $idx = 0;
+my $idx_reb = 1;
+if(scalar(@allowed_dbs) != 2) {
+ print "found more or less than 2 Dropboxes for this group?!\n";
$dbh->disconnect();
exit 1;
}
-my $dropbox = $allowed_dbs[0]->{'PATH'};
-my $to_cart = $allowed_dbs[0]->{'TO_CART'};
+my $dropbox = $allowed_dbs[$idx]->{'PATH'};
+my $to_cart = $allowed_dbs[$idx]->{'TO_CART'};
+my $dropbox_reb = $allowed_dbs[$idx_reb]->{'PATH'};
+my $to_cart_reb = $allowed_dbs[$idx_reb]->{'TO_CART'};
my @today = Date::Calc::Today();
my @import_date = @today;
@@ -80,10 +84,11 @@ if( Date::Calc::Day_of_Week(@today) != 3 ) {
@import_date = Date::Calc::Business_to_Standard(@import_date);
}
my @broadcast_day = Date::Calc::Add_Delta_Days(@import_date, -5);
+my @import_date_reb = Date::Calc::Add_Delta_Days(@import_date, 3);
print "day of original broadcast: " . Date::Calc::Date_to_Text(@broadcast_day) . "\n";
print "day of Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@import_date) . "\n";
+print "day of Radio Helsinki rebroadcast: " . Date::Calc::Date_to_Text(@import_date_reb) . "\n";
-my $id = sprintf("%04d-%02d-%02d", @import_date);
my $bd = sprintf("%04d-%02d-%02d", @broadcast_day);
my $bdfile = sprintf("NETWATCHER[-_]?%04d%02d%02d(.*)\.MP3", @broadcast_day);
print "looking for files from $bd in RSS Feed\n";
@@ -139,8 +144,10 @@ for my $entry ($feed->entries) {
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
- rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1");
+ rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $import_date[0], $import_date[1], $import_date[2]), "1");
print "\n";
+# rhimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", $import_date_reb[0], $import_date_reb[1], $import_date_reb[2]), "2");
+# print "\n";
last;
}
@@ -159,6 +166,7 @@ if($file eq "" || !(-e "$file")) {
}
print "will import $file to dropbox $dropbox (cart=$to_cart)\n";
+print "will import $file to rebroadcast dropbox $dropbox_reb (cart=$to_cart_reb)\n\n";
my $error_cb = sub {
my ($text) = @_;
@@ -174,6 +182,10 @@ my $log = rhimport::clear_carts($dbh, $group, $to_cart);
my $import_log;
($ret, $import_log) = rhimport::import_single($file, $dropbox, $user, 0, $error_cb);
$log .= $import_log;
+$import_log = rhimport::clear_carts($dbh, $group, $to_cart_reb);
+$log .= $import_log;
+($ret, $import_log) = rhimport::import_single($file, $dropbox_reb, $user, 0, $error_cb);
+$log .= $import_log;
$dbh->disconnect();