refactor: Simplify getAvconvProcess()

This commit is contained in:
Pierre Rudloff 2018-07-03 20:09:45 +02:00
parent 159ea245a8
commit cb7c21164b

View file

@ -222,6 +222,7 @@ class VideoDownload
{
$arguments = [];
if ($video->protocol == 'rtmp') {
foreach ([
'url' => '-rtmp_tcurl',
'webpage_url' => '-rtmp_pageurl',
@ -242,6 +243,7 @@ class VideoDownload
$arguments[] = $conn;
}
}
}
return $arguments;
}
@ -289,26 +291,20 @@ class VideoDownload
$durationRegex = '/(\d+:)?(\d+:)?(\d+)/';
if ($video->protocol == 'rtmp') {
$beforeArguments = $this->getRtmpArguments($video);
} else {
$beforeArguments = [];
}
$afterArguments = [];
if ($audioOnly) {
$afterArguments = ['-vn'];
} else {
$afterArguments = [];
$afterArguments[] = '-vn';
}
if (isset($from) && !empty($from)) {
if (!empty($from)) {
if (!preg_match($durationRegex, $from)) {
throw new Exception(_('Invalid start time: ').$from.'.');
}
$afterArguments[] = '-ss';
$afterArguments[] = $from;
}
if (isset($to) && !empty($to)) {
if (!empty($to)) {
if (!preg_match($durationRegex, $to)) {
throw new Exception(_('Invalid end time: ').$to.'.');
}
@ -321,7 +317,7 @@ class VideoDownload
$this->config->avconv,
'-v', $this->config->avconvVerbosity,
],
$beforeArguments,
$this->getRtmpArguments($video),
[
'-i', $video->url,
'-f', $filetype,