summaryrefslogtreecommitdiff
path: root/rhautoimport-ra
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-03-12 22:36:21 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-03-12 22:36:21 (GMT)
commitbbc151dcd8d88f543454cb282e1dac01ef720894 (patch)
treef1ca7bf9b81393e3522f50d636dd4990935b0ed3 /rhautoimport-ra
parentd8b38a12a3b14e5083ee1ed8138439c005692355 (diff)
import for rebroadcast at radioattac works now
Diffstat (limited to 'rhautoimport-ra')
-rwxr-xr-xrhautoimport-ra45
1 files changed, 30 insertions, 15 deletions
diff --git a/rhautoimport-ra b/rhautoimport-ra
index aaa1e0a..3cf2843 100755
--- a/rhautoimport-ra
+++ b/rhautoimport-ra
@@ -50,7 +50,6 @@ if(!defined $allowed_dbs[0] && defined $allowed_dbs[1]) {
exit 1;
}
-
my $idx = 0;
my $idx_reb = 1;
if(scalar(@allowed_dbs) != 2) {
@@ -62,6 +61,7 @@ my $show_title = $allowed_dbs[$idx]->{'SHOWTITLE'};
my $show_id_reb = $allowed_dbs[$idx_reb]->{'SHOWID'};
my $show_title_reb = $allowed_dbs[$idx_reb]->{'SHOWTITLE'};
+
my @today = Date::Calc::Standard_to_Business(Date::Calc::Today());
$today[2] = 1;
my @broadcast_day = Date::Calc::Business_to_Standard(@today);
@@ -83,6 +83,9 @@ my $bdexp = sprintf("^(\\d+)\\..*\\s*0?%d\\s*[.,]\\s*0?%d\\s*[.,]\\s*%4d", $broa
my $uri = "";
my $file = "";
+my $sum_title = "";
+my $sum_text = "";
+
my $i = 0;
for my $entry ($feed->entries) {
$i++;
@@ -97,7 +100,8 @@ for my $entry ($feed->entries) {
$orig_uri = $1 . $2;
}
- my $sum_title = decode_entities($entry->title);
+ $sum_title = decode_entities($entry->title);
+ $sum_text = decode_entities($entry->content->body);
next unless $sum_title =~ /$bdexp/;
my $bnum = $1;
@@ -116,13 +120,7 @@ for my $entry ($feed->entries) {
exit 1;
}
- my $sum_text = decode_entities($entry->content->body);
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_date), "1");
- print "\n";
- rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_date_reb), "2");
- print "\n";
-
last;
}
}
@@ -138,19 +136,36 @@ if($uri eq "") {
exit 1;
}
-print "will import '$uri' to show $show_id, $show_title\n\n";
-print "will import '$uri' to rebroadcast $show_id_reb, $show_title_reb\n\n";
+print "will import '$uri' to show $show_id, $show_title\n";
+my ($ret, $log, $keptfile_uri) = rhautoimport::import_uri($show_id, $uri->as_string, "keep");
+if($ret == 0) {
+ print "\nImport Success:\n\n";
+ print $log;
+ rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_date), "1");
+ print "\n";
+ if(!defined($keptfile_uri)) {
+ print "rhimportd didn't provide a clue where to find the kept file... will import '$uri' to rebroadcast $show_id_reb, $show_title_reb\n";
+ ($ret, $log) = rhautoimport::import_uri($show_id_reb, $uri->as_string);
+ } else {
+ print "re-using kept file '$keptfile_uri' to import rebroadcast $show_id_reb, $show_title_reb\n";
+ ($ret, $log) = rhautoimport::import_uri($show_id_reb, $keptfile_uri, "delete-with-dir");
+ }
-my ($ret, $log) = rhautoimport::import_uri($show_id, $uri->as_string); # TODO: file-policy: keep
-# TODO: import to $show_id_reb with file-policy: delete-with-dir
-if($ret) {
+ if($ret == 0) {
+ print "\nImport Success:\n\n";
+ print $log;
+ rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_date_reb), "2");
+ } else {
+ print "\nImport Error:\n\n";
+ print $log;
+ exit 1;
+ }
+} else {
print "\nImport Error:\n\n";
print $log;
exit 1;
}
-print "\nImport Success:\n\n";
-print $log;
unlink($STAT_FILE);
open(my $fhs, '>', $STAT_FILE);