summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-07-20 17:01:57 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-07-20 17:01:57 (GMT)
commit69d79bee3b6406eb85a99c60e6fb230c98c02508 (patch)
treebda19ce5c9a1f154ebbfb7370008800003e1e538
parent071dff71446b6a0004f77d33a026098bbc8a8176 (diff)
added feed aggregator for rhimport-dn
git-svn-id: https://svn.helsinki.at/rhimport/trunk@71 7c65635b-ec39-4f67-a626-873dbafdd612
-rw-r--r--debian/control2
-rwxr-xr-xrhimport-dn41
2 files changed, 34 insertions, 9 deletions
diff --git a/debian/control b/debian/control
index 1ad22d3..aa4b7a1 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Homepage: http://www.helsinki.at/
Package: rhimport
Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, perl, libdbd-mysql-perl, libgtk2-gladexml-perl, libdate-calc-perl
+Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, perl, libdbd-mysql-perl, libgtk2-gladexml-perl, libdate-calc-perl, libxml-feed-perl
Description: Radio Helsinki Import Tool
rhimport is a small tool which can be used to import media files
into the playout system namley Rivendell.
diff --git a/rhimport-dn b/rhimport-dn
index abcda30..e19f3b6 100755
--- a/rhimport-dn
+++ b/rhimport-dn
@@ -24,6 +24,11 @@
use strict;
use DBI;
use Date::Calc;
+use XML::Feed;
+use XML::Feed::Entry;
+use XML::Feed::Content;
+use XML::Feed::Enclosure;
+use File::Fetch;
use lib '/usr/local/share/rhimport/';
use rhimport;
@@ -68,10 +73,35 @@ if($dropbox eq "") {
exit 0;
}
-my $file = sprintf("dn%04d-%02d%02d-?.mp3", $yesterday[0], $yesterday[1], $yesterday[2]);
-print "looking for file like: $file\n";
+my $y = 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('http://www.democracynow.org/podcast.xml'))
+ or die "Error fetching feed: " . XML::Feed->errstr;
+my $file = "";
+for my $entry ($feed->entries) {
+ if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
+ my $summary = $entry->title . "\n\n" . $entry->summary->body . "\n\n" . $entry->link . "\n";
+
+ if($entry->id =~ /tag:democracynow.org,([0-9-]+):media\/mp3download\/[^\/]+/) {
+ next if($y ne $1);
+
+ my $ff = File::Fetch->new(uri => $entry->enclosure->url);
+ print $1 . ": downloading " . $entry->enclosure->url . " (" . $entry->enclosure->length . " Bytes) .. ";
+ $file = $ff->fetch( to => '/tmp' ) or die $ff->error;
+ print "ok\n";
+
+ print "summary:\n" . $summary;
+ }
+ print "\n\n\n";
+ }
+}
+($file ne "") or die "No Entry found for today!\n";
+(-e "$file") or die "file '$file' not found - donwload error?\n";
+print "will import $file to dropbox $dropbox (cart=$to_cart)\n\n";
+
+exit 0;
my $error_cb = sub {
my ($text) = @_;
@@ -81,12 +111,7 @@ my $error_cb = sub {
$x =~ /^n/i;
};
-#rhimport::check_key_file() or die "Import Key not found, use rhimport-create-id to create one\n";
-
-#(-e "$file") or die "file '$file' not found\n";
-print "will import $file to dropbox $dropbox (cart=$to_cart)\n\n";
-
-exit 0;
+rhimport::check_key_file() or die "Import Key not found, use rhimport-create-id to create one\n";
my $ret;
my $log;