Merge branch 'develop' into feature/stream

Conflicts:
	composer.json
	composer.lock
This commit is contained in:
Pierre Rudloff 2016-04-12 15:13:50 +02:00
commit ac16e68389
4 changed files with 103 additions and 21 deletions

View file

@ -31,10 +31,10 @@ class Config
public $youtubedl = 'vendor/rg3/youtube-dl/youtube_dl/__main__.py'; public $youtubedl = 'vendor/rg3/youtube-dl/youtube_dl/__main__.py';
public $python = '/usr/bin/python'; public $python = '/usr/bin/python';
public $params = array('--no-playlist', '--no-warnings', '-f best', '--playlist-end', 1); public $params = array('--no-playlist', '--no-warnings', '-f best[protocol^=http]', '--playlist-end', 1);
public $convert = false; public $convert = false;
public $avconv = 'vendor/bin/ffmpeg'; public $avconv = 'vendor/bin/ffmpeg';
public $curl_params = ''; public $curl_params = array();
/** /**
* Config constructor * Config constructor

View file

@ -11,7 +11,8 @@
"mathmarques/smarty-view": "~1.1.0", "mathmarques/smarty-view": "~1.1.0",
"symfony/yaml": "~3.0.0", "symfony/yaml": "~3.0.0",
"symfony/process": "~3.0.0", "symfony/process": "~3.0.0",
"ffmpeg/ffmpeg": "~2.8.2", "ptachoire/process-builder-chain": "~1.2.0",
"ffmpeg/ffmpeg": "dev-release",
"rudloff/smarty-plugin-noscheme": "~0.1.0", "rudloff/smarty-plugin-noscheme": "~0.1.0",
"guzzlehttp/guzzle": "~6.2.0" "guzzlehttp/guzzle": "~6.2.0"
}, },
@ -40,7 +41,7 @@
"type": "package", "type": "package",
"package": { "package": {
"name": "ffmpeg/ffmpeg", "name": "ffmpeg/ffmpeg",
"version": "2.8.4", "version": "dev-release",
"dist": { "dist": {
"url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz", "url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz",
"type": "xz" "type": "xz"

46
composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "347d65d546b37e0a0f459d98687906ad", "hash": "e1cdeb4248ab93397c2fa390a76b0c62",
"content-hash": "e4325cba5a550465b162ab31dd37ecf3", "content-hash": "8ad4495699681f4ade03f5e0fbe0b074",
"packages": [ "packages": [
{ {
"name": "container-interop/container-interop", "name": "container-interop/container-interop",
@ -36,7 +36,7 @@
}, },
{ {
"name": "ffmpeg/ffmpeg", "name": "ffmpeg/ffmpeg",
"version": "2.8.4", "version": "dev-release",
"dist": { "dist": {
"type": "xz", "type": "xz",
"url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz", "url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz",
@ -533,6 +533,42 @@
], ],
"time": "2015-05-04 20:22:00" "time": "2015-05-04 20:22:00"
}, },
{
"name": "ptachoire/process-builder-chain",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/krichprollsch/process-builder-chain.git",
"reference": "465055dbcc3b5ef792a768df935571551de4781a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/krichprollsch/process-builder-chain/zipball/465055dbcc3b5ef792a768df935571551de4781a",
"reference": "465055dbcc3b5ef792a768df935571551de4781a",
"shasum": ""
},
"require": {
"symfony/process": "~2.5 || ~3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Chain": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Pierre Tachoire",
"email": "pierre.tachoire@gmail.com"
}
],
"description": "Add ability to chain symfony processes",
"time": "2016-04-10 08:33:20"
},
{ {
"name": "rg3/youtube-dl", "name": "rg3/youtube-dl",
"version": "2016.04.06", "version": "2016.04.06",
@ -931,7 +967,9 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"ffmpeg/ffmpeg": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],

View file

@ -14,6 +14,8 @@ namespace Alltube\Controller;
use Alltube\VideoDownload; use Alltube\VideoDownload;
use Alltube\Config; use Alltube\Config;
use Symfony\Component\Process\ProcessBuilder;
use Chain\Chain;
/** /**
* Main controller * Main controller
@ -115,7 +117,18 @@ class FrontController
try { try {
return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request); return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request);
} catch (\Exception $e) { } catch (\Exception $e) {
$video = $this->download->getJSON($params["url"]); $video = $this->download->getJSON($params["url"], 'best');
$avconvProc = ProcessBuilder::create(
array(
$this->config->avconv,
'-v', 'quiet',
'-i', '-',
'-f', 'mp3',
'-vn',
'pipe:1'
)
);
//Vimeo needs a correct user-agent //Vimeo needs a correct user-agent
ini_set( ini_set(
@ -123,6 +136,33 @@ class FrontController
$video->http_headers->{'User-Agent'} $video->http_headers->{'User-Agent'}
); );
if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') { if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') {
$builder = new ProcessBuilder(
array(
'/usr/bin/rtmpdump',
'-q',
'-r',
$video->url,
'--pageUrl', $video->webpage_url
)
);
if (isset($video->player_url)) {
$builder->add('--swfVfy');
$builder->add($video->player_url);
}
if (isset($video->flash_version)) {
$builder->add('--flashVer');
$builder->add($video->flash_version);
}
if (isset($video->play_path)) {
$builder->add('--playpath');
$builder->add($video->play_path);
}
foreach ($video->rtmp_conn as $conn) {
$builder->add('--conn');
$builder->add($conn);
}
$chain = new Chain($builder->getProcess());
$chain->add('|', $avconvProc);
ob_end_flush(); ob_end_flush();
header( header(
'Content-Disposition: attachment; filename="'. 'Content-Disposition: attachment; filename="'.
@ -136,13 +176,22 @@ class FrontController
).'"' ).'"'
); );
header("Content-Type: audio/mpeg"); header("Content-Type: audio/mpeg");
passthru( passthru($chain->getProcess()->getCommandLine());
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
' | '.$this->config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1'
);
exit; exit;
} else { } else {
$chain = new Chain(
ProcessBuilder::create(
array_merge(
array('curl'),
$this->config->curl_params,
array(
'--user-agent', $video->http_headers->{'User-Agent'},
$video->url
)
)
)
);
$chain->add('|', $avconvProc);
ob_end_flush(); ob_end_flush();
header( header(
'Content-Disposition: attachment; filename="'. 'Content-Disposition: attachment; filename="'.
@ -156,13 +205,7 @@ class FrontController
).'"' ).'"'
); );
header("Content-Type: audio/mpeg"); header("Content-Type: audio/mpeg");
passthru( passthru($chain->getProcess()->getCommandLine());
'curl '.$this->config->curl_params.
' --user-agent '.escapeshellarg($video->http_headers->{'User-Agent'}).
' '.escapeshellarg($video->url).
' | '.$this->config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1'
);
exit; exit;
} }
} }