From 04fe43a1ca0222aa37f1f0127b952d43a81e8a9a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 5 Feb 2018 16:48:58 +0100 Subject: [PATCH 1/7] style: Declare imported classes at the top of the file --- classes/Config.php | 3 +- classes/Locale.php | 6 ++- classes/LocaleManager.php | 8 ++-- classes/PasswordException.php | 4 +- classes/PlaylistArchiveStream.php | 5 ++- classes/UglyRouter.php | 6 ++- classes/VideoDownload.php | 72 ++++++++++++++++--------------- controllers/FrontController.php | 31 +++++++------ index.php | 2 +- tests/FrontControllerTest.php | 3 +- tests/LocaleManagerTest.php | 2 +- tests/VideoDownloadTest.php | 2 +- 12 files changed, 81 insertions(+), 63 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index f7e725b..8cef263 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -5,6 +5,7 @@ namespace Alltube; +use Exception; use Symfony\Component\Yaml\Yaml; /** @@ -172,7 +173,7 @@ class Config */ $options = []; } else { - throw new \Exception("Can't find config file at ".$yamlPath); + throw new Exception("Can't find config file at ".$yamlPath); } self::$instance = new self($options); self::$instance->file = $yamlfile; diff --git a/classes/Locale.php b/classes/Locale.php index 5392316..9ccf020 100644 --- a/classes/Locale.php +++ b/classes/Locale.php @@ -5,6 +5,8 @@ namespace Alltube; +use Locale as PHPLocale; +use Rinvex\Country\Country; use Teto\HTTP\AcceptLanguage; /** @@ -55,7 +57,7 @@ class Locale */ public function getFullName() { - return \Locale::getDisplayName($this->getIso15897(), $this->getIso15897()); + return PHPLocale::getDisplayName($this->getIso15897(), $this->getIso15897()); } /** @@ -91,7 +93,7 @@ class Locale /** * Get country information from locale. * - * @return \Rinvex\Country\Country|array + * @return Country|array */ public function getCountry() { diff --git a/classes/LocaleManager.php b/classes/LocaleManager.php index 829e2a6..3efa390 100644 --- a/classes/LocaleManager.php +++ b/classes/LocaleManager.php @@ -5,6 +5,8 @@ namespace Alltube; +use Aura\Session\Segment; +use Aura\Session\SessionFactory; use Symfony\Component\Process\Process; /** @@ -29,7 +31,7 @@ class LocaleManager /** * Session segment used to store session variables. * - * @var \Aura\Session\Segment + * @var Segment */ private $sessionSegment; @@ -40,9 +42,9 @@ class LocaleManager */ public function __construct(array $cookies = []) { - $session_factory = new \Aura\Session\SessionFactory(); + $session_factory = new SessionFactory(); $session = $session_factory->newInstance($cookies); - $this->sessionSegment = $session->getSegment('Alltube\LocaleManager'); + $this->sessionSegment = $session->getSegment(self::class); $cookieLocale = $this->sessionSegment->get('locale'); if (isset($cookieLocale)) { $this->setLocale(new Locale($cookieLocale)); diff --git a/classes/PasswordException.php b/classes/PasswordException.php index 6ede500..598ca92 100644 --- a/classes/PasswordException.php +++ b/classes/PasswordException.php @@ -5,9 +5,11 @@ namespace Alltube; +use Exception; + /** * Exception thrown when a video requires a password. */ -class PasswordException extends \Exception +class PasswordException extends Exception { } diff --git a/classes/PlaylistArchiveStream.php b/classes/PlaylistArchiveStream.php index 6c6dfbe..3c45a04 100644 --- a/classes/PlaylistArchiveStream.php +++ b/classes/PlaylistArchiveStream.php @@ -8,6 +8,7 @@ namespace Alltube; use Barracuda\ArchiveStream\TarArchive; +use GuzzleHttp\Client; /** * Class used to create a Tar archive from playlists and stream it to the browser. @@ -33,7 +34,7 @@ class PlaylistArchiveStream extends TarArchive /** * Guzzle client. * - * @var \GuzzleHttp\Client + * @var Client */ private $client; @@ -65,7 +66,7 @@ class PlaylistArchiveStream extends TarArchive */ public function __construct(Config $config = null) { - $this->client = new \GuzzleHttp\Client(); + $this->client = new Client(); $this->download = new VideoDownload($config); } diff --git a/classes/UglyRouter.php b/classes/UglyRouter.php index c574480..abfca22 100644 --- a/classes/UglyRouter.php +++ b/classes/UglyRouter.php @@ -5,7 +5,9 @@ namespace Alltube; +use InvalidArgumentException; use Psr\Http\Message\ServerRequestInterface; +use RuntimeException; use Slim\Router; /** @@ -43,8 +45,8 @@ class UglyRouter extends Router * @param array $data Named argument replacement data * @param array $queryParams Optional query string parameters * - * @throws \RuntimeException If named route does not exist - * @throws \InvalidArgumentException If required data not provided + * @throws RuntimeException If named route does not exist + * @throws InvalidArgumentException If required data not provided * * @return string */ diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 5720a82..475d63a 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -5,6 +5,8 @@ namespace Alltube; +use Exception; +use stdClass; use Symfony\Component\Process\Process; /** @@ -24,8 +26,8 @@ class VideoDownload * * @param Config $config Config instance. * - * @throws \Exception If youtube-dl is missing - * @throws \Exception If Python is missing + * @throws Exception If youtube-dl is missing + * @throws Exception If Python is missing */ public function __construct(Config $config = null) { @@ -39,9 +41,9 @@ class VideoDownload so they will always go to the logs. */ if (!is_file($this->config->youtubedl)) { - throw new \Exception("Can't find youtube-dl at ".$this->config->youtubedl); + throw new Exception("Can't find youtube-dl at ".$this->config->youtubedl); } elseif (!$this->checkCommand([$this->config->python, '--version'])) { - throw new \Exception("Can't find Python at ".$this->config->python); + throw new Exception("Can't find Python at ".$this->config->python); } } @@ -82,8 +84,8 @@ class VideoDownload * @param string $password Video password * * @throws PasswordException If the video is protected by a password and no password was specified - * @throws \Exception If the password is wrong - * @throws \Exception If youtube-dl returns an error + * @throws Exception If the password is wrong + * @throws Exception If youtube-dl returns an error * * @return string */ @@ -111,9 +113,9 @@ class VideoDownload if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') { throw new PasswordException($errorOutput); } elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { - throw new \Exception(_('Wrong password')); + throw new Exception(_('Wrong password')); } else { - throw new \Exception($errorOutput); + throw new Exception($errorOutput); } } else { return trim($process->getOutput()); @@ -209,7 +211,7 @@ class VideoDownload * * @return array Arguments */ - private function getRtmpArguments(\stdClass $video) + private function getRtmpArguments(stdClass $video) { $arguments = []; @@ -260,14 +262,14 @@ class VideoDownload * @param string $filetype Filetype of the converted file * @param bool $audioOnly True to return an audio-only file * - * @throws \Exception If avconv/ffmpeg is missing + * @throws Exception If avconv/ffmpeg is missing * * @return Process Process */ - private function getAvconvProcess(\stdClass $video, $audioBitrate, $filetype = 'mp3', $audioOnly = true) + private function getAvconvProcess(stdClass $video, $audioBitrate, $filetype = 'mp3', $audioOnly = true) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { - throw(new \Exception(_('Can\'t find avconv or ffmpeg.'))); + throw(new Exception(_('Can\'t find avconv or ffmpeg.'))); } if ($video->protocol == 'rtmp') { @@ -314,8 +316,8 @@ class VideoDownload * @param string $format Format to use for the video * @param string $password Video password * - * @throws \Exception If your try to convert and M3U8 video - * @throws \Exception If the popen stream was not created correctly + * @throws Exception If your try to convert and M3U8 video + * @throws Exception If the popen stream was not created correctly * * @return resource popen stream */ @@ -323,7 +325,7 @@ 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.'))); + throw(new Exception(_('Conversion of M3U8 files is not supported.'))); } $avconvProc = $this->getAvconvProcess($video, $this->config->audioBitrate); @@ -331,7 +333,7 @@ class VideoDownload $stream = popen($avconvProc->getCommandLine(), 'r'); if (!is_resource($stream)) { - throw new \Exception(_('Could not open popen stream.')); + throw new Exception(_('Could not open popen stream.')); } return $stream; @@ -340,17 +342,17 @@ class VideoDownload /** * Get video stream from an M3U playlist. * - * @param \stdClass $video Video object returned by getJSON + * @param stdClass $video Video object returned by getJSON * - * @throws \Exception If avconv/ffmpeg is missing - * @throws \Exception If the popen stream was not created correctly + * @throws Exception If avconv/ffmpeg is missing + * @throws Exception If the popen stream was not created correctly * * @return resource popen stream */ - public function getM3uStream(\stdClass $video) + public function getM3uStream(stdClass $video) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { - throw(new \Exception(_('Can\'t find avconv or ffmpeg.'))); + throw(new Exception(_('Can\'t find avconv or ffmpeg.'))); } $process = new Process( @@ -368,7 +370,7 @@ class VideoDownload $stream = popen($process->getCommandLine(), 'r'); if (!is_resource($stream)) { - throw new \Exception(_('Could not open popen stream.')); + throw new Exception(_('Could not open popen stream.')); } return $stream; @@ -379,7 +381,7 @@ class VideoDownload * * @param array $urls URLs of the video ($urls[0]) and audio ($urls[1]) files * - * @throws \Exception If the popen stream was not created correctly + * @throws Exception If the popen stream was not created correctly * * @return resource popen stream */ @@ -401,7 +403,7 @@ class VideoDownload $stream = popen($process->getCommandLine(), 'r'); if (!is_resource($stream)) { - throw new \Exception(_('Could not open popen stream.')); + throw new Exception(_('Could not open popen stream.')); } return $stream; @@ -410,13 +412,13 @@ class VideoDownload /** * Get video stream from an RTMP video. * - * @param \stdClass $video Video object returned by getJSON + * @param stdClass $video Video object returned by getJSON * - * @throws \Exception If the popen stream was not created correctly + * @throws Exception If the popen stream was not created correctly * * @return resource popen stream */ - public function getRtmpStream(\stdClass $video) + public function getRtmpStream(stdClass $video) { $process = new Process( array_merge( @@ -434,7 +436,7 @@ class VideoDownload ); $stream = popen($process->getCommandLine(), 'r'); if (!is_resource($stream)) { - throw new \Exception(_('Could not open popen stream.')); + throw new Exception(_('Could not open popen stream.')); } return $stream; @@ -446,11 +448,11 @@ class VideoDownload * @param object $video Video object returned by youtube-dl * @param string $format Requested format * - * @throws \Exception If the popen stream was not created correctly + * @throws Exception If the popen stream was not created correctly * * @return resource */ - public function getPlaylistArchiveStream(\stdClass $video, $format) + public function getPlaylistArchiveStream(stdClass $video, $format) { $playlistItems = []; foreach ($video->entries as $entry) { @@ -458,7 +460,7 @@ class VideoDownload } $stream = fopen('playlist://'.implode(';', $playlistItems).'/'.$format, 'r'); if (!is_resource($stream)) { - throw new \Exception(_('Could not open fopen stream.')); + throw new Exception(_('Could not open fopen stream.')); } return $stream; @@ -473,8 +475,8 @@ class VideoDownload * @param string $filetype Filetype of the converted file * @param string $password Video password * - * @throws \Exception If your try to convert and M3U8 video - * @throws \Exception If the popen stream was not created correctly + * @throws Exception If your try to convert and M3U8 video + * @throws Exception If the popen stream was not created correctly * * @return resource popen stream */ @@ -482,7 +484,7 @@ 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.'))); + throw(new Exception(_('Conversion of M3U8 files is not supported.'))); } $avconvProc = $this->getAvconvProcess($video, $audioBitrate, $filetype, false); @@ -490,7 +492,7 @@ class VideoDownload $stream = popen($avconvProc->getCommandLine(), 'r'); if (!is_resource($stream)) { - throw new \Exception(_('Could not open popen stream.')); + throw new Exception(_('Could not open popen stream.')); } return $stream; diff --git a/controllers/FrontController.php b/controllers/FrontController.php index b6962e2..8108bd6 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -10,11 +10,16 @@ use Alltube\Locale; use Alltube\LocaleManager; use Alltube\PasswordException; use Alltube\VideoDownload; +use Aura\Session\Segment; +use Aura\Session\SessionFactory; +use Exception; +use GuzzleHttp\Client; use Psr\Container\ContainerInterface; use Slim\Container; use Slim\Http\Request; use Slim\Http\Response; use Slim\Http\Stream; +use Slim\Views\Smarty; /** * Main controller. @@ -45,14 +50,14 @@ class FrontController /** * Session segment used to store session variables. * - * @var \Aura\Session\Segment + * @var Segment */ private $sessionSegment; /** * Smarty view. * - * @var \Slim\Views\Smarty + * @var Smarty */ private $view; @@ -88,9 +93,9 @@ class FrontController $this->container = $container; $this->view = $this->container->get('view'); $this->localeManager = $this->container->get('locale'); - $session_factory = new \Aura\Session\SessionFactory(); + $session_factory = new SessionFactory(); $session = $session_factory->newInstance($cookies); - $this->sessionSegment = $session->getSegment('Alltube\Controller\FrontController'); + $this->sessionSegment = $session->getSegment(self::class); if ($this->config->stream) { $this->defaultFormat = 'best'; } @@ -214,7 +219,7 @@ class FrontController } } catch (PasswordException $e) { return $this->password($request, $response); - } catch (\Exception $e) { + } catch (Exception $e) { $response = $response->withHeader( 'Content-Disposition', 'attachment; filename="'. @@ -311,13 +316,13 @@ class FrontController /** * Display an error page. * - * @param Request $request PSR-7 request - * @param Response $response PSR-7 response - * @param \Exception $exception Error to display + * @param Request $request PSR-7 request + * @param Response $response PSR-7 response + * @param Exception $exception Error to display * * @return Response HTTP response */ - public function error(Request $request, Response $response, \Exception $exception) + public function error(Request $request, Response $response, Exception $exception) { $this->view->render( $response, @@ -366,7 +371,7 @@ class FrontController $response = $response->withHeader('Content-Type', 'video/'.$video->ext); $body = new Stream($stream); } else { - $client = new \GuzzleHttp\Client(); + $client = new Client(); $stream = $client->request('GET', $video->url, ['stream' => true]); $response = $response->withHeader('Content-Type', $stream->getHeader('Content-Type')); $response = $response->withHeader('Content-Length', $stream->getHeader('Content-Length')); @@ -397,7 +402,7 @@ class FrontController private function getRemuxStream(array $urls, $format, Response $response, Request $request) { if (!$this->config->remux) { - throw new \Exception(_('You need to enable remux mode to merge two formats.')); + throw new Exception(_('You need to enable remux mode to merge two formats.')); } $stream = $this->download->getRemuxStream($urls); $response = $response->withHeader('Content-Type', 'video/x-matroska'); @@ -464,7 +469,7 @@ class FrontController ); } else { if (empty($videoUrls[0])) { - throw new \Exception(_("Can't find URL of video.")); + throw new Exception(_("Can't find URL of video.")); } return $response->withRedirect($videoUrls[0]); @@ -533,7 +538,7 @@ class FrontController return $response->withRedirect( $this->container->get('router')->pathFor('video').'?url='.urlencode($params['url']) ); - } catch (\Exception $e) { + } catch (Exception $e) { $response->getBody()->write($e->getMessage()); return $response->withHeader('Content-Type', 'text/plain')->withStatus(500); diff --git a/index.php b/index.php index 13a7686..37eb1d6 100644 --- a/index.php +++ b/index.php @@ -58,6 +58,6 @@ $app->get( try { $app->run(); -} catch (\SmartyException $e) { +} catch (SmartyException $e) { die('Smarty could not compile the template file: '.$e->getMessage()); } diff --git a/tests/FrontControllerTest.php b/tests/FrontControllerTest.php index 2c5566b..7e3348a 100644 --- a/tests/FrontControllerTest.php +++ b/tests/FrontControllerTest.php @@ -9,6 +9,7 @@ use Alltube\Config; use Alltube\Controller\FrontController; use Alltube\LocaleManager; use Alltube\ViewFactory; +use Exception; use PHPUnit\Framework\TestCase; use Slim\Container; use Slim\Http\Environment; @@ -348,7 +349,7 @@ class FrontControllerTest extends TestCase */ public function testError() { - $result = $this->controller->error($this->request, $this->response, new \Exception('foo')); + $result = $this->controller->error($this->request, $this->response, new Exception('foo')); $this->assertTrue($result->isServerError()); } diff --git a/tests/LocaleManagerTest.php b/tests/LocaleManagerTest.php index ae9cb14..2fff818 100644 --- a/tests/LocaleManagerTest.php +++ b/tests/LocaleManagerTest.php @@ -27,7 +27,7 @@ class LocaleManagerTest extends TestCase protected function setUp() { $this->localeManager = new LocaleManager(); - $_SESSION['Alltube\LocaleManager']['locale'] = 'foo_BAR'; + $_SESSION[LocaleManager::class]['locale'] = 'foo_BAR'; } /** diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 3b41aa8..5a91b17 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -126,7 +126,7 @@ class VideoDownloadTest extends TestCase * Test getURL function with a protected video and no password. * * @return void - * @expectedException \Alltube\PasswordException + * @expectedException Alltube\PasswordException */ public function testGetURLWithMissingPassword() { From 5a527373bdd5b15cfb2254ea6b0fd1baa9ed264d Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 6 Feb 2018 19:11:57 +0100 Subject: [PATCH 2/7] style: throw is not a function --- classes/VideoDownload.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 475d63a..79b89e4 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -269,7 +269,7 @@ class VideoDownload private function getAvconvProcess(stdClass $video, $audioBitrate, $filetype = 'mp3', $audioOnly = true) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { - throw(new Exception(_('Can\'t find avconv or ffmpeg.'))); + throw new Exception(_('Can\'t find avconv or ffmpeg.')); } if ($video->protocol == 'rtmp') { @@ -325,7 +325,7 @@ 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.'))); + throw new Exception(_('Conversion of M3U8 files is not supported.')); } $avconvProc = $this->getAvconvProcess($video, $this->config->audioBitrate); @@ -352,7 +352,7 @@ class VideoDownload public function getM3uStream(stdClass $video) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { - throw(new Exception(_('Can\'t find avconv or ffmpeg.'))); + throw new Exception(_('Can\'t find avconv or ffmpeg.')); } $process = new Process( @@ -484,7 +484,7 @@ 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.'))); + throw new Exception(_('Conversion of M3U8 files is not supported.')); } $avconvProc = $this->getAvconvProcess($video, $audioBitrate, $filetype, false); From b27fa518c9ba30cd1eddc5060b4f152eec6c38c8 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 6 Feb 2018 19:20:56 +0100 Subject: [PATCH 3/7] feat: Add youtube-dl exit code to the exceptions --- classes/VideoDownload.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 79b89e4..15f76a3 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -110,12 +110,13 @@ class VideoDownload $process->run(); if (!$process->isSuccessful()) { $errorOutput = trim($process->getErrorOutput()); + $exitCode = $process->getExitCode(); if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') { - throw new PasswordException($errorOutput); + throw new PasswordException($errorOutput, $exitCode); } elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { - throw new Exception(_('Wrong password')); + throw new Exception(_('Wrong password'), $exitCode); } else { - throw new Exception($errorOutput); + throw new Exception($errorOutput, $exitCode); } } else { return trim($process->getOutput()); From a8cd915f01b80f396c8a69787eea71d530975a4a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 6 Feb 2018 19:31:15 +0100 Subject: [PATCH 4/7] build(composer): Dependencies update Updated: phpunit/phpunit, symfony/process, symfony/var-dumper, symfony/yaml --- composer.lock | 84 +++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/composer.lock b/composer.lock index c799ce7..dba6e0c 100644 --- a/composer.lock +++ b/composer.lock @@ -1139,16 +1139,16 @@ }, { "name": "symfony/process", - "version": "v3.4.3", + "version": "v3.4.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba" + "reference": "09a5172057be8fc677840e591b17f385e58c7c0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/ff69f110c6b33fd33cd2089ba97d6112f44ef0ba", - "reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba", + "url": "https://api.github.com/repos/symfony/process/zipball/09a5172057be8fc677840e591b17f385e58c7c0d", + "reference": "09a5172057be8fc677840e591b17f385e58c7c0d", "shasum": "" }, "require": { @@ -1184,20 +1184,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:37:34+00:00" + "time": "2018-01-29T09:03:43+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.3", + "version": "v3.4.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "25c192f25721a74084272671f658797d9e0e0146" + "reference": "eab73b6c21d27ae4cd037c417618dfd4befb0bfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/25c192f25721a74084272671f658797d9e0e0146", - "reference": "25c192f25721a74084272671f658797d9e0e0146", + "url": "https://api.github.com/repos/symfony/yaml/zipball/eab73b6c21d27ae4cd037c417618dfd4befb0bfe", + "reference": "eab73b6c21d27ae4cd037c417618dfd4befb0bfe", "shasum": "" }, "require": { @@ -1242,7 +1242,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:37:34+00:00" + "time": "2018-01-21T19:05:02+00:00" }, { "name": "zonuexe/http-accept-language", @@ -1644,16 +1644,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.2.0", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "66465776cfc249844bde6d117abff1d22e06c2da" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/66465776cfc249844bde6d117abff1d22e06c2da", - "reference": "66465776cfc249844bde6d117abff1d22e06c2da", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { @@ -1691,7 +1691,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-27T17:38:31+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -2013,16 +2013,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.5", + "version": "6.5.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "83d27937a310f2984fd575686138597147bdc7df" + "reference": "3330ef26ade05359d006041316ed0fa9e8e3cefe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/83d27937a310f2984fd575686138597147bdc7df", - "reference": "83d27937a310f2984fd575686138597147bdc7df", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3330ef26ade05359d006041316ed0fa9e8e3cefe", + "reference": "3330ef26ade05359d006041316ed0fa9e8e3cefe", "shasum": "" }, "require": { @@ -2093,7 +2093,7 @@ "testing", "xunit" ], - "time": "2017-12-17T06:31:19+00:00" + "time": "2018-02-01T05:57:37+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -2212,21 +2212,21 @@ }, { "name": "sebastian/comparator", - "version": "2.1.2", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "11c07feade1d65453e06df3b3b90171d6d982087" + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/11c07feade1d65453e06df3b3b90171d6d982087", - "reference": "11c07feade1d65453e06df3b3b90171d6d982087", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", "shasum": "" }, "require": { "php": "^7.0", - "sebastian/diff": "^2.0", + "sebastian/diff": "^2.0 || ^3.0", "sebastian/exporter": "^3.1" }, "require-dev": { @@ -2272,7 +2272,7 @@ "compare", "equality" ], - "time": "2018-01-12T06:34:42+00:00" + "time": "2018-02-01T13:46:46+00:00" }, { "name": "sebastian/diff", @@ -2777,16 +2777,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", "shasum": "" }, "require": { @@ -2798,7 +2798,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.7-dev" } }, "autoload": { @@ -2832,20 +2832,20 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-01-30T19:27:44+00:00" }, { "name": "symfony/var-dumper", - "version": "v3.4.3", + "version": "v3.4.4", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "545be7e78ccbec43e599f10ff7500d0b09eda9d0" + "reference": "472a9849930cf21f73abdb02240f17cf5b5bd1a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/545be7e78ccbec43e599f10ff7500d0b09eda9d0", - "reference": "545be7e78ccbec43e599f10ff7500d0b09eda9d0", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/472a9849930cf21f73abdb02240f17cf5b5bd1a7", + "reference": "472a9849930cf21f73abdb02240f17cf5b5bd1a7", "shasum": "" }, "require": { @@ -2901,7 +2901,7 @@ "debug", "dump" ], - "time": "2018-01-03T17:14:19+00:00" + "time": "2018-01-29T09:03:43+00:00" }, { "name": "theseer/tokenizer", @@ -2945,16 +2945,16 @@ }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -2991,7 +2991,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], From 003452909a772e6237b6c81d737c8b42650b9153 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 21 Feb 2018 18:55:12 +0100 Subject: [PATCH 5/7] feat: Add path to "Can't find avconv" error See #109 --- classes/VideoDownload.php | 4 ++-- i18n/template.pot | 40 +++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 15f76a3..f022c31 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -270,7 +270,7 @@ class VideoDownload private function getAvconvProcess(stdClass $video, $audioBitrate, $filetype = 'mp3', $audioOnly = true) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { - throw new Exception(_('Can\'t find avconv or ffmpeg.')); + throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.'); } if ($video->protocol == 'rtmp') { @@ -353,7 +353,7 @@ class VideoDownload public function getM3uStream(stdClass $video) { if (!$this->checkCommand([$this->config->avconv, '-version'])) { - throw new Exception(_('Can\'t find avconv or ffmpeg.')); + throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.'); } $process = new Process( diff --git a/i18n/template.pot b/i18n/template.pot index 010b9e3..ec28874 100644 --- a/i18n/template.pot +++ b/i18n/template.pot @@ -19,7 +19,7 @@ msgstr "" #: templates/playlist.tpl:26 templates/password.tpl:10 templates/video.tpl:97 #: templates/video.tpl:100 templates/index.tpl:19 -#: controllers/FrontController.php:265 +#: controllers/FrontController.php:270 msgid "Download" msgstr "" @@ -39,7 +39,7 @@ msgstr "" msgid "Video password" msgstr "" -#: templates/extractors.tpl:4 controllers/FrontController.php:159 +#: templates/extractors.tpl:4 controllers/FrontController.php:164 msgid "Supported websites" msgstr "" @@ -139,68 +139,68 @@ msgstr "" msgid "Bookmarklet" msgstr "" -#: classes/VideoDownload.php:114 +#: classes/VideoDownload.php:117 msgid "Wrong password" msgstr "" -#: classes/VideoDownload.php:270 classes/VideoDownload.php:353 -msgid "Can't find avconv or ffmpeg." +#: classes/VideoDownload.php:273 classes/VideoDownload.php:356 +msgid "Can't find avconv or ffmpeg at " msgstr "" -#: classes/VideoDownload.php:326 classes/VideoDownload.php:485 +#: classes/VideoDownload.php:329 classes/VideoDownload.php:488 msgid "Conversion of M3U8 files is not supported." msgstr "" -#: classes/VideoDownload.php:334 classes/VideoDownload.php:371 -#: classes/VideoDownload.php:404 classes/VideoDownload.php:437 -#: classes/VideoDownload.php:493 +#: classes/VideoDownload.php:337 classes/VideoDownload.php:374 +#: classes/VideoDownload.php:407 classes/VideoDownload.php:440 +#: classes/VideoDownload.php:496 msgid "Could not open popen stream." msgstr "" -#: classes/VideoDownload.php:461 +#: classes/VideoDownload.php:464 msgid "Could not open fopen stream." msgstr "" -#: controllers/FrontController.php:116 +#: controllers/FrontController.php:121 msgid "" "Easily download videos from Youtube, Dailymotion, Vimeo and other websites." msgstr "" -#: controllers/FrontController.php:160 +#: controllers/FrontController.php:165 msgid "" "List of all supported websites from which Alltube Download can extract video " "or audio files" msgstr "" -#: controllers/FrontController.php:185 +#: controllers/FrontController.php:190 msgid "Password prompt" msgstr "" -#: controllers/FrontController.php:186 +#: controllers/FrontController.php:191 msgid "" "You need a password in order to download this video with Alltube Download" msgstr "" -#: controllers/FrontController.php:261 +#: controllers/FrontController.php:266 msgid "Video download" msgstr "" -#: controllers/FrontController.php:262 +#: controllers/FrontController.php:267 msgid "Download video from " msgstr "" -#: controllers/FrontController.php:265 +#: controllers/FrontController.php:270 msgid "from" msgstr "" -#: controllers/FrontController.php:328 +#: controllers/FrontController.php:333 msgid "Error" msgstr "" -#: controllers/FrontController.php:400 +#: controllers/FrontController.php:405 msgid "You need to enable remux mode to merge two formats." msgstr "" -#: controllers/FrontController.php:467 +#: controllers/FrontController.php:472 msgid "Can't find URL of video." msgstr "" From da2bdcbe40acc3631eff5f5a708a08aa63288bee Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 21 Feb 2018 18:56:59 +0100 Subject: [PATCH 6/7] Update Alltube.po (POEditor.com) --- i18n/fr_FR/LC_MESSAGES/Alltube.po | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/i18n/fr_FR/LC_MESSAGES/Alltube.po b/i18n/fr_FR/LC_MESSAGES/Alltube.po index 88c171e..14b0d45 100644 --- a/i18n/fr_FR/LC_MESSAGES/Alltube.po +++ b/i18n/fr_FR/LC_MESSAGES/Alltube.po @@ -21,7 +21,7 @@ msgstr " :" #: templates/playlist.tpl:26 templates/password.tpl:10 templates/video.tpl:97 #: templates/video.tpl:100 templates/index.tpl:19 -#: controllers/FrontController.php:265 +#: controllers/FrontController.php:270 msgid "Download" msgstr "Télécharger" @@ -41,7 +41,7 @@ msgstr "L'accès à cette vidéo nécessite un mot de passe." msgid "Video password" msgstr "Mot de passe de la vidéo" -#: templates/extractors.tpl:4 controllers/FrontController.php:159 +#: templates/extractors.tpl:4 controllers/FrontController.php:164 msgid "Supported websites" msgstr "Sites web supportés" @@ -145,65 +145,65 @@ msgstr "kbit/s" msgid "with" msgstr "avec de l'audio à" -#: classes/VideoDownload.php:114 +#: classes/VideoDownload.php:117 msgid "Wrong password" msgstr "Mauvais mot de passe" -#: classes/VideoDownload.php:270 classes/VideoDownload.php:353 -msgid "Can't find avconv or ffmpeg." -msgstr "Impossible de trouver avconv ou ffmpeg." - -#: classes/VideoDownload.php:326 classes/VideoDownload.php:485 +#: classes/VideoDownload.php:329 classes/VideoDownload.php:488 msgid "Conversion of M3U8 files is not supported." msgstr "La conversion des fichiers M3U8 n'est pas possible." -#: classes/VideoDownload.php:334 classes/VideoDownload.php:371 -#: classes/VideoDownload.php:404 classes/VideoDownload.php:437 -#: classes/VideoDownload.php:493 +#: classes/VideoDownload.php:337 classes/VideoDownload.php:374 +#: classes/VideoDownload.php:407 classes/VideoDownload.php:440 +#: classes/VideoDownload.php:496 msgid "Could not open popen stream." msgstr "Impossible d'ouvrir le flux popen." -#: classes/VideoDownload.php:461 +#: classes/VideoDownload.php:464 msgid "Could not open fopen stream." msgstr "Impossible d'ouvrir le flux fopen." -#: controllers/FrontController.php:116 +#: controllers/FrontController.php:121 msgid "Easily download videos from Youtube, Dailymotion, Vimeo and other websites." msgstr "Téléchargez facilement des vidéos depuis Youtube, Dailymotion, Vimeo et d'autres sites web." -#: controllers/FrontController.php:160 +#: controllers/FrontController.php:165 msgid "List of all supported websites from which Alltube Download can extract video or audio files" msgstr "Liste de tous les sites web depuis lesquels Alltube Download peut extraire des fichiers vidéo ou audio" -#: controllers/FrontController.php:185 +#: controllers/FrontController.php:190 msgid "Password prompt" msgstr "Demande de mot de passe" -#: controllers/FrontController.php:186 +#: controllers/FrontController.php:191 msgid "You need a password in order to download this video with Alltube Download" msgstr "Vous avez besoin d'un mot de passe pour télécharger cette vidéo avec Alltube Download" -#: controllers/FrontController.php:261 +#: controllers/FrontController.php:266 msgid "Video download" msgstr "Téléchargement d'une vidéo" -#: controllers/FrontController.php:262 +#: controllers/FrontController.php:267 msgid "Download video from " msgstr "Téléchargement d'une vidéo depuis " -#: controllers/FrontController.php:265 +#: controllers/FrontController.php:270 msgid "from" msgstr "depuis" -#: controllers/FrontController.php:328 +#: controllers/FrontController.php:333 msgid "Error" msgstr "Erreur" -#: controllers/FrontController.php:400 +#: controllers/FrontController.php:405 msgid "You need to enable remux mode to merge two formats." msgstr "Vous devez activer le mode remux pour fusionner deux formats." -#: controllers/FrontController.php:467 +#: controllers/FrontController.php:472 msgid "Can't find URL of video." msgstr "Impossible de trouver l'URL de la vidéo." +#: classes/VideoDownload.php:273 classes/VideoDownload.php:356 +msgid "Can't find avconv or ffmpeg at " +msgstr "Impossible de trouver avconv ou ffmpeg à " + From c4506cfcf1dff72b0833a13958322c94ed276363 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 21 Feb 2018 19:16:50 +0100 Subject: [PATCH 7/7] test: Replace deleted openload.co video VideoDownload tests --- tests/VideoDownloadTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 5a91b17..a999e6f 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -198,8 +198,8 @@ class VideoDownloadTest extends TestCase 'edgefcs.net', ], [ - 'https://openload.co/embed/qTsjMEUtN4U', 'best[protocol^=http]', - 'aup-the-lego-ninjago-movie-2017-1508463762.MP4.mp4-qTsjMEUtN4U', + 'https://openload.co/f/kUEfGclsU9o', 'best[protocol^=http]', + 'skyrim_no-audio_1080.mp4-kUEfGclsU9o', 'mp4', 'openload.co', ],