X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FFileGetter.pm;h=48278dd576905f985ffc5d2a57b2980d5b30a98b;hb=09d45a4c4460dce9322f4528dad5123322ab6b38;hp=f7c680ec75ba33db36737b617745a9540a2397ea;hpb=d4895ed1563f30b8885472b2fe7ba16b1bbfbb84;p=videosite.git diff --git a/videosite/FileGetter.pm b/videosite/FileGetter.pm index f7c680e..48278dd 100644 --- a/videosite/FileGetter.pm +++ b/videosite/FileGetter.pm @@ -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 { @@ -59,6 +60,17 @@ sub get { return 0; } + if (exists($video->{'DLURL_AUDIO'})) { + $dlfile = $dlfile . ".audio"; + $self->debug('Going to download %s to %s', $video->{'DLURL_AUDIO'}, $dlfile); + + $res = $ua->mirror($video->{'DLURL_AUDIO'}, $dlfile); + if (!$res->is_success()) { + $self->error('Could not download %s to %s (%s)', $video->{'DLURL_AUDIO'}, $dlfile, $res->code()); + return 0; + } + } + return 1; }