YAML config file
This commit is contained in:
parent
8d4cf18360
commit
5249df52e6
15 changed files with 168 additions and 67 deletions
54
classes/Config.php
Normal file
54
classes/Config.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Config class
|
||||
*
|
||||
* PHP Version 5.3.10
|
||||
*
|
||||
* @category Youtube-dl
|
||||
* @package Youtubedl
|
||||
* @author Pierre Rudloff <contact@rudloff.pro>
|
||||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://rudloff.pro
|
||||
* */
|
||||
namespace Alltube;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
/**
|
||||
* Class to manage config parameters
|
||||
*
|
||||
* PHP Version 5.3.10
|
||||
*
|
||||
* @category Youtube-dl
|
||||
* @package Youtubedl
|
||||
* @author Pierre Rudloff <contact@rudloff.pro>
|
||||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://rudloff.pro
|
||||
* */
|
||||
Class Config
|
||||
{
|
||||
private static $_instance;
|
||||
|
||||
public $youtubedl = __DIR__.'/../vendor/rg3/youtube-dl/youtube_dl/__main__.py';
|
||||
public $python = '/usr/bin/python';
|
||||
public $params = '--no-playlist --no-warnings -f best';
|
||||
public $convert = false;
|
||||
public $avconv = __DIR__.'/ffmpeg/ffmpeg';
|
||||
|
||||
private function __construct() {
|
||||
$yaml = Yaml::parse(__DIR__.'/../config.yml');
|
||||
foreach ($yaml as $param=>$value) {
|
||||
if (isset($this->$param)) {
|
||||
$this->$param = $value;
|
||||
}
|
||||
}
|
||||
if (getenv('CONVERT')) {
|
||||
$this->convert = getenv('CONVERT');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
if(is_null(self::$_instance)) {
|
||||
self::$_instance = new Config();
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Main class
|
||||
* VideoDownload class
|
||||
*
|
||||
* PHP Version 5.3.10
|
||||
*
|
||||
|
@ -13,7 +12,6 @@
|
|||
* */
|
||||
namespace Alltube;
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Main class
|
||||
*
|
||||
* PHP Version 5.3.10
|
||||
|
@ -33,8 +31,9 @@ Class VideoDownload
|
|||
* */
|
||||
static function getUA()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --dump-user-agent',
|
||||
$config->python.' '.$config->youtubedl.' --dump-user-agent',
|
||||
$version
|
||||
);
|
||||
return $version[0];
|
||||
|
@ -47,8 +46,9 @@ Class VideoDownload
|
|||
* */
|
||||
static function listExtractors()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --list-extractors',
|
||||
$config->python.' '.$config->youtubedl.' --list-extractors',
|
||||
$extractors
|
||||
);
|
||||
return $extractors;
|
||||
|
@ -64,7 +64,8 @@ Class VideoDownload
|
|||
* */
|
||||
static function getFilename($url, $format=null)
|
||||
{
|
||||
$cmd=PYTHON.' '.YOUTUBE_DL;
|
||||
$config = Config::getInstance();
|
||||
$cmd=$config->python.' '.$config->youtubedl;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
|
@ -86,7 +87,8 @@ Class VideoDownload
|
|||
* */
|
||||
static function getJSON($url, $format=null)
|
||||
{
|
||||
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
|
||||
$config = Config::getInstance();
|
||||
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
|
@ -111,7 +113,8 @@ Class VideoDownload
|
|||
* */
|
||||
static function getURL($url, $format=null)
|
||||
{
|
||||
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
|
||||
$config = Config::getInstance();
|
||||
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue