2015-10-31 14:42:25 +00:00
|
|
|
<?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;
|
2016-03-29 23:49:08 +00:00
|
|
|
|
2015-10-31 14:42:25 +00:00
|
|
|
use Symfony\Component\Yaml\Yaml;
|
2016-03-29 23:49:08 +00:00
|
|
|
|
2015-10-31 14:42:25 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* */
|
2016-03-29 23:49:08 +00:00
|
|
|
class Config
|
2015-10-31 14:42:25 +00:00
|
|
|
{
|
2016-03-29 23:49:08 +00:00
|
|
|
private static $instance;
|
2015-10-31 14:42:25 +00:00
|
|
|
|
2015-10-31 14:56:00 +00:00
|
|
|
public $youtubedl = 'vendor/rg3/youtube-dl/youtube_dl/__main__.py';
|
2015-10-31 14:42:25 +00:00
|
|
|
public $python = '/usr/bin/python';
|
|
|
|
public $params = '--no-playlist --no-warnings -f best';
|
|
|
|
public $convert = false;
|
2015-11-21 19:54:38 +00:00
|
|
|
public $avconv = 'vendor/bin/ffmpeg';
|
2016-02-28 22:00:33 +00:00
|
|
|
public $curl_params = '';
|
2015-10-31 14:42:25 +00:00
|
|
|
|
2015-10-31 14:50:32 +00:00
|
|
|
/**
|
|
|
|
* Config constructor
|
|
|
|
*/
|
|
|
|
private function __construct()
|
|
|
|
{
|
2015-12-18 23:58:14 +00:00
|
|
|
$yamlfile = __DIR__.'/../config.yml';
|
|
|
|
if (is_file($yamlfile)) {
|
|
|
|
$yaml = Yaml::parse(file_get_contents($yamlfile));
|
|
|
|
if (isset($yaml) && is_array($yaml)) {
|
2016-03-29 23:49:08 +00:00
|
|
|
foreach ($yaml as $param => $value) {
|
2015-12-18 23:58:14 +00:00
|
|
|
if (isset($this->$param)) {
|
|
|
|
$this->$param = $value;
|
|
|
|
}
|
2015-10-31 14:57:36 +00:00
|
|
|
}
|
2015-10-31 14:42:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (getenv('CONVERT')) {
|
|
|
|
$this->convert = getenv('CONVERT');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-31 14:50:32 +00:00
|
|
|
/**
|
|
|
|
* Get singleton instance
|
2016-02-28 22:04:53 +00:00
|
|
|
*
|
2015-10-31 14:50:32 +00:00
|
|
|
* @return Config
|
|
|
|
*/
|
|
|
|
public static function getInstance()
|
|
|
|
{
|
2016-03-29 23:49:08 +00:00
|
|
|
if (is_null(self::$instance)) {
|
|
|
|
self::$instance = new Config();
|
2015-10-31 14:42:25 +00:00
|
|
|
}
|
2016-03-29 23:49:08 +00:00
|
|
|
return self::$instance;
|
2015-10-31 14:42:25 +00:00
|
|
|
}
|
|
|
|
}
|