Always use custom arguments (fixes #45)

Custom arguments for curl
This commit is contained in:
Pierre Rudloff 2016-02-28 23:00:33 +01:00
parent b69a12d49c
commit c73be59a52
4 changed files with 8 additions and 4 deletions

View file

@ -32,6 +32,7 @@ Class Config
public $params = '--no-playlist --no-warnings -f best'; public $params = '--no-playlist --no-warnings -f best';
public $convert = false; public $convert = false;
public $avconv = 'vendor/bin/ffmpeg'; public $avconv = 'vendor/bin/ffmpeg';
public $curl_params = '';
/** /**
* Config constructor * Config constructor

View file

@ -32,8 +32,9 @@ Class VideoDownload
static function getUA() static function getUA()
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params);
exec( exec(
escapeshellcmd($config->python).' '.escapeshellarg($config->youtubedl).' --dump-user-agent', $cmd.' --dump-user-agent',
$version $version
); );
return $version[0]; return $version[0];
@ -47,8 +48,9 @@ Class VideoDownload
static function listExtractors() static function listExtractors()
{ {
$config = Config::getInstance(); $config = Config::getInstance();
$cmd = escapeshellcmd($config->python.' '.escapeshellarg($config->youtubedl).' '.$config->params);
exec( exec(
escapeshellcmd($config->python).' '.escapeshellarg($config->youtubedl).' --list-extractors', $cmd.' --list-extractors',
$extractors $extractors
); );
return $extractors; return $extractors;
@ -65,7 +67,7 @@ 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); $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

@ -1,5 +1,6 @@
youtubedl: vendor/rg3/youtube-dl/youtube_dl/__main__.py youtubedl: vendor/rg3/youtube-dl/youtube_dl/__main__.py
python: /usr/bin/python python: /usr/bin/python
params: --no-playlist --no-warnings -f best params: --no-playlist --no-warnings -f best
curl_params:
convert: false convert: false
avconv: vendor/bin/ffmpeg avconv: vendor/bin/ffmpeg

View file

@ -130,7 +130,7 @@ class FrontController
); );
header("Content-Type: audio/mpeg"); header("Content-Type: audio/mpeg");
passthru( passthru(
'curl --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'