diff options
-rwxr-xr-x | rhautoimport-nw | 7 | ||||
-rwxr-xr-x | rhautoimport-ra | 7 | ||||
-rwxr-xr-x | rhautoimport-tr | 25 |
3 files changed, 25 insertions, 14 deletions
diff --git a/rhautoimport-nw b/rhautoimport-nw index 2fbc9c8..e8f7dd0 100755 --- a/rhautoimport-nw +++ b/rhautoimport-nw @@ -103,7 +103,10 @@ for my $entry ($feed->entries) { $uri = new URI::URL($orig_uri); my @path = $uri->path_components; $file = $path[-1]; - next unless (uc($file) =~ $bdfile); # file not from correct day + unless(uc($file) =~ $bdfile) { # file not from correct day + $uri = ""; + next; + } my $current_file = `cat $STAT_FILE`; if($current_file eq $file) { @@ -121,7 +124,7 @@ for my $entry ($feed->entries) { last; } } - last if $file ne ""; + last if $uri ne ""; } if($uri eq "") { print "No Entry found from $bd - "; diff --git a/rhautoimport-ra b/rhautoimport-ra index f5780a0..14cbbf0 100755 --- a/rhautoimport-ra +++ b/rhautoimport-ra @@ -108,7 +108,10 @@ for my $entry ($feed->entries) { $uri = new URI::URL($orig_uri); my @path = $uri->path_components; $file = $path[-1]; - next unless $bnum eq substr($file, 0, 3); + unless($bnum eq substr($file, 0, 3)) { + $uri = ""; + next; + } my $current_file = `cat $STAT_FILE`; if($current_file eq $file) { @@ -124,7 +127,7 @@ for my $entry ($feed->entries) { last; } } - last if $file ne ""; + last if $uri ne ""; } if($uri eq "") { print "No Entry found from $bd - "; diff --git a/rhautoimport-tr b/rhautoimport-tr index 263cc0f..7077b88 100755 --- a/rhautoimport-tr +++ b/rhautoimport-tr @@ -57,6 +57,7 @@ if(scalar(@allowed_dbs) != 1) { my $show_id = $allowed_dbs[0]->{'SHOWID'}; my $show_title = $allowed_dbs[0]->{'SHOWTITLE'}; + my @today = Date::Calc::Standard_to_Business(Date::Calc::Today()); if($today[2] == 5) { print "please don't run this script on fridays!\n"; @@ -67,14 +68,12 @@ if($today[2] < 5) { @broadcast_day = Date::Calc::Add_Delta_Days(@broadcast_day, -7); } my @import_date = Date::Calc::Add_Delta_Days(@broadcast_day, 7); - 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"; my $id = sprintf("%04d-%02d-%02d", @import_date); my $bd = sprintf("%04d-%02d-%02d", @broadcast_day); my $bdfile = sprintf("^%04d-?%02d-?%02d", @broadcast_day); - print "looking for files from $bd in RSS Feed\n"; print " -> $RSS_URL\n"; @@ -83,6 +82,9 @@ my $feed = rhautoimport::fetch_parse_rss($RSS_URL) my $uri = ""; my $file = ""; +my $sum_title = ""; +my $sum_text = ""; + my $i = 0; for my $entry ($feed->entries) { $i++; @@ -100,7 +102,10 @@ for my $entry ($feed->entries) { $uri = new URI::URL($orig_uri); my @path = $uri->path_components; $file = $path[-1]; - next unless (uc($file) =~ $bdfile); # file not from correct day + unless(uc($file) =~ $bdfile) { # file not from correct day + $uri = ""; + next; + } my $current_file = `cat $STAT_FILE`; if($current_file eq $file) { @@ -112,18 +117,16 @@ for my $entry ($feed->entries) { exit 1; } - my $sum_title = decode_entities($entry->title); - my $sum_text = decode_entities($entry->content->body); + $sum_title = decode_entities($entry->title); + $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, $id, "1"); - last; } } - last if $file ne ""; + last if $uri ne ""; } if($uri eq "") { - print "No Entry found from $bd or download error - "; + print "No Entry found from $bd - "; if($#ARGV >= 0 && $ARGV[0] eq 'last') { print "giving up, manual import necessary!!!\n"; } else { @@ -132,16 +135,18 @@ if($uri eq "") { exit 1; } -print "will import '$uri' to show $show_id, $show_title\n\n"; +print "\n\nwill import '$uri' to show $show_id, $show_title\n\n"; my ($ret, $log) = rhautoimport::import_uri($show_id, $uri->as_string); if($ret) { print "\nImport Error:\n\n"; print $log; + print "\n\nNot adding PV note!!"; exit 1; } print "\nImport Success:\n\n"; print $log; +rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, $id, "1"); unlink($STAT_FILE); open(my $fhs, '>', $STAT_FILE); |