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
*
* @return Config
*/
public static function getInstance()

View file

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

View file

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

View file

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