Add a way to log commands
This commit is contained in:
parent
dfdf6fef76
commit
0413427bbe
3 changed files with 74 additions and 51 deletions
|
@ -14,6 +14,8 @@ use Alltube\Library\Exception\WrongPasswordException;
|
||||||
use Alltube\Library\Exception\YoutubedlException;
|
use Alltube\Library\Exception\YoutubedlException;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Psr\Log\NullLogger;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +67,11 @@ class Downloader
|
||||||
*/
|
*/
|
||||||
private $params;
|
private $params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LoggerInterface
|
||||||
|
*/
|
||||||
|
private $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloader constructor.
|
* Downloader constructor.
|
||||||
* @param string $youtubedl youtube-dl binary path
|
* @param string $youtubedl youtube-dl binary path
|
||||||
|
@ -88,6 +95,17 @@ class Downloader
|
||||||
$this->avconv = $avconv;
|
$this->avconv = $avconv;
|
||||||
$this->phantomjsDir = $phantomjsDir;
|
$this->phantomjsDir = $phantomjsDir;
|
||||||
$this->avconvVerbosity = $avconvVerbosity;
|
$this->avconvVerbosity = $avconvVerbosity;
|
||||||
|
|
||||||
|
$this->logger = new NullLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setLogger(LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +225,10 @@ class Downloader
|
||||||
$arguments[] = '-user_agent';
|
$arguments[] = '-user_agent';
|
||||||
$arguments[] = $video->getProp('dump-user-agent');
|
$arguments[] = $video->getProp('dump-user-agent');
|
||||||
|
|
||||||
return new Process($arguments);
|
$process = new Process($arguments);
|
||||||
|
$this->logger->debug($process->getCommandLine());
|
||||||
|
|
||||||
|
return $process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,6 +247,7 @@ class Downloader
|
||||||
$process = $this->getProcess($arguments);
|
$process = $this->getProcess($arguments);
|
||||||
//This is needed by the openload extractor because it runs PhantomJS
|
//This is needed by the openload extractor because it runs PhantomJS
|
||||||
$process->setEnv(['PATH' => $this->phantomjsDir]);
|
$process->setEnv(['PATH' => $this->phantomjsDir]);
|
||||||
|
$this->logger->debug($process->getCommandLine());
|
||||||
$process->run();
|
$process->run();
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
$errorOutput = trim($process->getErrorOutput());
|
$errorOutput = trim($process->getErrorOutput());
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"homepage": "http://alltubedownload.net/",
|
"homepage": "http://alltubedownload.net/",
|
||||||
"require": {
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
"guzzlehttp/guzzle": "^6.5",
|
"guzzlehttp/guzzle": "^6.5",
|
||||||
"symfony/process": "^4.0|^5.0",
|
"psr/log": "^1.1",
|
||||||
"ext-json": "*"
|
"symfony/process": "^4.0|^5.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpro/grumphp": "^0.18.0",
|
"phpro/grumphp": "^0.18.0",
|
||||||
|
|
96
composer.lock
generated
96
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "e084bdaf7ed377ff4963c65d85513eca",
|
"content-hash": "9a53e4f77d715163307f6736896493b8",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
|
@ -245,6 +245,53 @@
|
||||||
],
|
],
|
||||||
"time": "2016-08-06T14:39:51+00:00"
|
"time": "2016-08-06T14:39:51+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/log",
|
||||||
|
"version": "1.1.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/log.git",
|
||||||
|
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||||
|
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.1.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Log\\": "Psr/Log/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common interface for logging libraries",
|
||||||
|
"homepage": "https://github.com/php-fig/log",
|
||||||
|
"keywords": [
|
||||||
|
"log",
|
||||||
|
"psr",
|
||||||
|
"psr-3"
|
||||||
|
],
|
||||||
|
"time": "2020-03-23T09:12:05+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ralouphie/getallheaders",
|
"name": "ralouphie/getallheaders",
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
|
@ -1559,53 +1606,6 @@
|
||||||
],
|
],
|
||||||
"time": "2019-01-08T18:20:26+00:00"
|
"time": "2019-01-08T18:20:26+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "psr/log",
|
|
||||||
"version": "1.1.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-fig/log.git",
|
|
||||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
|
|
||||||
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.1.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\Log\\": "Psr/Log/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common interface for logging libraries",
|
|
||||||
"homepage": "https://github.com/php-fig/log",
|
|
||||||
"keywords": [
|
|
||||||
"log",
|
|
||||||
"psr",
|
|
||||||
"psr-3"
|
|
||||||
],
|
|
||||||
"time": "2020-03-23T09:12:05+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "roave/security-advisories",
|
"name": "roave/security-advisories",
|
||||||
"version": "dev-master",
|
"version": "dev-master",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue