Lint
This commit is contained in:
parent
81e9eaba4e
commit
71d49ad74f
13 changed files with 83 additions and 39 deletions
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube;
|
||||
|
||||
use Exception;
|
||||
use Jawira\CaseConverter\CaseConverterException;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Jawira\CaseConverter\Convert;
|
||||
|
||||
|
@ -121,13 +122,6 @@ class Config
|
|||
*/
|
||||
public $appName = 'AllTube Download';
|
||||
|
||||
/**
|
||||
* YAML config file path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* Generic formats supported by youtube-dl.
|
||||
*
|
||||
|
@ -156,9 +150,9 @@ class Config
|
|||
if (empty($this->genericFormats)) {
|
||||
// We don't put this in the class definition so it can be detected by xgettext.
|
||||
$this->genericFormats = [
|
||||
'best' => $localeManager->t('Best'),
|
||||
'best' => $localeManager->t('Best'),
|
||||
'bestvideo+bestaudio' => $localeManager->t('Remux best video with best audio'),
|
||||
'worst' => $localeManager->t('Worst'),
|
||||
'worst' => $localeManager->t('Worst'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -195,10 +189,10 @@ class Config
|
|||
/**
|
||||
* Throw an exception if some of the options are invalid.
|
||||
*
|
||||
* @throws Exception If youtube-dl is missing
|
||||
* @return void
|
||||
* @throws Exception If Python is missing
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception If youtube-dl is missing
|
||||
*/
|
||||
private function validateOptions()
|
||||
{
|
||||
|
@ -235,6 +229,7 @@ class Config
|
|||
* If the value is an array, you should use the YAML format: "CONVERT_ADVANCED_FORMATS='[foo, bar]'"
|
||||
*
|
||||
* @return void
|
||||
* @throws CaseConverterException
|
||||
*/
|
||||
private function getEnv()
|
||||
{
|
||||
|
@ -265,6 +260,7 @@ class Config
|
|||
* Set options from a YAML file.
|
||||
*
|
||||
* @param string $file Path to the YAML file
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setFile($file)
|
||||
{
|
||||
|
@ -281,7 +277,8 @@ class Config
|
|||
* Manually set some options.
|
||||
*
|
||||
* @param array $options Options (see `config/config.example.yml` for available options)
|
||||
* @param bool $update True to update an existing instance
|
||||
* @param bool $update True to update an existing instance
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setOptions(array $options, $update = true)
|
||||
{
|
||||
|
|
|
@ -104,12 +104,14 @@ class Locale
|
|||
/**
|
||||
* Get country information from locale.
|
||||
*
|
||||
* @return Country|array
|
||||
* @return Country|array|null
|
||||
*/
|
||||
public function getCountry()
|
||||
{
|
||||
if (isset($this->region)) {
|
||||
return country($this->getIso3166());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
namespace Alltube;
|
||||
|
||||
use Aura\Session\Segment;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Symfony\Component\Translation\Loader\PoFileLoader;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class LocaleMiddleware
|
|||
*
|
||||
* @param array $proposedLocale Locale array created by AcceptLanguage::parse()
|
||||
*
|
||||
* @return Locale Locale if chosen, nothing otherwise
|
||||
* @return Locale|null Locale if chosen, nothing otherwise
|
||||
*/
|
||||
public function testLocale(array $proposedLocale)
|
||||
{
|
||||
|
@ -52,6 +52,8 @@ class LocaleMiddleware
|
|||
return new Locale($proposedLocale['language'] . '_' . $proposedLocale['region']);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ use Alltube\Exception\EmptyUrlException;
|
|||
use Alltube\Exception\PasswordException;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use stdClass;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
@ -124,7 +125,9 @@ class Video
|
|||
* List all extractors.
|
||||
*
|
||||
* @return string[] Extractors
|
||||
* */
|
||||
*
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public static function getExtractors()
|
||||
{
|
||||
$video = new self('');
|
||||
|
@ -172,6 +175,7 @@ class Video
|
|||
* @param string $prop Property
|
||||
*
|
||||
* @return string
|
||||
* @throws PasswordException
|
||||
*/
|
||||
private function getProp($prop = 'dump-json')
|
||||
{
|
||||
|
@ -196,7 +200,9 @@ class Video
|
|||
* Get all information about a video.
|
||||
*
|
||||
* @return stdClass Decoded JSON
|
||||
* */
|
||||
*
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getJson()
|
||||
{
|
||||
if (!isset($this->json)) {
|
||||
|
@ -212,12 +218,15 @@ class Video
|
|||
* @param string $name Property
|
||||
*
|
||||
* @return mixed
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (isset($this->$name)) {
|
||||
return $this->getJson()->$name;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,6 +235,7 @@ class Video
|
|||
* @param string $name Property
|
||||
*
|
||||
* @return bool
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
|
@ -240,7 +250,9 @@ class Video
|
|||
* (eg. bestvideo+bestaudio).
|
||||
*
|
||||
* @return string[] URLs of video
|
||||
* */
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
// Cache the URLs.
|
||||
|
@ -259,7 +271,9 @@ class Video
|
|||
* Get filename of video file from URL of page.
|
||||
*
|
||||
* @return string Filename of extracted video
|
||||
* */
|
||||
*
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
return trim($this->getProp('get-filename'));
|
||||
|
@ -271,6 +285,7 @@ class Video
|
|||
* @param string $extension New file extension
|
||||
*
|
||||
* @return string Filename of extracted video with specified extension
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getFileNameWithExtension($extension)
|
||||
{
|
||||
|
@ -601,6 +616,9 @@ class Video
|
|||
* @param array $headers HTTP headers of the request
|
||||
*
|
||||
* @return Response
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getHttpResponse(array $headers = [])
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ use Psr\Container\ContainerInterface;
|
|||
use Slim\Http\Request;
|
||||
use Slim\Views\Smarty;
|
||||
use Slim\Views\SmartyPlugins;
|
||||
use SmartyException;
|
||||
|
||||
/**
|
||||
* Create Smarty view object.
|
||||
|
@ -20,9 +21,10 @@ class ViewFactory
|
|||
* Create Smarty view object.
|
||||
*
|
||||
* @param ContainerInterface $container Slim dependency container
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
*
|
||||
* @return Smarty
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public static function create(ContainerInterface $container, Request $request = null)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube\Stream;
|
||||
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
use Slim\Http\Stream;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +21,7 @@ class ConvertedPlaylistArchiveStream extends PlaylistArchiveStream
|
|||
* @param Video $video Video to stream
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function startVideoStream(Video $video)
|
||||
{
|
||||
|
|
|
@ -86,7 +86,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
*
|
||||
* @param string $string The string that is to be written
|
||||
*
|
||||
* @return int
|
||||
* @return void
|
||||
*/
|
||||
public function write($string)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
/**
|
||||
* Get the size of the stream if known.
|
||||
*
|
||||
* @return null
|
||||
* @return void
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
|
@ -170,6 +170,8 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
if (isset($meta[$key])) {
|
||||
return $meta[$key];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -124,21 +124,21 @@ class YoutubeChunkStream implements StreamInterface
|
|||
* @param int $offset Stream offset
|
||||
* @param int $whence Specifies how the cursor position will be calculated
|
||||
*
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
return $this->response->getBody()->seek($offset, $whence);
|
||||
$this->response->getBody()->seek($offset, $whence);
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek to the beginning of the stream.
|
||||
*
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
return $this->response->getBody()->rewind();
|
||||
$this->response->getBody()->rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue