From 5aad3abc5dd8c1f1ae9dc4b8f89a485643afec1c Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 27 Dec 2016 00:01:42 +0100 Subject: [PATCH] Display error when trying to convert a M3U8 file (fixes #83) --- classes/VideoDownload.php | 3 +++ tests/VideoDownloadTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 2284840..39230c9 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -265,6 +265,9 @@ 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.')); + } //Vimeo needs a correct user-agent ini_set( diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index c1053bd..58624d8 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -323,4 +323,15 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase $config->rtmpdump = 'foobar'; $this->download->getAudioStream($url, $format); } + + /** + * Test getAudioStream function with a M3U8 file. + * + * @return void + * @expectedException Exception + */ + public function testGetAudioStreamM3uError() + { + $this->download->getAudioStream('https://twitter.com/verge/status/813055465324056576/video/1', 'best'); + } }