Move Video class to a separate library
+ improve error handling + youtube-dl update
This commit is contained in:
parent
7d94271a49
commit
5c2823e3f1
30 changed files with 649 additions and 1152 deletions
|
@ -7,12 +7,14 @@
|
|||
namespace Alltube\Controller;
|
||||
|
||||
use Alltube\Config;
|
||||
use Alltube\Library\Downloader;
|
||||
use Alltube\Library\Video;
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\SessionManager;
|
||||
use Alltube\Video;
|
||||
use Aura\Session\Segment;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
/**
|
||||
* Abstract class used by every controller.
|
||||
|
@ -61,6 +63,13 @@ abstract class BaseController
|
|||
*/
|
||||
protected $localeManager;
|
||||
|
||||
/**
|
||||
* Downloader instance.
|
||||
*
|
||||
* @var Downloader
|
||||
*/
|
||||
protected $downloader;
|
||||
|
||||
/**
|
||||
* BaseController constructor.
|
||||
*
|
||||
|
@ -73,6 +82,7 @@ abstract class BaseController
|
|||
$session = SessionManager::getSession();
|
||||
$this->sessionSegment = $session->getSegment(self::class);
|
||||
$this->localeManager = $this->container->get('locale');
|
||||
$this->downloader = $this->config->getDownloader();
|
||||
|
||||
if (!$this->config->stream) {
|
||||
// Force HTTP if stream is not enabled.
|
||||
|
@ -117,4 +127,20 @@ abstract class BaseController
|
|||
|
||||
return $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an user-friendly error.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
* @param string $message Error message
|
||||
*
|
||||
* @return Response HTTP response
|
||||
*/
|
||||
protected function displayError(Request $request, Response $response, $message)
|
||||
{
|
||||
$controller = new FrontController($this->container);
|
||||
|
||||
return $controller->displayError($request, $response, $message);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue