Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudloff committed May 14, 2020
2 parents bb8105e + 5051602 commit c136534
Show file tree
Hide file tree
Showing 50 changed files with 996 additions and 844 deletions.
4 changes: 3 additions & 1 deletion .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ FileETag None
</ifmodule>

<ifmodule mod_filter.c>
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
</IfModule>
</ifmodule>

<ifmodule mod_headers.c>
Expand Down
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
language: php
php: 7.3
addons:
apt:
packages:
- language-pack-fr
apt:
packages:
- language-pack-fr
install: composer install --no-progress
script:
- composer lint
- composer test
- composer lint
- composer test
38 changes: 19 additions & 19 deletions classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Alltube;

use Exception;
use Jawira\CaseConverter\CaseConverterException;
use Symfony\Component\Yaml\Yaml;
use Jawira\CaseConverter\Convert;

Expand Down Expand Up @@ -39,7 +40,7 @@ class Config
/**
* youtube-dl parameters.
*
* @var array
* @var string[]
*/
public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist'];

Expand All @@ -60,7 +61,7 @@ class Config
/**
* List of formats available in advanced conversion mode.
*
* @var array
* @var string[]
*/
public $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav'];

Expand Down Expand Up @@ -121,17 +122,10 @@ class Config
*/
public $appName = 'AllTube Download';

/**
* YAML config file path.
*
* @var string
*/
private $file;

/**
* Generic formats supported by youtube-dl.
*
* @var array
* @var string[]
*/
public $genericFormats = [];

Expand All @@ -145,7 +139,8 @@ class Config
/**
* Config constructor.
*
* @param array $options Options
* @param mixed[] $options Options
* @throws CaseConverterException
*/
private function __construct(array $options = [])
{
Expand All @@ -156,9 +151,9 @@ private function __construct(array $options = [])
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'),
];
}

Expand Down Expand Up @@ -195,10 +190,10 @@ private function replaceGenericFormat($oldFormat, $newFormat)
/**
* 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()
{
Expand All @@ -216,7 +211,7 @@ private function validateOptions()
/**
* Apply the provided options.
*
* @param array $options Options
* @param mixed[] $options Options
*
* @return void
*/
Expand All @@ -235,6 +230,7 @@ private function applyOptions(array $options)
* If the value is an array, you should use the YAML format: "CONVERT_ADVANCED_FORMATS='[foo, bar]'"
*
* @return void
* @throws CaseConverterException
*/
private function getEnv()
{
Expand Down Expand Up @@ -265,11 +261,13 @@ public static function getInstance()
* Set options from a YAML file.
*
* @param string $file Path to the YAML file
* @return void
* @throws Exception
*/
public static function setFile($file)
{
if (is_file($file)) {
$options = Yaml::parse(file_get_contents($file));
$options = Yaml::parse(strval(file_get_contents($file)));
self::$instance = new self($options);
self::$instance->validateOptions();
} else {
Expand All @@ -280,8 +278,10 @@ public static function setFile($file)
/**
* 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 mixed[] $options Options (see `config/config.example.yml` for available options)
* @param bool $update True to update an existing instance
* @return void
* @throws Exception
*/
public static function setOptions(array $options, $update = true)
{
Expand Down
4 changes: 3 additions & 1 deletion classes/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ public function getIso3166()
/**
* Get country information from locale.
*
* @return Country|array
* @return Country|Country[]|null
*/
public function getCountry()
{
if (isset($this->region)) {
return country($this->getIso3166());
}

return null;
}
}
10 changes: 6 additions & 4 deletions classes/LocaleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,7 +18,7 @@ class LocaleManager
/**
* Supported locales.
*
* @var array
* @var string[]
*/
private $supportedLocales = ['en_US', 'fr_FR', 'zh_CN', 'es_ES', 'pt_BR', 'de_DE', 'ar', 'pl_PL', 'tr_TR'];

Expand Down Expand Up @@ -112,6 +111,7 @@ public function getLocale()
* Set the current locale.
*
* @param Locale $locale Locale
* @return void
*/
public function setLocale(Locale $locale)
{
Expand All @@ -122,6 +122,7 @@ public function setLocale(Locale $locale)

/**
* Unset the current locale.
* @return void
*/
public function unsetLocale()
{
Expand All @@ -133,8 +134,8 @@ public function unsetLocale()
/**
* Smarty "t" block.
*
* @param array $params Block parameters
* @param string $text Block content
* @param mixed[] $params Block parameters
* @param string $text Block content
*
* @return string Translated string
*/
Expand All @@ -152,6 +153,7 @@ public function smartyTranslate(array $params, $text)
*
* @param string $string String to translate
*
* @param mixed[] $params
* @return string Translated string
*/
public function t($string, array $params = [])
Expand Down
10 changes: 6 additions & 4 deletions classes/LocaleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function __construct(ContainerInterface $container)
/**
* Test if a locale can be used for the current user.
*
* @param array $proposedLocale Locale array created by AcceptLanguage::parse()
* @param mixed[] $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)
{
Expand All @@ -52,14 +52,16 @@ public function testLocale(array $proposedLocale)
return new Locale($proposedLocale['language'] . '_' . $proposedLocale['region']);
}
}

return null;
}

/**
* Main middleware function.
*
* @param Request $request PSR request
* @param Request $request PSR request
* @param Response $response PSR response
* @param callable $next Next middleware
* @param callable $next Next middleware
*
* @return Response
*/
Expand Down
12 changes: 6 additions & 6 deletions classes/UglyRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UglyRouter extends Router
*
* @param ServerRequestInterface $request The current HTTP request object
*
* @return array
* @return mixed[]
*
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
*/
Expand All @@ -42,14 +42,14 @@ public function dispatch(ServerRequestInterface $request)
/**
* Build the path for a named route including the base path.
*
* @param string $name Route name
* @param array $data Named argument replacement data
* @param array $queryParams Optional query string parameters
* @param string $name Route name
* @param string[] $data Named argument replacement data
* @param string[] $queryParams Optional query string parameters
*
* @throws RuntimeException If named route does not exist
* @return string
* @throws InvalidArgumentException If required data not provided
*
* @return string
* @throws RuntimeException If named route does not exist
*/
public function pathFor($name, array $data = [], array $queryParams = [])
{
Expand Down
Loading

0 comments on commit c136534

Please sign in to comment.