summaryrefslogtreecommitdiff
path: root/rhimport-tr
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport-tr')
-rwxr-xr-xrhimport-tr26
1 files changed, 16 insertions, 10 deletions
diff --git a/rhimport-tr b/rhimport-tr
index e02ae0c..b7d6916 100755
--- a/rhimport-tr
+++ b/rhimport-tr
@@ -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;
@@ -42,7 +42,7 @@ my $DBPW = "lldriven";
my $DB = "rivendell";
my $STAT_FILE = $ENV{'HOME'} . "/rhimport-tr.stat";
-my $RSS_URL = "http://cba.fro.at/series/tierrechtsradio/feed?c=Kfs2IoV2Wmd";
+my $RSS_URL = "https://cba.fro.at/series/tierrechtsradio/feed?c=Kfs2IoV2Wmd";
$XML::Feed::MULTIPLE_ENCLOSURES=1;
my $PV_ID = '506';
@@ -105,24 +105,26 @@ 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_file = `cat $STAT_FILE`;
- if($current_file eq $ff->output_file) {
+ if($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();
@@ -130,7 +132,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";