diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-04-23 00:11:31 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-04-23 00:11:31 (GMT) |
commit | d85c6d205ac64681e49be76d0e50134dfa21036e (patch) | |
tree | b278fe11cd42fd03c3d121d03309c46caf2c4d02 /rhimport-nw | |
parent | c9c41b172731af0029ec1989803647f4dd7e6ddf (diff) |
all cba importer now use wget (switch to https...)
Diffstat (limited to 'rhimport-nw')
-rwxr-xr-x | rhimport-nw | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/rhimport-nw b/rhimport-nw index 2fe4253..e2db9b8 100755 --- a/rhimport-nw +++ b/rhimport-nw @@ -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-nw.stat"; -my $RSS_URL = "http://cba.fro.at/seriesrss/262514?c=Kfs2IoV2Wmd"; +my $RSS_URL = "https://cba.fro.at/seriesrss/262514?c=Kfs2IoV2Wmd"; $XML::Feed::MULTIPLE_ENCLOSURES=1; my $PV_ID = '73'; @@ -103,24 +103,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(); @@ -128,7 +130,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"; |