X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FFileGetter.pm;h=b2a0cea6c3fe686ff9fb2367f7432bc46d7b7b5d;hb=1dd46d87d78c3cac2732ba942f4412f3a168a837;hp=66f5f0d84c72fb7cafe536cf0db231ffa5da23d4;hpb=911eeb36e674f916d08b04cd9c48bb33e96bf108;p=videosite.git diff --git a/videosite/FileGetter.pm b/videosite/FileGetter.pm index 66f5f0d..b2a0cea 100644 --- a/videosite/FileGetter.pm +++ b/videosite/FileGetter.pm @@ -10,20 +10,20 @@ use videosite::GetterBase; @ISA = qw(videosite::GetterBase); use strict; -use LWP::Simple qw(!get); 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 { @@ -31,6 +31,7 @@ sub get { my $video = shift; my $dlfile; my $dirname; + my $ua; my $res; $dlfile = sprintf($self->_getval('FILEPATTERN'), @@ -46,10 +47,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 != ($res = LWP::Simple::mirror($video->{'DLURL'}, $dlfile))) { - $self->error('Could not download %s to %s (%s)', $video->{'DLURL'}, $dlfile, $res); + $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; }