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:
parent
38e31c39f1
commit
2b316d4e8d
3 changed files with 18 additions and 1 deletions
|
@ -327,6 +327,8 @@ class VideoDownload
|
||||||
$video = $this->getJSON($url, $format, $password);
|
$video = $this->getJSON($url, $format, $password);
|
||||||
if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) {
|
if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) {
|
||||||
throw new Exception(_('Conversion of M3U8 files is not supported.'));
|
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);
|
$avconvProc = $this->getAvconvProcess($video, $this->config->audioBitrate);
|
||||||
|
|
|
@ -228,7 +228,11 @@ class FrontController
|
||||||
$response = $response->withHeader('Content-Type', 'audio/mpeg');
|
$response = $response->withHeader('Content-Type', 'audio/mpeg');
|
||||||
|
|
||||||
if ($request->isGet() || $request->isPost()) {
|
if ($request->isGet() || $request->isPost()) {
|
||||||
|
try {
|
||||||
$process = $this->download->getAudioStream($params['url'], 'bestaudio/best', $password);
|
$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));
|
$response = $response->withBody(new Stream($process));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,6 +406,17 @@ class VideoDownloadTest extends TestCase
|
||||||
$this->download->getAudioStream($url, $format);
|
$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.
|
* Assert that a stream is valid.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue