diff --git a/classes/EmptyUrlException.php b/classes/EmptyUrlException.php new file mode 100644 index 0000000..663501c --- /dev/null +++ b/classes/EmptyUrlException.php @@ -0,0 +1,15 @@ +getProp($url, $format, 'get-url', $password)); if (empty($urls[0])) { - throw new Exception(_('youtube-dl returned an empty URL.')); + throw new EmptyUrlException(_('youtube-dl returned an empty URL.')); } return $urls; diff --git a/controllers/FrontController.php b/controllers/FrontController.php index aa07473..1c9dba2 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 @@ class FrontController */ 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) {