Refactor FrontController::getStream()

This commit is contained in:
Pierre Rudloff 2017-05-05 00:25:08 +02:00
parent 879a37820d
commit 1b4e96f5ef

View file

@ -329,23 +329,20 @@ class FrontController
} elseif ($video->protocol == 'rtmp') {
$stream = $this->download->getRtmpStream($video);
$response = $response->withHeader('Content-Type', 'video/'.$video->ext);
if ($request->isGet()) {
$response = $response->withBody(new Stream($stream));
}
$body = new Stream($stream);
} elseif ($video->protocol == 'm3u8') {
$stream = $this->download->getM3uStream($video);
$response = $response->withHeader('Content-Type', 'video/'.$video->ext);
if ($request->isGet()) {
$response = $response->withBody(new Stream($stream));
}
$body = new Stream($stream);
} else {
$client = new \GuzzleHttp\Client();
$stream = $client->request('GET', $video->url, ['stream' => true]);
$response = $response->withHeader('Content-Type', $stream->getHeader('Content-Type'));
$response = $response->withHeader('Content-Length', $stream->getHeader('Content-Length'));
if ($request->isGet()) {
$response = $response->withBody($stream->getBody());
}
$body = $stream->getBody();
}
if ($request->isGet()) {
$response = $response->withBody($body);
}
$response = $response->withHeader(
'Content-Disposition',