diff --git a/README.md b/README.md index efb526df..ce11b4fd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # AllTube Download +[![Donate using Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/Rudloff/donate) + HTML GUI for youtube-dl ([alltubedownload.net](http://alltubedownload.net/)) ![Screenshot](img/screenshot.png "AllTube GUI screenshot") diff --git a/classes/Config.php b/classes/Config.php index 8cef2635..0a06d553 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -39,7 +39,7 @@ class Config * * @var array */ - public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames']; + public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist']; /** * Enable audio conversion. diff --git a/classes/EmptyUrlException.php b/classes/EmptyUrlException.php new file mode 100644 index 00000000..663501cd --- /dev/null +++ b/classes/EmptyUrlException.php @@ -0,0 +1,15 @@ +getProp($url, $format, 'get-url', $password)); + $urls = explode("\n", $this->getProp($url, $format, 'get-url', $password)); + + if (empty($urls[0])) { + throw new EmptyUrlException(_('youtube-dl returned an empty URL.')); + } + + return $urls; } /** @@ -325,6 +331,11 @@ private function getAvconvProcess(stdClass $video, $audioBitrate, $filetype = 'm public function getAudioStream($url, $format, $password = null) { $video = $this->getJSON($url, $format, $password); + + if (isset($video->_type) && $video->_type == 'playlist') { + throw new Exception(_('Conversion of playlists is not supported.')); + } + if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) { throw new Exception(_('Conversion of M3U8 files is not supported.')); } elseif ($video->protocol == 'http_dash_segments') { diff --git a/config/config.example.yml b/config/config.example.yml index c616db5a..529fdba6 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -11,6 +11,7 @@ params: - --ignore-errors - --flat-playlist - --restrict-filenames + - --no-playlist # True to enable audio conversion convert: false diff --git a/controllers/FrontController.php b/controllers/FrontController.php index aa074734..1c9dba24 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -6,6 +6,7 @@ namespace Alltube\Controller; use Alltube\Config; +use Alltube\EmptyUrlException; use Alltube\Locale; use Alltube\LocaleManager; use Alltube\PasswordException; @@ -456,11 +457,19 @@ private function getFormat(Request $request) */ private function getRedirectResponse($url, $format, Response $response, Request $request) { - $videoUrls = $this->download->getURL( - $url, - $format, - $this->sessionSegment->getFlash($url) - ); + try { + $videoUrls = $this->download->getURL( + $url, + $format, + $this->sessionSegment->getFlash($url) + ); + } catch (EmptyUrlException $e) { + /* + If this happens it is probably a playlist + so it will either be handle by getStream() or throw an exception anyway. + */ + $videoUrls = []; + } if (count($videoUrls) > 1) { return $this->getRemuxStream($videoUrls, $format, $response, $request); } elseif ($this->config->stream) { diff --git a/package.json b/package.json index 6a2a07c2..bbec7a4e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alltube", "description": "HTML GUI for youtube-dl", - "version": "1.1.1", + "version": "1.1.2", "author": "Pierre Rudloff", "bugs": "https://github.com/Rudloff/alltube/issues", "dependencies": { diff --git a/templates/video.tpl b/templates/video.tpl index f2c2814d..cdf4242c 100644 --- a/templates/video.tpl +++ b/templates/video.tpl @@ -79,7 +79,6 @@ {/if} {/foreach} -