summaryrefslogtreecommitdiff
path: root/rhimport-dn
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport-dn')
-rwxr-xr-xrhimport-dn44
1 files changed, 30 insertions, 14 deletions
diff --git a/rhimport-dn b/rhimport-dn
index d77c724..b650f24 100755
--- a/rhimport-dn
+++ b/rhimport-dn
@@ -41,7 +41,8 @@ my $DBPW = "lldriven";
my $DB = "rivendell";
my $STAT_FILE = $ENV{'HOME'} . "/rhimport-dn.stat";
-my $RSS_URL = "http://www.democracynow.org/podcast.xml";
+my $FILES_RSS_URL = "http://www.democracynow.org/podcast-stations.xml";
+my $HEADLINES_RSS_URL = "http://www.democracynow.org/podcast.xml";
my @PV_SCRIPT = ('/usr/bin/ssh', 'root@intranet', 'addnote', '111');
binmode(STDIN, ":utf8");
@@ -81,20 +82,18 @@ if($dropbox eq "") {
}
my $y = sprintf("%04d-%02d-%02d", $yesterday[0], $yesterday[1], $yesterday[2]);
+my $yc = sprintf("%04d-%02d%02d", $yesterday[0], $yesterday[1], $yesterday[2]);
print "looking for files from date $y in RSS Feed\n";
-my $feed = XML::Feed->parse(URI->new($RSS_URL))
+my $files_feed = XML::Feed->parse(URI->new($FILES_RSS_URL))
or die "Error fetching feed: " . XML::Feed->errstr;
my $file = "";
my $out_file = "";
-for my $entry ($feed->entries) {
+for my $entry ($files_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";
-
- if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3download\/[^\/]+/) {
- next if($y ne $1);
+ if($entry->id =~ /dn([0-9-]+)-static/) {
+ next if($yc ne $1);
my $ff = File::Fetch->new(uri => $entry->enclosure->url);
@@ -109,6 +108,28 @@ for my $entry ($feed->entries) {
print $1 . ": downloading " . $entry->enclosure->url . " (" . $entry->enclosure->length . " Bytes) .. ";
$file = $ff->fetch( to => '/tmp' ) or die $ff->error;
print "ok\n";
+ }
+ }
+}
+if($file eq "" || !(-e "$file")) {
+ print "No Entry found for today or download error - just clearing cart!\n";
+ rhimport::check_key_file() or die "Import Key not found, use rhimport-create-id to create one\n";
+ rhimport::clear_carts($dbh, $group, $to_cart);
+ exit 1;
+}
+
+
+print "\nlooking for headlines from date $y in RSS Feed\n";
+my $headlines_feed = XML::Feed->parse(URI->new($HEADLINES_RSS_URL))
+ or die "Error fetching feed: " . XML::Feed->errstr;
+
+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";
+
+ if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3download\/[^\/]+/) {
+ next if($y ne $1);
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";
@@ -127,6 +148,7 @@ for my $entry ($feed->entries) {
print "\n\nPV: adding note failed\n";
print "STDERR:\n" . join('', <$error>) . "\n";
print "STDOUT:\n" . join('', <$reader>) . "\n";
+ print "Ignoring failed headline import!\n";
} else {
print join('', <$reader>) . "\n";
}
@@ -134,12 +156,6 @@ for my $entry ($feed->entries) {
}
}
}
-if($file eq "" || !(-e "$file")) {
- print "No Entry found for today or download error - just clearing cart!\n";
- rhimport::check_key_file() or die "Import Key not found, use rhimport-create-id to create one\n";
- rhimport::clear_carts($dbh, $group, $to_cart);
- exit 1;
-}
print "will import $file to dropbox $dropbox (cart=$to_cart)\n\n";