This commit is contained in:
Pierre Rudloff 2016-02-28 23:04:53 +01:00
parent c73be59a52
commit cf9e90ce0d
4 changed files with 29 additions and 6 deletions

View file

@ -57,6 +57,7 @@ Class Config
/** /**
* Get singleton instance * Get singleton instance
*
* @return Config * @return Config
*/ */
public static function getInstance() public static function getInstance()

View file

@ -32,7 +32,10 @@ Class VideoDownload
static function getUA() static function getUA()
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params); $cmd = escapeshellcmd(
$config->python.' '.escapeshellarg($config->youtubedl).
' '.$config->params
);
exec( exec(
$cmd.' --dump-user-agent', $cmd.' --dump-user-agent',
$version $version
@ -48,7 +51,10 @@ Class VideoDownload
static function listExtractors() static function listExtractors()
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params); $cmd = escapeshellcmd(
$config->python.' '.escapeshellarg($config->youtubedl).
' '.$config->params
);
exec( exec(
$cmd.' --list-extractors', $cmd.' --list-extractors',
$extractors $extractors
@ -67,7 +73,10 @@ Class VideoDownload
static function getFilename($url, $format=null) static function getFilename($url, $format=null)
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params); $cmd = escapeshellcmd(
$config->python.' '.escapeshellarg($config->youtubedl).
' '.$config->params
);
if (isset($format)) { if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format); $cmd .= ' -f '.escapeshellarg($format);
} }
@ -90,7 +99,10 @@ Class VideoDownload
static function getJSON($url, $format=null) static function getJSON($url, $format=null)
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params); $cmd = escapeshellcmd(
$config->python.' '.escapeshellarg($config->youtubedl).
' '.$config->params
);
if (isset($format)) { if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format); $cmd .= ' -f '.escapeshellarg($format);
} }
@ -116,7 +128,10 @@ Class VideoDownload
static function getURL($url, $format=null) static function getURL($url, $format=null)
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params); $cmd = escapeshellcmd(
$config->python.' '.escapeshellarg($config->youtubedl).
' '.$config->params
);
if (isset($format)) { if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format); $cmd .= ' -f '.escapeshellarg($format);
} }

View file

@ -29,6 +29,7 @@ class FrontController
/** /**
* Display index page * Display index page
*
* @return void * @return void
*/ */
static function index() static function index()
@ -55,6 +56,7 @@ class FrontController
/** /**
* Display a list of extractors * Display a list of extractors
*
* @return void * @return void
*/ */
static function extractors() static function extractors()
@ -79,6 +81,7 @@ class FrontController
/** /**
* Dislay information about the video * Dislay information about the video
*
* @return void * @return void
*/ */
static function video() static function video()
@ -130,7 +133,8 @@ class FrontController
); );
header("Content-Type: audio/mpeg"); header("Content-Type: audio/mpeg");
passthru( passthru(
'curl '.$config->curl_params.' --user-agent '.escapeshellarg($UA). 'curl '.$config->curl_params.
' --user-agent '.escapeshellarg($UA).
' '.escapeshellarg($video->url). ' '.escapeshellarg($video->url).
' | '.$config->avconv. ' | '.$config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1' ' -v quiet -i - -f mp3 -vn pipe:1'
@ -180,6 +184,7 @@ class FrontController
/** /**
* Redirect to video file * Redirect to video file
*
* @return void * @return void
*/ */
static function redirect() static function redirect()
@ -198,6 +203,7 @@ class FrontController
/** /**
* Output JSON info about the video * Output JSON info about the video
*
* @return void * @return void
*/ */
static function json() static function json()

View file

@ -28,6 +28,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase
/** /**
* Test the getInstance function * Test the getInstance function
*
* @return void * @return void
*/ */
public function testGetInstance() public function testGetInstance()