add connector support to AsyncFileGetter
[videosite.git] / videosite / FileGetter.pm
index 8c3420d..f7c680e 100644 (file)
@@ -4,13 +4,12 @@
 # A getter which will download the media to a local file storage
 #
 
-package FileGetter;
+package videosite::FileGetter;
 
-use GetterBase;
-@ISA = qw(GetterBase);
+use videosite::GetterBase;
+@ISA = qw(videosite::GetterBase);
 
 use strict;
-use LWP::Simple qw(!get);
 use File::Basename;
 
 sub new {
@@ -31,6 +30,8 @@ sub get {
     my $video = shift;
     my $dlfile;
     my $dirname;
+    my $ua;
+    my $res;
 
     $dlfile = sprintf($self->_getval('FILEPATTERN'),
         $self->_encode($video->{'SOURCE'}),
@@ -45,10 +46,16 @@ sub get {
         return 0;
     }
 
+    if (exists($video->{'CONNECTOR'})) {
+        $self->selectconn($video->{'CONNECTOR'});
+    }
+    $ua = $self->ua();
+
     $self->debug('Going to download %s to %s', $video->{'DLURL'}, $dlfile);
 
-    if (200 != LWP::Simple::mirror($video->{'DLURL'}, $dlfile)) {
-        $self->error('Could not download %s to %s', $video->{'DLURL'}, $dlfile);
+    $res = $ua->mirror($video->{'DLURL'}, $dlfile);
+    if (!$res->is_success()) {
+        $self->error('Could not download %s to %s (%s)', $video->{'DLURL'}, $dlfile, $res->code());
         return 0;
     }