Support audio conversion of password protected videos

This commit is contained in:
Pierre Rudloff 2016-10-20 23:13:37 +02:00
parent 75ddf27a95
commit efe0b97d7f
2 changed files with 16 additions and 12 deletions

View file

@ -143,19 +143,21 @@ class FrontController
}
if (isset($params['audio'])) {
try {
$url = $this->download->getURL($params['url'], 'mp3[protocol^=http]');
$url = $this->download->getURL($params['url'], 'mp3[protocol^=http]', $password);
return $response->withRedirect($url);
} catch (PasswordException $e) {
return $this->password($request, $response);
} catch (\Exception $e) {
$response = $response->withHeader(
'Content-Disposition',
'attachment; filename="'.
$this->download->getAudioFilename($params['url'], 'bestaudio/best').'"'
$this->download->getAudioFilename($params['url'], 'bestaudio/best', $password).'"'
);
$response = $response->withHeader('Content-Type', 'audio/mpeg');
if ($request->isGet()) {
$process = $this->download->getAudioStream($params['url'], 'bestaudio/best');
if ($request->isGet() || $request->isPost()) {
$process = $this->download->getAudioStream($params['url'], 'bestaudio/best', $password);
$response = $response->withBody(new Stream($process));
}