diff options
Diffstat (limited to 'rhimport-ra')
-rwxr-xr-x | rhimport-ra | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/rhimport-ra b/rhimport-ra index ec30851..ef7e3fb 100755 --- a/rhimport-ra +++ b/rhimport-ra @@ -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-ra.stat"; -my $RSS_URL = "http://cba.fro.at/seriesrss/262430?c=Kfs2IoV2Wmd"; +my $RSS_URL = "https://cba.fro.at/seriesrss/262430?c=Kfs2IoV2Wmd"; $XML::Feed::MULTIPLE_ENCLOSURES=1; my $PV_ID = '76'; @@ -104,9 +104,9 @@ 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 $sum_title = decode_entities($entry->title); @@ -114,15 +114,16 @@ for my $entry ($feed->entries) { my $sum_text = decode_entities($entry->content->body); my $bnum = $1; - my $ff = File::Fetch->new(uri => $url); - next unless $bnum eq substr($ff->output_file, 0, 3); + my $url = new URI::URL($fetchurl); + my @path = $url->path_components; + next unless $bnum eq substr($path[-1], 0, 3); 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 +131,11 @@ for my $entry ($feed->entries) { } print " --> " . $bnum . ": 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"; |