Merge branch 'develop' into feature/stream

Conflicts:
	composer.json
	composer.lock
This commit is contained in:
Pierre Rudloff 2016-04-12 15:13:50 +02:00
commit ac16e68389
4 changed files with 103 additions and 21 deletions

View file

@ -14,6 +14,8 @@ namespace Alltube\Controller;
use Alltube\VideoDownload;
use Alltube\Config;
use Symfony\Component\Process\ProcessBuilder;
use Chain\Chain;
/**
* Main controller
@ -115,7 +117,18 @@ class FrontController
try {
return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request);
} catch (\Exception $e) {
$video = $this->download->getJSON($params["url"]);
$video = $this->download->getJSON($params["url"], 'best');
$avconvProc = ProcessBuilder::create(
array(
$this->config->avconv,
'-v', 'quiet',
'-i', '-',
'-f', 'mp3',
'-vn',
'pipe:1'
)
);
//Vimeo needs a correct user-agent
ini_set(
@ -123,6 +136,33 @@ class FrontController
$video->http_headers->{'User-Agent'}
);
if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') {
$builder = new ProcessBuilder(
array(
'/usr/bin/rtmpdump',
'-q',
'-r',
$video->url,
'--pageUrl', $video->webpage_url
)
);
if (isset($video->player_url)) {
$builder->add('--swfVfy');
$builder->add($video->player_url);
}
if (isset($video->flash_version)) {
$builder->add('--flashVer');
$builder->add($video->flash_version);
}
if (isset($video->play_path)) {
$builder->add('--playpath');
$builder->add($video->play_path);
}
foreach ($video->rtmp_conn as $conn) {
$builder->add('--conn');
$builder->add($conn);
}
$chain = new Chain($builder->getProcess());
$chain->add('|', $avconvProc);
ob_end_flush();
header(
'Content-Disposition: attachment; filename="'.
@ -136,13 +176,22 @@ class FrontController
).'"'
);
header("Content-Type: audio/mpeg");
passthru(
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
' | '.$this->config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1'
);
passthru($chain->getProcess()->getCommandLine());
exit;
} else {
$chain = new Chain(
ProcessBuilder::create(
array_merge(
array('curl'),
$this->config->curl_params,
array(
'--user-agent', $video->http_headers->{'User-Agent'},
$video->url
)
)
)
);
$chain->add('|', $avconvProc);
ob_end_flush();
header(
'Content-Disposition: attachment; filename="'.
@ -156,13 +205,7 @@ class FrontController
).'"'
);
header("Content-Type: audio/mpeg");
passthru(
'curl '.$this->config->curl_params.
' --user-agent '.escapeshellarg($video->http_headers->{'User-Agent'}).
' '.escapeshellarg($video->url).
' | '.$this->config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1'
);
passthru($chain->getProcess()->getCommandLine());
exit;
}
}