From f366fc3929ad85a6b1f74baf4e62e86d651fe0f7 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Sun, 13 Mar 2016 00:06:11 +0100
Subject: dn is now tested as well - note will only be set when import was
 successful


diff --git a/rhautoimport-dn b/rhautoimport-dn
index 4cf7eb0..0feafdb 100755
--- a/rhautoimport-dn
+++ b/rhautoimport-dn
@@ -93,6 +93,9 @@ my $files_feed = rhautoimport::fetch_parse_rss($FILES_RSS_URL)
 
 my $uri = "";
 my $file = "";
+my $sum_title = "";
+my $sum_text = "";
+
 for my $entry ($files_feed->entries) {
   if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
     if($entry->enclosure->url =~ /^https?:\/\/.*\.democracynow\.org\/dn([0-9-]+)-1\.mp3$/) {
@@ -117,7 +120,7 @@ for my $entry ($files_feed->entries) {
   }
 }
 if($uri eq "") {
-  print "No Entry found from day in question or download error - ";
+  print "No Entry found from day in question - ";
   if($#ARGV >= 0 && $ARGV[0] eq 'last') {
     print "giving up, manual import necessary!!!\n";
   } else {
@@ -135,30 +138,32 @@ my $headlines_feed = rhautoimport::fetch_parse_rss($HEADLINES_RSS_URL)
 
 for my $entry ($headlines_feed->entries) {
   if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
-    my $sum_title = $entry->title;
-    my $sum_text = $entry->summary->body . "\n<br />\n<a href=\"" . $entry->link . "\">" . $entry->link . "</a>\n";
+    $sum_title = $entry->title;
+    $sum_text = $entry->summary->body . "\n<br />\n<a href=\"" . $entry->link . "\">" . $entry->link . "</a>\n";
 
     if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3podcast\/[^\/]+/) {
       next if($y ne $1);
 
       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_day), "1", 0);
-
       last;
     }
   }
 }
 
-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;
+if($sum_title ne "") {
+  rhautoimport::pv_add_note($sum_title, $sum_text, $PV_ID, sprintf("%04d-%02d-%02d", @import_day), "1", 0);
+}
 
 unlink($STAT_FILE);
 open(my $fhs, '>', $STAT_FILE);
diff --git a/rhautoimport-ra b/rhautoimport-ra
index d75d18e..f5780a0 100755
--- a/rhautoimport-ra
+++ b/rhautoimport-ra
@@ -127,7 +127,7 @@ for my $entry ($feed->entries) {
   last if $file 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 {
-- 
cgit v0.10.2