diff options
author | Christian Pointner <equinox@helsinki.at> | 2011-08-03 12:15:27 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2011-08-03 12:15:27 (GMT) |
commit | 1af18aed11f7f98539fa59d79a7372464bef2846 (patch) | |
tree | 52c8205fdd0a9db5f677147b570d113bd703d306 | |
parent | 263b115f15d0a50f7423b5a3ea5b5847cafa6083 (diff) |
downloading files from different rss feed (for broadcasters)
-rw-r--r-- | debian/changelog | 6 | ||||
-rwxr-xr-x | rhimport-dn | 44 |
2 files changed, 36 insertions, 14 deletions
diff --git a/debian/changelog b/debian/changelog index 7e29d1d..a35dbe4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +rhimport (0.3.4-1) unstable; urgency=low + + * new upstream release 0.3.4 + + -- Christian Pointner <equinox@helsinki.at> Sun, 03 Aug 2011 14:15:10 +0200 + rhimport (0.3.3-2) unstable; urgency=low * fixed html output 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"; |