diff options
Diffstat (limited to 'rhimport-dn')
-rwxr-xr-x | rhimport-dn | 41 |
1 files changed, 33 insertions, 8 deletions
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; |