Merge branch 'release-2.3.0'
This commit is contained in:
commit
c136534723
50 changed files with 1010 additions and 858 deletions
|
@ -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>
|
||||
|
|
10
.travis.yml
10
.travis.yml
|
@ -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
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube;
|
||||
|
||||
use Exception;
|
||||
use Jawira\CaseConverter\CaseConverterException;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Jawira\CaseConverter\Convert;
|
||||
|
||||
|
@ -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'];
|
||||
|
||||
|
@ -60,7 +61,7 @@ class Config
|
|||
/**
|
||||
* List of formats available in advanced conversion mode.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
public $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav'];
|
||||
|
||||
|
@ -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 = [];
|
||||
|
||||
|
@ -145,7 +139,8 @@ class Config
|
|||
/**
|
||||
* Config constructor.
|
||||
*
|
||||
* @param array $options Options
|
||||
* @param mixed[] $options Options
|
||||
* @throws CaseConverterException
|
||||
*/
|
||||
private function __construct(array $options = [])
|
||||
{
|
||||
|
@ -156,9 +151,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 +190,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()
|
||||
{
|
||||
|
@ -216,7 +211,7 @@ class Config
|
|||
/**
|
||||
* Apply the provided options.
|
||||
*
|
||||
* @param array $options Options
|
||||
* @param mixed[] $options Options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -235,6 +230,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,11 +261,13 @@ class Config
|
|||
* 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 {
|
||||
|
@ -280,8 +278,10 @@ 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 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)
|
||||
{
|
||||
|
|
|
@ -104,12 +104,14 @@ class Locale
|
|||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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'];
|
||||
|
||||
|
@ -112,6 +111,7 @@ class LocaleManager
|
|||
* Set the current locale.
|
||||
*
|
||||
* @param Locale $locale Locale
|
||||
* @return void
|
||||
*/
|
||||
public function setLocale(Locale $locale)
|
||||
{
|
||||
|
@ -122,6 +122,7 @@ class LocaleManager
|
|||
|
||||
/**
|
||||
* Unset the current locale.
|
||||
* @return void
|
||||
*/
|
||||
public function unsetLocale()
|
||||
{
|
||||
|
@ -133,8 +134,8 @@ class LocaleManager
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -152,6 +153,7 @@ class LocaleManager
|
|||
*
|
||||
* @param string $string String to translate
|
||||
*
|
||||
* @param mixed[] $params
|
||||
* @return string Translated string
|
||||
*/
|
||||
public function t($string, array $params = [])
|
||||
|
|
|
@ -36,9 +36,9 @@ class LocaleMiddleware
|
|||
/**
|
||||
* 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)
|
||||
{
|
||||
|
@ -52,14 +52,16 @@ class LocaleMiddleware
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -42,14 +42,14 @@ class UglyRouter extends Router
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws RuntimeException If named route does not exist
|
||||
* @throws InvalidArgumentException If required data not provided
|
||||
* @param string $name Route name
|
||||
* @param string[] $data Named argument replacement data
|
||||
* @param string[] $queryParams Optional query string parameters
|
||||
*
|
||||
* @return string
|
||||
* @throws InvalidArgumentException If required data not provided
|
||||
*
|
||||
* @throws RuntimeException If named route does not exist
|
||||
*/
|
||||
public function pathFor($name, array $data = [], array $queryParams = [])
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use Alltube\Exception\EmptyUrlException;
|
|||
use Alltube\Exception\PasswordException;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use stdClass;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
|
@ -19,16 +19,16 @@ use Symfony\Component\Process\Process;
|
|||
*
|
||||
* Due to the way youtube-dl behaves, this class can also contain information about a playlist.
|
||||
*
|
||||
* @property-read string $title Title
|
||||
* @property-read string $protocol Network protocol (HTTP, RTMP, etc.)
|
||||
* @property-read string $url File URL
|
||||
* @property-read string $ext File extension
|
||||
* @property-read string $extractor_key youtube-dl extractor class used
|
||||
* @property-read array $entries List of videos (if the object contains information about a playlist)
|
||||
* @property-read array $rtmp_conn
|
||||
* @property-read string $title Title
|
||||
* @property-read string $protocol Network protocol (HTTP, RTMP, etc.)
|
||||
* @property-read string $url File URL
|
||||
* @property-read string $ext File extension
|
||||
* @property-read string $extractor_key youtube-dl extractor class used
|
||||
* @property-read array $entries List of videos (if the object contains information about a playlist)
|
||||
* @property-read array $rtmp_conn
|
||||
* @property-read string|null $_type Object type (usually "playlist" or null)
|
||||
* @property-read stdClass $downloader_options
|
||||
* @property-read stdClass $http_headers
|
||||
* @property-read stdClass $downloader_options
|
||||
* @property-read stdClass $http_headers
|
||||
*/
|
||||
class Video
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ class Video
|
|||
/**
|
||||
* URLs of the video files.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
private $urls;
|
||||
|
||||
|
@ -84,11 +84,11 @@ class Video
|
|||
/**
|
||||
* VideoDownload constructor.
|
||||
*
|
||||
* @param string $webpageUrl URL of the page containing the video
|
||||
* @param string $webpageUrl URL of the page containing the video
|
||||
* @param string $requestedFormat Requested video format
|
||||
* (can be any format string accepted by youtube-dl,
|
||||
* including selectors like "[height<=720]")
|
||||
* @param string $password Password
|
||||
* @param string $password Password
|
||||
*/
|
||||
public function __construct($webpageUrl, $requestedFormat = 'best', $password = null)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ class Video
|
|||
*
|
||||
* @param string[] $arguments Arguments
|
||||
*
|
||||
* @return Process
|
||||
* @return Process<string>
|
||||
*/
|
||||
private static function getProcess(array $arguments)
|
||||
{
|
||||
|
@ -124,7 +124,9 @@ class Video
|
|||
* List all extractors.
|
||||
*
|
||||
* @return string[] Extractors
|
||||
* */
|
||||
*
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public static function getExtractors()
|
||||
{
|
||||
$video = new self('');
|
||||
|
@ -135,13 +137,13 @@ class Video
|
|||
/**
|
||||
* Call youtube-dl.
|
||||
*
|
||||
* @param array $arguments Arguments
|
||||
* @param string[] $arguments Arguments
|
||||
*
|
||||
* @throws PasswordException If the video is protected by a password and no password was specified
|
||||
* @return string Result
|
||||
* @throws Exception If the password is wrong
|
||||
* @throws Exception If youtube-dl returns an error
|
||||
*
|
||||
* @return string Result
|
||||
* @throws PasswordException If the video is protected by a password and no password was specified
|
||||
*/
|
||||
private function callYoutubedl(array $arguments)
|
||||
{
|
||||
|
@ -153,7 +155,7 @@ class Video
|
|||
$process->run();
|
||||
if (!$process->isSuccessful()) {
|
||||
$errorOutput = trim($process->getErrorOutput());
|
||||
$exitCode = $process->getExitCode();
|
||||
$exitCode = intval($process->getExitCode());
|
||||
if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') {
|
||||
throw new PasswordException($errorOutput, $exitCode);
|
||||
} elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') {
|
||||
|
@ -172,6 +174,7 @@ class Video
|
|||
* @param string $prop Property
|
||||
*
|
||||
* @return string
|
||||
* @throws PasswordException
|
||||
*/
|
||||
private function getProp($prop = 'dump-json')
|
||||
{
|
||||
|
@ -196,7 +199,9 @@ class Video
|
|||
* Get all information about a video.
|
||||
*
|
||||
* @return stdClass Decoded JSON
|
||||
* */
|
||||
*
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getJson()
|
||||
{
|
||||
if (!isset($this->json)) {
|
||||
|
@ -212,12 +217,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 +234,7 @@ class Video
|
|||
* @param string $name Property
|
||||
*
|
||||
* @return bool
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
|
@ -240,7 +249,9 @@ class Video
|
|||
* (eg. bestvideo+bestaudio).
|
||||
*
|
||||
* @return string[] URLs of video
|
||||
* */
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
// Cache the URLs.
|
||||
|
@ -259,7 +270,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,23 +284,17 @@ class Video
|
|||
* @param string $extension New file extension
|
||||
*
|
||||
* @return string Filename of extracted video with specified extension
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function getFileNameWithExtension($extension)
|
||||
{
|
||||
return html_entity_decode(
|
||||
pathinfo(
|
||||
$this->getFilename(),
|
||||
PATHINFO_FILENAME
|
||||
) . '.' . $extension,
|
||||
ENT_COMPAT,
|
||||
'ISO-8859-1'
|
||||
);
|
||||
return str_replace('.' . $this->ext, '.' . $extension, $this->getFilename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return arguments used to run rtmp for a specific video.
|
||||
*
|
||||
* @return array Arguments
|
||||
* @return string[] Arguments
|
||||
*/
|
||||
private function getRtmpArguments()
|
||||
{
|
||||
|
@ -296,12 +303,12 @@ class Video
|
|||
if ($this->protocol == 'rtmp') {
|
||||
foreach (
|
||||
[
|
||||
'url' => '-rtmp_tcurl',
|
||||
'webpage_url' => '-rtmp_pageurl',
|
||||
'player_url' => '-rtmp_swfverify',
|
||||
'flash_version' => '-rtmp_flashver',
|
||||
'play_path' => '-rtmp_playpath',
|
||||
'app' => '-rtmp_app',
|
||||
'url' => '-rtmp_tcurl',
|
||||
'webpage_url' => '-rtmp_pageurl',
|
||||
'player_url' => '-rtmp_swfverify',
|
||||
'flash_version' => '-rtmp_flashver',
|
||||
'play_path' => '-rtmp_playpath',
|
||||
'app' => '-rtmp_app',
|
||||
] as $property => $option
|
||||
) {
|
||||
if (isset($this->{$property})) {
|
||||
|
@ -324,7 +331,7 @@ class Video
|
|||
/**
|
||||
* Check if a command runs successfully.
|
||||
*
|
||||
* @param array $command Command and arguments
|
||||
* @param string[] $command Command and arguments
|
||||
*
|
||||
* @return bool False if the command returns an error, true otherwise
|
||||
*/
|
||||
|
@ -339,15 +346,15 @@ class Video
|
|||
/**
|
||||
* Get a process that runs avconv in order to convert a video.
|
||||
*
|
||||
* @param int $audioBitrate Audio bitrate of the converted file
|
||||
* @param string $filetype Filetype of the converted file
|
||||
* @param bool $audioOnly True to return an audio-only file
|
||||
* @param string $from Start the conversion at this time
|
||||
* @param string $to End the conversion at this time
|
||||
* @param int $audioBitrate Audio bitrate of the converted file
|
||||
* @param string $filetype Filetype of the converted file
|
||||
* @param bool $audioOnly True to return an audio-only file
|
||||
* @param string $from Start the conversion at this time
|
||||
* @param string $to End the conversion at this time
|
||||
*
|
||||
* @return Process<string> Process
|
||||
* @throws Exception If avconv/ffmpeg is missing
|
||||
*
|
||||
* @return Process Process
|
||||
*/
|
||||
private function getAvconvProcess(
|
||||
$audioBitrate,
|
||||
|
@ -418,12 +425,12 @@ class Video
|
|||
* Get audio stream of converted video.
|
||||
*
|
||||
* @param string $from Start the conversion at this time
|
||||
* @param string $to End the conversion at this time
|
||||
*
|
||||
* @throws Exception If your try to convert an M3U8 video
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
* @param string $to End the conversion at this time
|
||||
*
|
||||
* @return resource popen stream
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
*
|
||||
* @throws Exception If your try to convert an M3U8 video
|
||||
*/
|
||||
public function getAudioStream($from = null, $to = null)
|
||||
{
|
||||
|
@ -453,10 +460,10 @@ class Video
|
|||
/**
|
||||
* Get video stream from an M3U playlist.
|
||||
*
|
||||
* @throws Exception If avconv/ffmpeg is missing
|
||||
* @return resource popen stream
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
*
|
||||
* @return resource popen stream
|
||||
* @throws Exception If avconv/ffmpeg is missing
|
||||
*/
|
||||
public function getM3uStream()
|
||||
{
|
||||
|
@ -495,9 +502,9 @@ class Video
|
|||
/**
|
||||
* Get an avconv stream to remux audio and video.
|
||||
*
|
||||
* @return resource popen stream
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
*
|
||||
* @return resource popen stream
|
||||
*/
|
||||
public function getRemuxStream()
|
||||
{
|
||||
|
@ -532,9 +539,9 @@ class Video
|
|||
/**
|
||||
* Get video stream from an RTMP video.
|
||||
*
|
||||
* @return resource popen stream
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
*
|
||||
* @return resource popen stream
|
||||
*/
|
||||
public function getRtmpStream()
|
||||
{
|
||||
|
@ -565,13 +572,13 @@ class Video
|
|||
/**
|
||||
* Get the stream of a converted video.
|
||||
*
|
||||
* @param int $audioBitrate Audio bitrate of the converted file
|
||||
* @param string $filetype Filetype of the converted file
|
||||
*
|
||||
* @throws Exception If your try to convert and M3U8 video
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
* @param int $audioBitrate Audio bitrate of the converted file
|
||||
* @param string $filetype Filetype of the converted file
|
||||
*
|
||||
* @return resource popen stream
|
||||
* @throws Exception If the popen stream was not created correctly
|
||||
*
|
||||
* @throws Exception If your try to convert and M3U8 video
|
||||
*/
|
||||
public function getConvertedStream($audioBitrate, $filetype)
|
||||
{
|
||||
|
@ -605,21 +612,35 @@ class Video
|
|||
/**
|
||||
* Get a HTTP response containing the video.
|
||||
*
|
||||
* @param array $headers HTTP headers of the request
|
||||
* @param mixed[] $headers HTTP headers of the request
|
||||
*
|
||||
* @return Response
|
||||
* @return ResponseInterface
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
* @link https://github.com/guzzle/guzzle/issues/2640
|
||||
*/
|
||||
public function getHttpResponse(array $headers = [])
|
||||
{
|
||||
$client = new Client();
|
||||
// IDN conversion breaks with Google hosts like https://r3---sn-25glene6.googlevideo.com/.
|
||||
$client = new Client(['idn_conversion' => false]);
|
||||
$urls = $this->getUrl();
|
||||
$stream_context_options = [];
|
||||
|
||||
if (array_key_exists('Referer', (array)$this->http_headers)) {
|
||||
$stream_context_options = [
|
||||
'http' => [
|
||||
'header' => 'Referer: ' . $this->http_headers->Referer
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $client->request(
|
||||
'GET',
|
||||
$urls[0],
|
||||
[
|
||||
'stream' => true,
|
||||
'headers' => array_merge((array) $this->http_headers, $headers)
|
||||
'stream_context' => $stream_context_options,
|
||||
'headers' => array_merge((array)$this->http_headers, $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,14 +21,15 @@ 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)
|
||||
{
|
||||
if (!isset($request)) {
|
||||
$request = $container['request'];
|
||||
$request = $container->get('request');
|
||||
}
|
||||
|
||||
$view = new Smarty(__DIR__ . '/../templates/');
|
||||
|
@ -35,9 +37,10 @@ class ViewFactory
|
|||
$request = $request->withUri($request->getUri()->withScheme('https')->withPort(443));
|
||||
}
|
||||
|
||||
$localeManager = $container['locale'];
|
||||
/** @var LocaleManager $localeManager */
|
||||
$localeManager = $container->get('locale');
|
||||
|
||||
$smartyPlugins = new SmartyPlugins($container['router'], $request->getUri()->withUserInfo(null));
|
||||
$smartyPlugins = new SmartyPlugins($container->get('router'), $request->getUri()->withUserInfo(null));
|
||||
$view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
|
||||
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
|
||||
$view->registerPlugin('block', 't', [$localeManager, 'smartyTranslate']);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
namespace Alltube\Stream;
|
||||
|
||||
use Alltube\Exception\EmptyUrlException;
|
||||
use Alltube\Exception\PasswordException;
|
||||
use Alltube\Video;
|
||||
use Barracuda\ArchiveStream\ZipArchive;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
@ -48,7 +50,10 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
/**
|
||||
* PlaylistArchiveStream constructor.
|
||||
*
|
||||
* We don't call the parent constructor because it messes up the output buffering.
|
||||
*
|
||||
* @param Video $video Video/playlist to download
|
||||
* @noinspection PhpMissingParentConstructorInspection
|
||||
*/
|
||||
public function __construct(Video $video)
|
||||
{
|
||||
|
@ -86,20 +91,21 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
*
|
||||
* @param string $string The string that is to be written
|
||||
*
|
||||
* @return int
|
||||
* @return int|false
|
||||
*/
|
||||
public function write($string)
|
||||
{
|
||||
fwrite($this->buffer, $string);
|
||||
return fwrite($this->buffer, $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the stream if known.
|
||||
*
|
||||
* @return null
|
||||
* @return int|null
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,7 +151,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
/**
|
||||
* Returns the remaining contents in a string.
|
||||
*
|
||||
* @return string
|
||||
* @return string|false
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
|
@ -170,6 +176,8 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
if (isset($meta[$key])) {
|
||||
return $meta[$key];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,7 +202,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
{
|
||||
$this->rewind();
|
||||
|
||||
return $this->getContents();
|
||||
return strval($this->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,6 +244,8 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
* @param Video $video Video to stream
|
||||
*
|
||||
* @return void
|
||||
* @throws PasswordException
|
||||
* @throws EmptyUrlException
|
||||
*/
|
||||
protected function startVideoStream(Video $video)
|
||||
{
|
||||
|
@ -246,7 +256,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
|
||||
$this->init_file_stream_transfer(
|
||||
$video->getFilename(),
|
||||
$contentLengthHeaders[0]
|
||||
intval($contentLengthHeaders[0])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -256,6 +266,8 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
|||
* @param int $count Number of bytes to read
|
||||
*
|
||||
* @return string|false
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function read($count)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace Alltube\Stream;
|
||||
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
|
@ -18,16 +18,16 @@ class YoutubeChunkStream implements StreamInterface
|
|||
/**
|
||||
* HTTP response containing the video chunk.
|
||||
*
|
||||
* @var Response
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* YoutubeChunkStream constructor.
|
||||
*
|
||||
* @param Response $response HTTP response containing the video chunk
|
||||
* @param ResponseInterface $response HTTP response containing the video chunk
|
||||
*/
|
||||
public function __construct(Response $response)
|
||||
public function __construct(ResponseInterface $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class YoutubeChunkStream implements StreamInterface
|
|||
*/
|
||||
public function read($length)
|
||||
{
|
||||
$size = $this->response->getHeader('Content-Length')[0];
|
||||
$size = intval($this->response->getHeader('Content-Length')[0]);
|
||||
if ($size - $this->tell() < $length) {
|
||||
// Don't try to read further than the end of the stream.
|
||||
$length = $size - $this->tell();
|
||||
|
@ -55,7 +55,7 @@ class YoutubeChunkStream implements StreamInterface
|
|||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->response->getBody();
|
||||
return (string)$this->response->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
namespace Alltube\Stream;
|
||||
|
||||
use Alltube\Exception\EmptyUrlException;
|
||||
use Alltube\Exception\PasswordException;
|
||||
use Alltube\Video;
|
||||
use GuzzleHttp\Psr7\AppendStream;
|
||||
|
||||
|
@ -19,6 +21,8 @@ class YoutubeStream extends AppendStream
|
|||
* YoutubeStream constructor.
|
||||
*
|
||||
* @param Video $video Video to stream
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function __construct(Video $video)
|
||||
{
|
||||
|
@ -31,7 +35,7 @@ class YoutubeStream extends AppendStream
|
|||
while ($rangeStart < $contentLenghtHeader[0]) {
|
||||
$rangeEnd = $rangeStart + $video->downloader_options->http_chunk_size;
|
||||
if ($rangeEnd >= $contentLenghtHeader[0]) {
|
||||
$rangeEnd = $contentLenghtHeader[0] - 1;
|
||||
$rangeEnd = intval($contentLenghtHeader[0]) - 1;
|
||||
}
|
||||
$response = $video->getHttpResponse(['Range' => 'bytes=' . $rangeStart . '-' . $rangeEnd]);
|
||||
$this->addStream(new YoutubeChunkStream($response));
|
||||
|
|
|
@ -5,34 +5,35 @@
|
|||
"homepage": "http://alltubedownload.net/",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"aura/session": "~2.1.0",
|
||||
"barracudanetworks/archivestream-php": "~1.0.5",
|
||||
"guzzlehttp/guzzle": "~6.3.0",
|
||||
"ext-intl": "*",
|
||||
"ext-json": "*",
|
||||
"aura/session": "^2.1",
|
||||
"barracudanetworks/archivestream-php": "^1.0",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"jawira/case-converter": "^3.4",
|
||||
"mathmarques/smarty-view": "~1.1.0",
|
||||
"mathmarques/smarty-view": "^1.1",
|
||||
"npm-asset/open-sans-fontface": "^1.4",
|
||||
"rinvex/countries": "~3.1.0",
|
||||
"slim/slim": "~3.12.1",
|
||||
"rinvex/countries": "^6.1",
|
||||
"symfony/process": "^4.0",
|
||||
"symfony/translation": "^4.0",
|
||||
"symfony/yaml": "^4.0",
|
||||
"zonuexe/http-accept-language": "~0.4.1"
|
||||
"zonuexe/http-accept-language": "^0.4.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"anam/phantomjs-linux-x86-binary": "~2.1.1",
|
||||
"anam/phantomjs-linux-x86-binary": "^2.1",
|
||||
"consolidation/robo": "^2.0",
|
||||
"ffmpeg/ffmpeg": "^4.1",
|
||||
"heroku/heroku-buildpack-php": "^162.0",
|
||||
"php-mock/php-mock-mockery": "^1.3",
|
||||
"phpro/grumphp": "^0.17.0",
|
||||
"phpstan/phpstan": "~0.9.2",
|
||||
"phpro/grumphp": "^0.18.0",
|
||||
"phpstan/phpstan": "^0.12.25",
|
||||
"phpunit/phpunit": "^8.4",
|
||||
"roave/security-advisories": "dev-master",
|
||||
"smarty-gettext/smarty-gettext": "^1.6",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"symfony/debug": "^4.0",
|
||||
"symfony/var-dumper": "^4.0",
|
||||
"ytdl-org/youtube-dl": "^2020.02"
|
||||
"symfony/error-handler": "^5.0",
|
||||
"symfony/var-dumper": "^5.0",
|
||||
"ytdl-org/youtube-dl": "^2020.05"
|
||||
},
|
||||
"extra": {
|
||||
"paas": {
|
||||
|
@ -50,10 +51,10 @@
|
|||
"type": "package",
|
||||
"package": {
|
||||
"name": "ytdl-org/youtube-dl",
|
||||
"version": "2020.02.16",
|
||||
"version": "2020.05.08",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/ytdl-org/youtube-dl/archive/2020.02.16.zip"
|
||||
"url": "https://github.com/ytdl-org/youtube-dl/archive/2020.05.08.zip"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
778
composer.lock
generated
778
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -66,10 +66,12 @@ class DownloadController extends BaseController
|
|||
/**
|
||||
* Return a converted MP3 file.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
* @throws PasswordException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getConvertedAudioResponse(Request $request, Response $response)
|
||||
{
|
||||
|
@ -100,10 +102,11 @@ class DownloadController extends BaseController
|
|||
/**
|
||||
* Return the MP3 file.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
* @throws PasswordException
|
||||
*/
|
||||
private function getAudioResponse(Request $request, Response $response)
|
||||
{
|
||||
|
@ -130,7 +133,7 @@ class DownloadController extends BaseController
|
|||
return $frontController->password($request, $response);
|
||||
} catch (Exception $e) {
|
||||
// If MP3 is not available, we convert it.
|
||||
$this->video = $this->video->withFormat('bestaudio');
|
||||
$this->video = $this->video->withFormat('bestaudio/best');
|
||||
|
||||
return $this->getConvertedAudioResponse($request, $response);
|
||||
}
|
||||
|
@ -139,10 +142,13 @@ class DownloadController extends BaseController
|
|||
/**
|
||||
* Get a video/audio stream piped through the server.
|
||||
*
|
||||
* @param Response $response PSR-7 response
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
*
|
||||
* @param Response $response PSR-7 response
|
||||
* @return Response HTTP response
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getStream(Request $request, Response $response)
|
||||
{
|
||||
|
@ -205,9 +211,11 @@ class DownloadController extends BaseController
|
|||
* Get a remuxed stream piped through the server.
|
||||
*
|
||||
* @param Response $response PSR-7 response
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
*
|
||||
* @return Response HTTP response
|
||||
* @throws PasswordException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getRemuxStream(Request $request, Response $response)
|
||||
{
|
||||
|
@ -230,10 +238,13 @@ class DownloadController extends BaseController
|
|||
* Get approriate HTTP response to download query.
|
||||
* Depends on whether we want to stream, remux or simply redirect.
|
||||
*
|
||||
* @param Response $response PSR-7 response
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
*
|
||||
* @param Response $response PSR-7 response
|
||||
* @return Response HTTP response
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getDownloadResponse(Request $request, Response $response)
|
||||
{
|
||||
|
@ -262,10 +273,12 @@ class DownloadController extends BaseController
|
|||
/**
|
||||
* Return a converted video file.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
* @throws PasswordException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getConvertedResponse(Request $request, Response $response)
|
||||
{
|
||||
|
|
|
@ -9,15 +9,15 @@ namespace Alltube\Controller;
|
|||
use Alltube\Exception\PasswordException;
|
||||
use Alltube\Locale;
|
||||
use Alltube\Video;
|
||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Throwable;
|
||||
use Exception;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Slim\Container;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
use Slim\Views\Smarty;
|
||||
use Symfony\Component\Debug\ExceptionHandler;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
|
||||
/**
|
||||
* Main controller.
|
||||
|
@ -46,7 +46,7 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Display index page.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
|
@ -58,15 +58,15 @@ class FrontController extends BaseController
|
|||
$response,
|
||||
'index.tpl',
|
||||
[
|
||||
'config' => $this->config,
|
||||
'class' => 'index',
|
||||
'description' => $this->localeManager->t(
|
||||
'config' => $this->config,
|
||||
'class' => 'index',
|
||||
'description' => $this->localeManager->t(
|
||||
'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.'
|
||||
),
|
||||
'domain' => $uri->getScheme() . '://' . $uri->getAuthority(),
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'domain' => $uri->getScheme() . '://' . $uri->getAuthority(),
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'supportedLocales' => $this->localeManager->getSupportedLocales(),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -76,9 +76,9 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Switch locale.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
* @param array $data Query parameters
|
||||
* @param string[] $data Query parameters
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
@ -92,10 +92,11 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Display a list of extractors.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function extractors(Request $request, Response $response)
|
||||
{
|
||||
|
@ -103,14 +104,14 @@ class FrontController extends BaseController
|
|||
$response,
|
||||
'extractors.tpl',
|
||||
[
|
||||
'config' => $this->config,
|
||||
'extractors' => Video::getExtractors(),
|
||||
'class' => 'extractors',
|
||||
'title' => $this->localeManager->t('Supported websites'),
|
||||
'config' => $this->config,
|
||||
'extractors' => Video::getExtractors(),
|
||||
'class' => 'extractors',
|
||||
'title' => $this->localeManager->t('Supported websites'),
|
||||
'description' => $this->localeManager->t('List of all supported websites from which Alltube Download ' .
|
||||
'can extract video or audio files'),
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -120,7 +121,7 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Display a password prompt.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
|
@ -131,14 +132,14 @@ class FrontController extends BaseController
|
|||
$response,
|
||||
'password.tpl',
|
||||
[
|
||||
'config' => $this->config,
|
||||
'class' => 'password',
|
||||
'title' => $this->localeManager->t('Password prompt'),
|
||||
'config' => $this->config,
|
||||
'class' => 'password',
|
||||
'title' => $this->localeManager->t('Password prompt'),
|
||||
'description' => $this->localeManager->t(
|
||||
'You need a password in order to download this video with Alltube Download'
|
||||
),
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -148,7 +149,7 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Return the video description page.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
|
@ -185,13 +186,13 @@ class FrontController extends BaseController
|
|||
$response,
|
||||
$template,
|
||||
[
|
||||
'video' => $this->video,
|
||||
'class' => 'info',
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'config' => $this->config,
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
'video' => $this->video,
|
||||
'class' => 'info',
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'config' => $this->config,
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
'defaultFormat' => $this->defaultFormat,
|
||||
]
|
||||
);
|
||||
|
@ -202,7 +203,7 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Dislay information about the video.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
*
|
||||
* @return Response HTTP response
|
||||
|
@ -231,18 +232,18 @@ class FrontController extends BaseController
|
|||
/**
|
||||
* Display an error page.
|
||||
*
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
* @param Throwable $error Error to display
|
||||
* @param Request $request PSR-7 request
|
||||
* @param Response $response PSR-7 response
|
||||
* @param Throwable $error Error to display
|
||||
*
|
||||
* @return Response HTTP response
|
||||
*/
|
||||
public function error(Request $request, Response $response, Throwable $error)
|
||||
{
|
||||
if ($this->config->debug) {
|
||||
$exception = FlattenException::createFromThrowable($error);
|
||||
$handler = new ExceptionHandler();
|
||||
$response->getBody()->write($handler->getHtml($exception));
|
||||
$renderer = new HtmlErrorRenderer(true);
|
||||
$exception = $renderer->render($error);
|
||||
$response->getBody()->write($exception->getAsString());
|
||||
|
||||
return $response->withStatus($exception->getStatusCode());
|
||||
} else {
|
||||
|
@ -256,12 +257,12 @@ class FrontController extends BaseController
|
|||
$response,
|
||||
'error.tpl',
|
||||
[
|
||||
'config' => $this->config,
|
||||
'error' => $message,
|
||||
'class' => 'video',
|
||||
'title' => $this->localeManager->t('Error'),
|
||||
'config' => $this->config,
|
||||
'error' => $message,
|
||||
'class' => 'video',
|
||||
'title' => $this->localeManager->t('Error'),
|
||||
'canonical' => $this->getCanonicalUrl($request),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
'locale' => $this->localeManager->getLocale(),
|
||||
]
|
||||
);
|
||||
|
||||
|
|
29
grumphp.yml
29
grumphp.yml
|
@ -1,17 +1,16 @@
|
|||
---
|
||||
parameters:
|
||||
ascii: ~
|
||||
tasks:
|
||||
jsonlint: ~
|
||||
xmllint: ~
|
||||
yamllint: ~
|
||||
composer: ~
|
||||
phpcs:
|
||||
standard: PSR12
|
||||
ignore_patterns:
|
||||
- RoboFile.php
|
||||
phpstan:
|
||||
level: max
|
||||
configuration: phpstan.neon
|
||||
ignore_patterns:
|
||||
- RoboFile.php
|
||||
ascii: ~
|
||||
tasks:
|
||||
jsonlint: ~
|
||||
xmllint: ~
|
||||
yamllint: ~
|
||||
composer: ~
|
||||
phpcs:
|
||||
standard: PSR12
|
||||
ignore_patterns:
|
||||
- RoboFile.php
|
||||
phpstan:
|
||||
level: max
|
||||
ignore_patterns:
|
||||
- RoboFile.php
|
||||
|
|
21
index.php
21
index.php
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Alltube\Config;
|
||||
use Alltube\Controller\DownloadController;
|
||||
use Alltube\Controller\FrontController;
|
||||
|
@ -10,7 +11,8 @@ use Alltube\LocaleMiddleware;
|
|||
use Alltube\UglyRouter;
|
||||
use Alltube\ViewFactory;
|
||||
use Slim\App;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Slim\Container;
|
||||
use Symfony\Component\ErrorHandler\Debug;
|
||||
|
||||
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
|
||||
header('Location: ' . str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
|
||||
|
@ -18,11 +20,17 @@ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.ph
|
|||
}
|
||||
|
||||
if (is_file(__DIR__ . '/config/config.yml')) {
|
||||
Config::setFile(__DIR__ . '/config/config.yml');
|
||||
try {
|
||||
Config::setFile(__DIR__ . '/config/config.yml');
|
||||
} catch (Exception $e) {
|
||||
die('Could not load config file: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Create app.
|
||||
$app = new App();
|
||||
|
||||
/** @var Container $container */
|
||||
$container = $app->getContainer();
|
||||
|
||||
// Load config.
|
||||
|
@ -47,7 +55,11 @@ $container['locale'] = LocaleManager::getInstance();
|
|||
$app->add(new LocaleMiddleware($container));
|
||||
|
||||
// Smarty.
|
||||
$container['view'] = ViewFactory::create($container);
|
||||
try {
|
||||
$container['view'] = ViewFactory::create($container);
|
||||
} catch (SmartyException $e) {
|
||||
die('Could not load Smarty: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// Controllers.
|
||||
$frontController = new FrontController($container);
|
||||
|
@ -102,4 +114,7 @@ try {
|
|||
$app->run();
|
||||
} catch (SmartyException $e) {
|
||||
die('Smarty could not compile the template file: ' . $e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
// Last resort if the error has not been caught by the error handler for some reason.
|
||||
die('Error when starting the app: ' . $e->getMessage());
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
parameters:
|
||||
ignoreErrors:
|
||||
# The Archive constructor messes up the output buffering.
|
||||
- '#Alltube\\Stream\\PlaylistArchiveStream::__construct\(\) does not call parent constructor from Barracuda\\ArchiveStream\\ZipArchive\.#'
|
30
phpunit.xml
30
phpunit.xml
|
@ -1,18 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit bootstrap="tests/bootstrap.php">
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>classes/</directory>
|
||||
<directory>controllers/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<testsuites>
|
||||
<testsuite name="Tests">
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-html" target="coverage/"/>
|
||||
<log type="coverage-clover" target="clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>classes/</directory>
|
||||
<directory>controllers/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<testsuites>
|
||||
<testsuite name="Tests">
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-html" target="coverage/"/>
|
||||
<log type="coverage-clover" target="clover.xml"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>AllTube Download - Maintenance</title>
|
||||
<link rel="stylesheet" href="../dist/main.css"/>
|
||||
<link rel="icon" href="../img/favicon.png"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="main">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="main">
|
||||
<h1>
|
||||
<img class="logo" src="../img/logo.png" alt="AllTube Download" width="328" height="284"/>
|
||||
<img class="logo" src="../img/logo.png" alt="AllTube Download" width="328" height="284"/>
|
||||
</h1>
|
||||
<div>An error occurred in the application and your page could not be served. Please try again in a few moments.</div>
|
||||
</div>
|
||||
<div>An error occurred in the application and your page could not be served. Please try again in a few
|
||||
moments.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>AllTube Download - Maintenance</title>
|
||||
<link rel="stylesheet" href="../dist/main.css"/>
|
||||
<link rel="icon" href="../img/favicon.png"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="main">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="main">
|
||||
<h1>
|
||||
<img class="logo" src="../img/logo.png" alt="AllTube Download" width="328" height="284"/>
|
||||
<img class="logo" src="../img/logo.png" alt="AllTube Download" width="328" height="284"/>
|
||||
</h1>
|
||||
<div>This application is undergoing maintenance right now. Please check back later.</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://alltubedownload.net/</loc>
|
||||
<changefreq>yearly</changefreq>
|
||||
<priority>1</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://alltubedownload.net/extractors</loc>
|
||||
<changefreq>weekly</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://alltubedownload.net/</loc>
|
||||
<changefreq>yearly</changefreq>
|
||||
<priority>1</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://alltubedownload.net/extractors</loc>
|
||||
<changefreq>weekly</changefreq>
|
||||
</url>
|
||||
</urlset>
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
{t}Please check the URL of your video.{/t}
|
||||
<p><i>{$error|escape}</i></p>
|
||||
</main>
|
||||
{include file='inc/footer.tpl'}
|
||||
{include file='inc/footer.tpl'}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
{include file='inc/logo.tpl'}
|
||||
<h2 class="titre">{t}Supported websites{/t}</h2>
|
||||
<div class="tripleliste">
|
||||
<ul>
|
||||
{foreach $extractors as $extractor}
|
||||
<li>{$extractor}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
<ul>
|
||||
{foreach $extractors as $extractor}
|
||||
<li>{$extractor}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
{include file='inc/footer.tpl'}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
·
|
||||
|
||||
<a rel="noopener" target="_blank" title="{t}Donate using Liberapay{/t}"
|
||||
href="https://liberapay.com/Rudloff/donate">
|
||||
href="https://liberapay.com/Rudloff/donate">
|
||||
{t}Donate{/t}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
<!doctype html>
|
||||
<html {if isset($locale)}lang="{$locale->getBcp47()}"{/if}>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name=viewport content="width=device-width, initial-scale=1">
|
||||
{if isset($description)}
|
||||
<meta name="description" content="{$description|escape}" />
|
||||
<meta name="twitter:description" content="{$description|escape}" />
|
||||
<meta property="og:description" content="{$description|escape}" />
|
||||
<meta name="description" content="{$description|escape}"/>
|
||||
<meta name="twitter:description" content="{$description|escape}"/>
|
||||
<meta property="og:description" content="{$description|escape}"/>
|
||||
{/if}
|
||||
<link rel="stylesheet" href="{base_url}/css/fonts.css" />
|
||||
<link rel="stylesheet" href="{base_url}/css/style.css" />
|
||||
<link rel="stylesheet" href="{base_url}/css/fonts.css"/>
|
||||
<link rel="stylesheet" href="{base_url}/css/style.css"/>
|
||||
<title>{$config->appName}{if isset($title)} - {$title|escape}{/if}</title>
|
||||
<link rel="canonical" href="{$canonical}" />
|
||||
<link rel="icon" href="{base_url}/img/favicon.png" />
|
||||
<meta property="og:title" content="{$config->appName}{if isset($title)} - {$title|escape}{/if}" />
|
||||
<meta property="og:image" content="{base_url}/img/logo.png" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:title" content="{$config->appName}{if isset($title)} - {$title|escape}{/if}" />
|
||||
<meta name="twitter:image" content="{base_url}/img/logo.png" />
|
||||
<meta name="twitter:creator" content="@Tael67" />
|
||||
<link rel="canonical" href="{$canonical}"/>
|
||||
<link rel="icon" href="{base_url}/img/favicon.png"/>
|
||||
<meta property="og:title" content="{$config->appName}{if isset($title)} - {$title|escape}{/if}"/>
|
||||
<meta property="og:image" content="{base_url}/img/logo.png"/>
|
||||
<meta name="twitter:card" content="summary"/>
|
||||
<meta name="twitter:title" content="{$config->appName}{if isset($title)} - {$title|escape}{/if}"/>
|
||||
<meta name="twitter:image" content="{base_url}/img/logo.png"/>
|
||||
<meta name="twitter:creator" content="@Tael67"/>
|
||||
<meta name="theme-color" content="#4F4F4F">
|
||||
<link rel="manifest" href="{base_url}/resources/manifest.json" />
|
||||
<link rel="manifest" href="{base_url}/resources/manifest.json"/>
|
||||
</head>
|
||||
<body class="{$class}">
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
{if $supportedLocale != $locale}
|
||||
<li>
|
||||
<a hreflang="{$supportedLocale->getBcp47()}"
|
||||
lang="{$supportedLocale->getBcp47()}"
|
||||
href="{path_for name='locale' data=['locale'=>$supportedLocale->getIso15897()]}">
|
||||
lang="{$supportedLocale->getBcp47()}"
|
||||
href="{path_for name='locale' data=['locale'=>$supportedLocale->getIso15897()]}">
|
||||
{if $supportedLocale->getCountry()}
|
||||
{$supportedLocale->getCountry()->getEmoji()}
|
||||
{/if}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<h1 class="logobis">
|
||||
<a class="logocompatible" href="{base_url}">
|
||||
<span class="logocompatiblemask"><img src="{base_url}/img/logocompatiblemask.png" width="447" height="107" alt="{$config->appName}" /></span>
|
||||
</a></h1>
|
||||
<a class="logocompatible" href="{base_url}">
|
||||
<span class="logocompatiblemask"><img src="{base_url}/img/logocompatiblemask.png" width="447" height="107"
|
||||
alt="{$config->appName}"/></span>
|
||||
</a></h1>
|
||||
|
|
|
@ -2,41 +2,45 @@
|
|||
{include file='inc/header.tpl'}
|
||||
<main class="main">
|
||||
<div><img class="logo" src="{base_url}/img/logo.png"
|
||||
alt="{$config->appName}" width="328" height="284"></div>
|
||||
alt="{$config->appName}" width="328" height="284"></div>
|
||||
<form action="{path_for name="info"}">
|
||||
<label class="labelurl" for="url">
|
||||
{t}Copy here the URL of your video (Youtube, Dailymotion, etc.){/t}
|
||||
</label>
|
||||
<div class="champs">
|
||||
<label class="labelurl" for="url">
|
||||
{t}Copy here the URL of your video (Youtube, Dailymotion, etc.){/t}
|
||||
</label>
|
||||
<div class="champs">
|
||||
<span class="URLinput_wrapper">
|
||||
<!-- We used to have an autofocus attribute on this field but it triggerd a very specific CSS bug: https://github.com/Rudloff/alltube/issues/117 -->
|
||||
<input class="URLinput large-font" type="url" name="url" id="url"
|
||||
required placeholder="http://example.com/video" />
|
||||
required placeholder="http://example.com/video"/>
|
||||
</span>
|
||||
{if $config->uglyUrls}
|
||||
<input type="hidden" name="page" value="info" />
|
||||
{/if}
|
||||
<input class="downloadBtn large-font" type="submit" value="{t}Download{/t}" /><br/>
|
||||
{if $config->convert}
|
||||
<div class="mp3 small-font">
|
||||
<div class="mp3-inner">
|
||||
<input type="checkbox" id="audio" class="audio" name="audio">
|
||||
<label for="audio"><span class="ui"></span>
|
||||
{t}Audio only (MP3){/t}
|
||||
</label>
|
||||
<div class="seekOptions">
|
||||
<label for="from">{t}From{/t}</label> <input type="text" pattern="(\d+:)?(\d+:)?\d+(\.\d+)?" placeholder="HH:MM:SS" value="" name="from" id="from" />
|
||||
<label for="to">{t}to{/t}</label> <input type="text" pattern="(\d+:)?(\d+:)?\d+(\.\d+)?" placeholder="HH:MM:SS" value="" name="to" id="to" />
|
||||
{if $config->uglyUrls}
|
||||
<input type="hidden" name="page" value="info"/>
|
||||
{/if}
|
||||
<input class="downloadBtn large-font" type="submit" value="{t}Download{/t}"/><br/>
|
||||
{if $config->convert}
|
||||
<div class="mp3 small-font">
|
||||
<div class="mp3-inner">
|
||||
<input type="checkbox" id="audio" class="audio" name="audio">
|
||||
<label for="audio"><span class="ui"></span>
|
||||
{t}Audio only (MP3){/t}
|
||||
</label>
|
||||
<div class="seekOptions">
|
||||
<label for="from">{t}From{/t}</label> <input type="text" pattern="(\d+:)?(\d+:)?\d+(\.\d+)?"
|
||||
placeholder="HH:MM:SS" value="" name="from"
|
||||
id="from"/>
|
||||
<label for="to">{t}to{/t}</label> <input type="text" pattern="(\d+:)?(\d+:)?\d+(\.\d+)?"
|
||||
placeholder="HH:MM:SS" value="" name="to" id="to"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
<a class="combatiblelink small-font" href="{path_for name="extractors"}">{t}See all supported websites{/t}</a>
|
||||
<div id="bookmarklet" class="bookmarklet_wrapper">
|
||||
<p> {t}Drag this to your bookmarks bar:{/t} </p>
|
||||
<a class="bookmarklet small-font" href="javascript:window.location='{$domain}{path_for name='info'}?url='+encodeURIComponent(location.href);">{t}Bookmarklet{/t}</a>
|
||||
<a class="bookmarklet small-font"
|
||||
href="javascript:window.location='{$domain}{path_for name='info'}?url='+encodeURIComponent(location.href);">{t}Bookmarklet{/t}</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
|
|
@ -1,100 +1,105 @@
|
|||
{include file="inc/head.tpl"}
|
||||
<div class="wrapper">
|
||||
<div itemscope itemtype="http://schema.org/VideoObject">
|
||||
<main class="main">
|
||||
{include file="inc/logo.tpl"}
|
||||
{$title="<i itemprop='name'>
|
||||
<div itemscope itemtype="http://schema.org/VideoObject">
|
||||
<main class="main">
|
||||
{include file="inc/logo.tpl"}
|
||||
{$title="<i itemprop='name'>
|
||||
<a itemprop='url' id='video_link'
|
||||
href='{$video->webpage_url}'>
|
||||
{$video->title}</a></i>"}
|
||||
<p id="download_intro">
|
||||
{t params=['@title' => $title]}You are going to download @title.{/t}
|
||||
</p>
|
||||
{if isset($video->thumbnail)}
|
||||
<img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt="" />
|
||||
{/if}
|
||||
{if isset($video->description)}
|
||||
<meta itemprop="description" content="{$video->description|escape}" />
|
||||
{/if}
|
||||
{if isset($video->upload_date)}
|
||||
<meta itemprop="uploadDate" content="{$video->upload_date}" />
|
||||
{/if}
|
||||
<br/>
|
||||
<form action="{path_for name="download"}">
|
||||
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
||||
{if $config->uglyUrls}
|
||||
<input type="hidden" name="page" value="download" />
|
||||
{/if}
|
||||
{if isset($video->formats) && count($video->formats) > 1}
|
||||
<h3><label for="format">{t}Available formats:{/t}</label></h3>
|
||||
<select name="format" id="format" class="formats monospace">
|
||||
<optgroup label="{t}Generic formats{/t}">
|
||||
{foreach $config->genericFormats as $format => $name}
|
||||
<option value="{$format}">{t}{$name}{/t}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
<optgroup label="{t}Detailed formats{/t}" class="monospace">
|
||||
{foreach $video->formats as $format}
|
||||
{if $config->stream || $format->protocol|in_array:array('http', 'https')}
|
||||
{strip}
|
||||
<option value="{$format->format_id}">
|
||||
{$format->ext}
|
||||
{for $foo=1 to (5 - ($format->ext|strlen))}
|
||||
|
||||
{/for}
|
||||
{if isset($format->width)}
|
||||
{$format->width}x{$format->height}
|
||||
{for $foo=1 to (10 - (("{$format->width}x{$format->height}")|strlen))}
|
||||
|
||||
{/for}
|
||||
{else}
|
||||
{for $foo=1 to 10}
|
||||
|
||||
{/for}
|
||||
{/if}
|
||||
{if isset($format->filesize)}
|
||||
{($format->filesize/1000000)|round:2} MB
|
||||
{for $foo=1 to (7 - (($format->filesize/1000000)|round:2|strlen))}
|
||||
|
||||
{/for}
|
||||
{else}
|
||||
{for $foo=1 to 10}
|
||||
|
||||
{/for}
|
||||
{/if}
|
||||
{if isset($format->format_note)}
|
||||
{$format->format_note}
|
||||
{/if}
|
||||
({$format->format_id})
|
||||
</option>
|
||||
{/strip}
|
||||
{/if}
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
</select><br/><br/>
|
||||
{/if}
|
||||
{if $config->stream}
|
||||
<input type="checkbox" {if $config->stream != 'ask'}checked{/if} name="stream" id="stream"/>
|
||||
<label for="stream">{t}Stream the video through the server{/t}</label>
|
||||
<br/><br/>
|
||||
{/if}
|
||||
{if $config->convertAdvanced}
|
||||
<input type="checkbox" name="customConvert" id="customConvert"/>
|
||||
<label for="customConvert">{t}Convert into a custom format:{/t}</label>
|
||||
<select title="{t}Custom format{/t}" name="customFormat" aria-label="{t}Format to convert to{/t}">
|
||||
{foreach $config->convertAdvancedFormats as $format}
|
||||
<option>{$format}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{t}with{/t}
|
||||
<label for="customBitrate" class="sr-only">{t}Bit rate{/t}</label>
|
||||
<input type="number" value="{$config->audioBitrate}" title="{t}Custom bitrate{/t}" class="customBitrate"
|
||||
name="customBitrate" id="customBitrate" aria-describedby="customBitrateUnit" />
|
||||
<span id="customBitrateUnit">{t}kbit/s audio{/t}</span>
|
||||
<br/><br/>
|
||||
{/if}
|
||||
<input class="downloadBtn" type="submit" value="{t}Download{/t}" /><br/>
|
||||
</form>
|
||||
</main>
|
||||
</div>
|
||||
{include file="inc/footer.tpl"}
|
||||
<p id="download_intro">
|
||||
{t params=['@title' => $title]}You are going to download @title.{/t}
|
||||
</p>
|
||||
{if isset($video->thumbnail)}
|
||||
<img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt=""/>
|
||||
{/if}
|
||||
{if isset($video->description)}
|
||||
<meta itemprop="description" content="{$video->description|escape}"/>
|
||||
{/if}
|
||||
{if isset($video->upload_date)}
|
||||
<meta itemprop="uploadDate" content="{$video->upload_date}"/>
|
||||
{/if}
|
||||
<br/>
|
||||
<form action="{path_for name="download"}">
|
||||
<input type="hidden" name="url" value="{$video->webpage_url}"/>
|
||||
{if $config->uglyUrls}
|
||||
<input type="hidden" name="page" value="download"/>
|
||||
{/if}
|
||||
{if isset($video->formats) && count($video->formats) > 1}
|
||||
<h3><label for="format">{t}Available formats:{/t}</label></h3>
|
||||
<select name="format" id="format" class="formats monospace">
|
||||
<optgroup label="{t}Generic formats{/t}">
|
||||
{foreach $config->genericFormats as $format => $name}
|
||||
<option value="{$format}">{t}{$name}{/t}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
<optgroup label="{t}Detailed formats{/t}" class="monospace">
|
||||
{foreach $video->formats as $format}
|
||||
{if $config->stream || $format->protocol|in_array:array('http', 'https')}
|
||||
{strip}
|
||||
<option value="{$format->format_id}">
|
||||
{$format->ext}
|
||||
{for $foo=1 to (5 - ($format->ext|strlen))}
|
||||
|
||||
{/for}
|
||||
{if isset($format->width)}
|
||||
{$format->width}x{$format->height}
|
||||
{for $foo=1 to (10 - (("{$format->width}x{$format->height}")|strlen))}
|
||||
|
||||
{/for}
|
||||
{else}
|
||||
{for $foo=1 to 10}
|
||||
|
||||
{/for}
|
||||
{/if}
|
||||
{if isset($format->filesize)}
|
||||
{($format->filesize/1000000)|round:2} MB
|
||||
{for $foo=1 to (7 - (($format->filesize/1000000)|round:2|strlen))}
|
||||
|
||||
{/for}
|
||||
{else}
|
||||
{for $foo=1 to 10}
|
||||
|
||||
{/for}
|
||||
{/if}
|
||||
{if isset($format->format_note)}
|
||||
{$format->format_note}
|
||||
{/if}
|
||||
({$format->format_id})
|
||||
</option>
|
||||
{/strip}
|
||||
{/if}
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
</select>
|
||||
<br/>
|
||||
<br/>
|
||||
{/if}
|
||||
{if $config->stream}
|
||||
<input type="checkbox" {if $config->stream != 'ask'}checked{/if} name="stream" id="stream"/>
|
||||
<label for="stream">{t}Stream the video through the server{/t}</label>
|
||||
<br/>
|
||||
<br/>
|
||||
{/if}
|
||||
{if $config->convertAdvanced}
|
||||
<input type="checkbox" name="customConvert" id="customConvert"/>
|
||||
<label for="customConvert">{t}Convert into a custom format:{/t}</label>
|
||||
<select title="{t}Custom format{/t}" name="customFormat" aria-label="{t}Format to convert to{/t}">
|
||||
{foreach $config->convertAdvancedFormats as $format}
|
||||
<option>{$format}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{t}with{/t}
|
||||
<label for="customBitrate" class="sr-only">{t}Bit rate{/t}</label>
|
||||
<input type="number" value="{$config->audioBitrate}" title="{t}Custom bitrate{/t}"
|
||||
class="customBitrate"
|
||||
name="customBitrate" id="customBitrate" aria-describedby="customBitrateUnit"/>
|
||||
<span id="customBitrateUnit">{t}kbit/s audio{/t}</span>
|
||||
<br/>
|
||||
<br/>
|
||||
{/if}
|
||||
<input class="downloadBtn" type="submit" value="{t}Download{/t}"/><br/>
|
||||
</form>
|
||||
</main>
|
||||
</div>
|
||||
{include file="inc/footer.tpl"}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
<p>{t}You need a password in order to download this video.{/t}</p>
|
||||
<form action="" method="POST">
|
||||
<label class="sr-only" for="password">{t}Video password{/t}</label>
|
||||
<input class="URLinput" type="password" name="password" id="password" />
|
||||
<input class="URLinput" type="password" name="password" id="password"/>
|
||||
<br/><br/>
|
||||
<input class="downloadBtn" type="submit" value="{t}Download{/t}" />
|
||||
<input class="downloadBtn" type="submit" value="{t}Download{/t}"/>
|
||||
</form>
|
||||
</main>
|
||||
{include file='inc/footer.tpl'}
|
||||
{include file='inc/footer.tpl'}
|
||||
|
|
|
@ -1,43 +1,44 @@
|
|||
{include file="inc/head.tpl"}
|
||||
<div class="wrapper">
|
||||
<main class="main">
|
||||
{include file="inc/logo.tpl"}
|
||||
<main class="main">
|
||||
{include file="inc/logo.tpl"}
|
||||
|
||||
{if isset($video->title)}
|
||||
{$title="<i>
|
||||
{if isset($video->title)}
|
||||
{$title="<i>
|
||||
<a href='{$video->webpage_url}'>
|
||||
{$video->title}</a>
|
||||
</i>"}
|
||||
<p>
|
||||
{t params=['@title'=>$title]}Videos extracted from @title:{/t}
|
||||
</p>
|
||||
{/if}
|
||||
<p>
|
||||
{t params=['@title'=>$title]}Videos extracted from @title:{/t}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{if $config->stream}
|
||||
<a href="{path_for name="download"}?url={$video->webpage_url}" class="downloadBtn">Download everything</a>
|
||||
{/if}
|
||||
{foreach $video->entries as $entry}
|
||||
<div class="playlist-entry">
|
||||
<h3 class="playlist-entry-title"><a target="_blank" href="{strip}
|
||||
{if $config->stream}
|
||||
<a href="{path_for name="download"}?url={$video->webpage_url}" class="downloadBtn">Download everything</a>
|
||||
{/if}
|
||||
{foreach $video->entries as $entry}
|
||||
<div class="playlist-entry">
|
||||
<h3 class="playlist-entry-title"><a target="_blank" href="{strip}
|
||||
{if isset($entry->ie_key) and $entry->ie_key == Youtube and !filter_var($entry->url, FILTER_VALIDATE_URL)}
|
||||
https://www.youtube.com/watch?v=
|
||||
{/if}
|
||||
{$entry->url}
|
||||
{/strip}">
|
||||
{if !isset($entry->title)}
|
||||
{if $entry->ie_key == YoutubePlaylist}
|
||||
Playlist
|
||||
{else}
|
||||
Video
|
||||
{/if}
|
||||
{else}
|
||||
{$entry->title}
|
||||
{/if}
|
||||
</a></h3>
|
||||
<a target="_blank" class="downloadBtn" href="{path_for name="download"}?url={$entry->url}">{t}Download{/t}</a>
|
||||
<a target="_blank" href="{path_for name="info"}?url={$entry->url}">{t}More options{/t}</a>
|
||||
</div>
|
||||
{/foreach}
|
||||
{if !isset($entry->title)}
|
||||
{if $entry->ie_key == YoutubePlaylist}
|
||||
Playlist
|
||||
{else}
|
||||
Video
|
||||
{/if}
|
||||
{else}
|
||||
{$entry->title}
|
||||
{/if}
|
||||
</a></h3>
|
||||
<a target="_blank" class="downloadBtn"
|
||||
href="{path_for name="download"}?url={$entry->url}">{t}Download{/t}</a>
|
||||
<a target="_blank" href="{path_for name="info"}?url={$entry->url}">{t}More options{/t}</a>
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
</main>
|
||||
{include file="inc/footer.tpl"}
|
||||
</main>
|
||||
{include file="inc/footer.tpl"}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Config;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +33,7 @@ abstract class BaseTest extends TestCase
|
|||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ class ConfigTest extends BaseTest
|
|||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ class ConfigTest extends BaseTest
|
|||
public function testGetInstance()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, false);
|
||||
$this->assertEquals(false, $config->convert);
|
||||
$this->assertConfig($config);
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,7 @@ class ConfigTest extends BaseTest
|
|||
Config::destroyInstance();
|
||||
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, false);
|
||||
$this->assertEquals(false, $config->convert);
|
||||
$this->assertConfig($config);
|
||||
}
|
||||
|
||||
|
@ -81,6 +82,7 @@ class ConfigTest extends BaseTest
|
|||
* Test the setFile function.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSetFile()
|
||||
{
|
||||
|
@ -103,24 +105,26 @@ class ConfigTest extends BaseTest
|
|||
* Test the setOptions function.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSetOptions()
|
||||
{
|
||||
Config::setOptions(['appName' => 'foo']);
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->appName, 'foo');
|
||||
$this->assertEquals('foo', $config->appName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the setOptions function.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testSetOptionsWithoutUpdate()
|
||||
{
|
||||
Config::setOptions(['appName' => 'foo'], false);
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->appName, 'foo');
|
||||
$this->assertEquals('foo', $config->appName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +153,7 @@ class ConfigTest extends BaseTest
|
|||
* Test the getInstance function with the CONVERT and PYTHON environment variables.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetInstanceWithEnv()
|
||||
{
|
||||
|
@ -156,7 +161,7 @@ class ConfigTest extends BaseTest
|
|||
putenv('CONVERT=1');
|
||||
Config::setFile($this->getConfigFile());
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, true);
|
||||
$this->assertEquals(true, $config->convert);
|
||||
putenv('CONVERT');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Controller\BaseController;
|
||||
use Alltube\Controller\DownloadController;
|
||||
use Alltube\Controller\FrontController;
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\ViewFactory;
|
||||
use Exception;
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
|
@ -43,11 +45,13 @@ abstract class ControllerTest extends BaseTest
|
|||
|
||||
/**
|
||||
* Controller instance used in tests.
|
||||
* @var BaseController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -78,7 +82,7 @@ abstract class ControllerTest extends BaseTest
|
|||
* Run controller function with custom query parameters and return the result.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
* @param mixed[] $params Query parameters
|
||||
*
|
||||
* @return Response HTTP response
|
||||
*/
|
||||
|
@ -94,7 +98,7 @@ abstract class ControllerTest extends BaseTest
|
|||
* Assert that calling controller function with these parameters returns a 200 HTTP response.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
* @param mixed[] $params Query parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -107,7 +111,7 @@ abstract class ControllerTest extends BaseTest
|
|||
* Assert that calling controller function with these parameters returns an HTTP redirect.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
* @param mixed[] $params Query parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -120,7 +124,7 @@ abstract class ControllerTest extends BaseTest
|
|||
* Assert that calling controller function with these parameters returns an HTTP 500 error.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
* @param mixed[] $params Query parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -133,7 +137,7 @@ abstract class ControllerTest extends BaseTest
|
|||
* Assert that calling controller function with these parameters returns an HTTP 400 error.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
* @param mixed[] $params Query parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\ConvertedPlaylistArchiveStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the ConvertedPlaylistArchiveStream class.
|
||||
|
@ -17,6 +18,7 @@ class ConvertedPlaylistArchiveStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Config;
|
||||
use Alltube\Controller\DownloadController;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the FrontController class.
|
||||
|
@ -17,6 +18,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -62,6 +64,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with streams enabled.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithStream()
|
||||
{
|
||||
|
@ -77,6 +80,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with an M3U stream.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithM3uStream()
|
||||
{
|
||||
|
@ -96,6 +100,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with an RTMP stream.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithRtmpStream()
|
||||
{
|
||||
|
@ -113,6 +118,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with a remuxed video.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithRemux()
|
||||
{
|
||||
|
@ -182,6 +188,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires OS Linux
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithPlaylist()
|
||||
{
|
||||
|
@ -197,6 +204,7 @@ class DownloadControllerTest extends ControllerTest
|
|||
* Test the download() function with an advanced conversion.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDownloadWithAdvancedConversion()
|
||||
{
|
||||
|
|
|
@ -17,8 +17,15 @@ use Slim\Http\Request;
|
|||
*/
|
||||
class FrontControllerTest extends ControllerTest
|
||||
{
|
||||
/**
|
||||
* Controller instance used in tests.
|
||||
* @var FrontController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -41,6 +48,7 @@ class FrontControllerTest extends ControllerTest
|
|||
* Test the constructor with streams enabled.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testConstructorWithStream()
|
||||
{
|
||||
|
@ -120,6 +128,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithAudio()
|
||||
{
|
||||
|
@ -136,6 +145,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithVimeoAudio()
|
||||
{
|
||||
|
@ -150,6 +160,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithUnconvertedAudio()
|
||||
{
|
||||
|
@ -197,6 +208,7 @@ class FrontControllerTest extends ControllerTest
|
|||
*
|
||||
* @return void
|
||||
* @requires download
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInfoWithStream()
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Controller\JsonController;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the FrontController class.
|
||||
|
@ -15,6 +16,7 @@ class JsonControllerTest extends ControllerTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Locale;
|
||||
use Alltube\LocaleManager;
|
||||
use Alltube\LocaleMiddleware;
|
||||
use Slim\Container;
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\PlaylistArchiveStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the PlaylistArchiveStream class.
|
||||
|
@ -17,6 +18,7 @@ class PlaylistArchiveStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +16,7 @@ abstract class StreamTest extends BaseTest
|
|||
{
|
||||
/**
|
||||
* Stream instance.
|
||||
* @var StreamInterface
|
||||
*/
|
||||
protected $stream;
|
||||
|
||||
|
@ -36,7 +38,7 @@ abstract class StreamTest extends BaseTest
|
|||
public function testWrite()
|
||||
{
|
||||
if ($this->stream->isWritable()) {
|
||||
$this->assertNull($this->stream->write('foo'));
|
||||
$this->assertIsInt($this->stream->write('foo'));
|
||||
} else {
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->stream->write('foo');
|
||||
|
@ -103,7 +105,7 @@ abstract class StreamTest extends BaseTest
|
|||
*/
|
||||
public function testEof()
|
||||
{
|
||||
$this->assertFalse($this->stream->eof());
|
||||
$this->assertIsBool($this->stream->eof());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@ class VideoStubsTest extends BaseTest
|
|||
|
||||
/**
|
||||
* Initialize properties used by test.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\Config;
|
||||
use Alltube\Exception\EmptyUrlException;
|
||||
use Alltube\Exception\PasswordException;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
|
@ -20,6 +22,7 @@ class VideoTest extends BaseTest
|
|||
* Test getExtractors function.
|
||||
*
|
||||
* @return void
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetExtractors()
|
||||
{
|
||||
|
@ -29,13 +32,15 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getUrl function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
* @param string $filename Filename
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
* @param string $filename Filename
|
||||
* @param string $extension File extension
|
||||
* @param string $domain Domain
|
||||
* @param string $domain Domain
|
||||
*
|
||||
* @return void
|
||||
* @throws PasswordException
|
||||
* @throws EmptyUrlException
|
||||
* @dataProvider urlProvider
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @dataProvider remuxUrlProvider
|
||||
|
@ -57,6 +62,8 @@ class VideoTest extends BaseTest
|
|||
* Test getUrl function with a protected video.
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testgetUrlWithPassword()
|
||||
{
|
||||
|
@ -70,6 +77,8 @@ class VideoTest extends BaseTest
|
|||
* Test getUrl function with a protected video and no password.
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testgetUrlWithMissingPassword()
|
||||
{
|
||||
|
@ -82,6 +91,8 @@ class VideoTest extends BaseTest
|
|||
* Test getUrl function with a protected video and a wrong password.
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testgetUrlWithWrongPassword()
|
||||
{
|
||||
|
@ -96,6 +107,8 @@ class VideoTest extends BaseTest
|
|||
* @param string $url URL
|
||||
*
|
||||
* @return void
|
||||
* @throws EmptyUrlException
|
||||
* @throws PasswordException
|
||||
* @dataProvider ErrorUrlProvider
|
||||
*/
|
||||
public function testgetUrlError($url)
|
||||
|
@ -112,7 +125,7 @@ class VideoTest extends BaseTest
|
|||
*/
|
||||
public function urlProvider()
|
||||
{
|
||||
$videos = [
|
||||
return [
|
||||
[
|
||||
'https://www.youtube.com/watch?v=M7IpKCZ47pU', 'best[protocol^=http]',
|
||||
'It_s_Not_Me_It_s_You_-_Hearts_Under_Fire-M7IpKCZ47pU',
|
||||
|
@ -136,11 +149,9 @@ class VideoTest extends BaseTest
|
|||
'https://vimeo.com/24195442', 'http-720p',
|
||||
'Carving_the_Mountains-24195442',
|
||||
'mp4',
|
||||
'gcs-vimeo.akamaized.net',
|
||||
'akamaized.net',
|
||||
]
|
||||
];
|
||||
|
||||
return $videos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,7 +178,7 @@ class VideoTest extends BaseTest
|
|||
*/
|
||||
public function m3uUrlProvider()
|
||||
{
|
||||
$videos = [
|
||||
return [
|
||||
[
|
||||
'https://twitter.com/verge/status/813055465324056576/video/1', 'hls-2176',
|
||||
'The_Verge_-_This_tiny_origami_robot_can_self-fold_and_complete_tasks-813055465324056576',
|
||||
|
@ -175,8 +186,6 @@ class VideoTest extends BaseTest
|
|||
'video.twimg.com',
|
||||
]
|
||||
];
|
||||
|
||||
return $videos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,12 +220,13 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getJSON function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetJson($url, $format)
|
||||
{
|
||||
|
@ -237,6 +247,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider ErrorURLProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetJsonError($url)
|
||||
{
|
||||
|
@ -248,15 +259,16 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getFilename function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
* @param string $filename Filename
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
* @param string $filename Filename
|
||||
* @param string $extension File extension
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @dataProvider remuxUrlProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetFilename($url, $format, $filename, $extension)
|
||||
{
|
||||
|
@ -271,6 +283,7 @@ class VideoTest extends BaseTest
|
|||
*
|
||||
* @return void
|
||||
* @dataProvider ErrorUrlProvider
|
||||
* @throws PasswordException
|
||||
*/
|
||||
public function testGetFilenameError($url)
|
||||
{
|
||||
|
@ -282,11 +295,12 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getAudioStream function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetAudioStream($url, $format)
|
||||
{
|
||||
|
@ -371,11 +385,12 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getM3uStream function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider m3uUrlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetM3uStream($url, $format)
|
||||
{
|
||||
|
@ -386,11 +401,12 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getRemuxStream function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider remuxUrlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetRemuxStream($url, $format)
|
||||
{
|
||||
|
@ -417,11 +433,12 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getRtmpStream function.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider rtmpUrlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetRtmpStream($url, $format)
|
||||
{
|
||||
|
@ -453,11 +470,12 @@ class VideoTest extends BaseTest
|
|||
/**
|
||||
* Test getConvertedStream function without avconv.
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetConvertedStream($url, $format)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ use Slim\Container;
|
|||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Views\Smarty;
|
||||
use SmartyException;
|
||||
|
||||
/**
|
||||
* Unit tests for the ViewFactory class.
|
||||
|
@ -22,6 +23,7 @@ class ViewFactoryTest extends BaseTest
|
|||
* Test the create() function.
|
||||
*
|
||||
* @return void
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
|
@ -35,6 +37,7 @@ class ViewFactoryTest extends BaseTest
|
|||
* Test the create() function with a X-Forwarded-Proto header.
|
||||
*
|
||||
* @return void
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function testCreateWithXForwardedProto()
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\YoutubeChunkStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the YoutubeChunkStream class.
|
||||
|
@ -17,6 +18,7 @@ class YoutubeChunkStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Alltube\Test;
|
|||
|
||||
use Alltube\Stream\YoutubeStream;
|
||||
use Alltube\Video;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Unit tests for the YoutubeStream class.
|
||||
|
@ -17,6 +18,7 @@ class YoutubeStreamTest extends StreamTest
|
|||
{
|
||||
/**
|
||||
* Prepare tests.
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use phpmock\mockery\PHPMockery;
|
|||
// Composer autoload.
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
ini_set('session.use_cookies', 0);
|
||||
ini_set('session.use_cookies', '0');
|
||||
session_cache_limiter('');
|
||||
session_start();
|
||||
|
||||
|
|
Loading…
Reference in a new issue