summaryrefslogtreecommitdiff
path: root/rhimport-dn
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport-dn')
-rwxr-xr-xrhimport-dn18
1 files changed, 12 insertions, 6 deletions
diff --git a/rhimport-dn b/rhimport-dn
index b6847e1..0468dc8 100755
--- a/rhimport-dn
+++ b/rhimport-dn
@@ -29,7 +29,7 @@ use XML::Feed;
use XML::Feed::Entry;
use XML::Feed::Content;
use XML::Feed::Enclosure;
-use File::Fetch;
+use URI::URL;
use IO::Handle;
use IPC::Open3;
@@ -107,21 +107,27 @@ my $file = "";
my $out_file = "";
for my $entry ($files_feed->entries) {
if($entry->enclosure && $entry->enclosure->type eq "audio/mpeg") {
- if($entry->enclosure->url =~ /^http:\/\/distro.democracynow.org\/dn([0-9-]+)-1\.mp3$/) {
+ if($entry->enclosure->url =~ /^https?:\/\/.*\.democracynow\.org\/dn([0-9-]+)-1\.mp3$/) {
next if($yc ne $1);
- my $ff = File::Fetch->new(uri => $entry->enclosure->url);
+ my $url = new URI::URL($entry->enclosure->url);
+ my @path = $url->path_components;
my $current_file = `cat $STAT_FILE`;
- if($current_file eq $ff->output_file) {
+ if($current_file eq $path[-1]) {
print "Already downloaded file of day in question\n";
$dbh->disconnect();
exit 0;
}
- $out_file = $ff->output_file;
+ $out_file = $path[-1];
print $1 . ": downloading " . $entry->enclosure->url . " (" . $entry->enclosure->length . " Bytes) .. ";
- $file = $ff->fetch( to => '/tmp' ) or die $ff->error;
+
+ $file = "/tmp/" . $out_file;
+ system("wget", "--quiet", "--no-check-certificate", $url, "-O", $file);
+ if( $! != 0) {
+ die "wget returned with error: " . $!;
+ }
print "ok\n";
last;