videosite-test: Allow selective tests by using grabber names on the command line
[videosite.git] / videosite / FileGetter.pm
index dab7ff3..b2a0cea 100644 (file)
@@ -14,15 +14,16 @@ use File::Basename;
 
 sub new {
     my $class = shift;
-    my $self = $class->SUPER::new();
-
-    $self->{'NAME'} = 'filegetter';
-    $self->{'_PARAMS'} = {'MINFREE' => ['500000', 'The amount of space that needs to be available on the filesystem before the video is downloaded (in kilobytes)'], 'FILEPATTERN', => ['/tmp/%s - %s - %s.flv', "The file name to save the file under. This is a string which is passed to a sprintf call later on. The parameters passed to that sprintf call, in order, are:\n- The site the video is from\n- The ID of the video\n- The title of the video\n- The URL of the video file itself\n- The URL of the site the video was taken from\nAll parameters are encoded (space and / replaced by _)"]};
-
-    bless($self, $class);
-    $self->_prepare_parameters();
-
-    return $self;
+    my $self = $class->SUPER::new(
+        NAME => 'filegetter',
+        _PARAMS => {
+            MINFREE => ['500000', 'The amount of space that needs to be available on the filesystem before the video is downloaded (in kilobytes)'],
+            FILEPATTERN => ['/tmp/%s - %s - %s.flv', "The file name to save the file under. This is a string which is passed to a sprintf call later on. The parameters passed to that sprintf call, in order, are:\n- The site the video is from\n- The ID of the video\n- The title of the video\n- The URL of the video file itself\n- The URL of the site the video was taken from\nAll parameters are encoded (space and / replaced by _)"]
+        },
+        @_,
+    );
+
+    return bless($self, $class);
 }
 
 sub get {
@@ -30,7 +31,7 @@ sub get {
     my $video = shift;
     my $dlfile;
     my $dirname;
-    my $ua = $self->ua();
+    my $ua;
     my $res;
 
     $dlfile = sprintf($self->_getval('FILEPATTERN'),
@@ -46,6 +47,11 @@ 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);
 
     $res = $ua->mirror($video->{'DLURL'}, $dlfile);