summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-04-20 20:18:39 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-04-20 20:18:39 (GMT)
commitc9c41b172731af0029ec1989803647f4dd7e6ddf (patch)
treea30adde8e2ec1763067c500f1b61c7caac79d770
parent3686189ba1f99a647aaab9355a229e75c1c60ce2 (diff)
autoimporter for radio stimme now uses wget as well (https)
-rwxr-xr-xrhimport-rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/rhimport-rs b/rhimport-rs
index d0d7337..c8e091a 100755
--- a/rhimport-rs
+++ b/rhimport-rs
@@ -28,7 +28,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;
use HTML::Entities;
@@ -138,25 +138,27 @@ for my $entry ($feed->entries) {
$j++;
if($enclosure->type eq "audio/mpeg" || $enclosure->type eq "audio/ogg") {
print "$i/$j: (" . $enclosure->type . ", " . $enclosure->length . ") " . $enclosure->url . "\n";
- my $url = $enclosure->url;
- if($url =~ /^(.*)_cut(\.[^\.]+)$/) {
- $url = $1 . $2;
+ my $fetchurl = $enclosure->url;
+ if($fetchurl =~ /^(.*)_cut(\.[^\.]+)$/) {
+ $fetchurl = $1 . $2;
}
- my $ff = File::Fetch->new(uri => $url);
- next unless (uc($ff->output_file) =~ $bdfile); # file not from correct day
+ my $url = new URI::URL($fetchurl);
+ my @path = $url->path_components;
+
+ next unless (uc($path[-1]) =~ $bdfile); # file not from correct day
my $sum_title = decode_entities($entry->title);
my $sum_text = decode_entities($entry->content->body);
my $current_stat = `cat $STAT_FILE`;
my ($current_id, $current_file) = $current_stat =~ m/^(.*)\n(.*)/;
- if($current_id eq $id && $current_file eq $ff->output_file) {
+ if($current_id eq $id && $current_file eq $path[-1]) {
print "Already downloaded file of today\n";
$dbh->disconnect();
exit 0;
}
- $out_file = $ff->output_file;
+ $out_file = $path[-1];
if(!rhimport::check_file_extension($out_file)) {
print "\n\nThe extension of the matching file '". $out_file . "' seems to be wrong - manual import necessary!!!\n";
$dbh->disconnect();
@@ -164,7 +166,11 @@ for my $entry ($feed->entries) {
}
print " --> " . $bdfile . ": downloading " . $url . " (" . $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";
print "summary:\n" . $sum_title . "\n\n" . $sum_text . "\n";