fix: Throw an exception when trying to download DASH with ffmpeg

Fallback to default format when we can't download bestaudio

Fixes #165
This commit is contained in:
Pierre Rudloff 2018-05-01 16:28:33 +02:00
parent 38e31c39f1
commit 2b316d4e8d
3 changed files with 18 additions and 1 deletions

View file

@ -327,6 +327,8 @@ class VideoDownload
$video = $this->getJSON($url, $format, $password);
if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) {
throw new Exception(_('Conversion of M3U8 files is not supported.'));
} elseif ($video->protocol == 'http_dash_segments') {
throw new Exception(_('Conversion of DASH segments is not supported.'));
}
$avconvProc = $this->getAvconvProcess($video, $this->config->audioBitrate);

View file

@ -228,7 +228,11 @@ class FrontController
$response = $response->withHeader('Content-Type', 'audio/mpeg');
if ($request->isGet() || $request->isPost()) {
$process = $this->download->getAudioStream($params['url'], 'bestaudio/best', $password);
try {
$process = $this->download->getAudioStream($params['url'], 'bestaudio/best', $password);
} catch (Exception $e) {
$process = $this->download->getAudioStream($params['url'], $this->defaultFormat, $password);
}
$response = $response->withBody(new Stream($process));
}

View file

@ -406,6 +406,17 @@ class VideoDownloadTest extends TestCase
$this->download->getAudioStream($url, $format);
}
/**
* Test getAudioStream function with a DASH URL.
*
* @return void
* @expectedException Exception
*/
public function testGetAudioStreamDashError()
{
$this->download->getAudioStream('https://vimeo.com/251997032', 'bestaudio/best');
}
/**
* Assert that a stream is valid.
*