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 $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 $avconv = 'vendor/bin/ffmpeg';
public $curl_params = '';
public $curl_params = array();
/**
* Config constructor

View file

@ -11,7 +11,8 @@
"mathmarques/smarty-view": "~1.1.0",
"symfony/yaml": "~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",
"guzzlehttp/guzzle": "~6.2.0"
},
@ -40,7 +41,7 @@
"type": "package",
"package": {
"name": "ffmpeg/ffmpeg",
"version": "2.8.4",
"version": "dev-release",
"dist": {
"url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.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",
"This file is @generated automatically"
],
"hash": "347d65d546b37e0a0f459d98687906ad",
"content-hash": "e4325cba5a550465b162ab31dd37ecf3",
"hash": "e1cdeb4248ab93397c2fa390a76b0c62",
"content-hash": "8ad4495699681f4ade03f5e0fbe0b074",
"packages": [
{
"name": "container-interop/container-interop",
@ -36,7 +36,7 @@
},
{
"name": "ffmpeg/ffmpeg",
"version": "2.8.4",
"version": "dev-release",
"dist": {
"type": "xz",
"url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz",
@ -533,6 +533,42 @@
],
"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",
"version": "2016.04.06",
@ -931,7 +967,9 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"ffmpeg/ffmpeg": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],

View file

@ -14,6 +14,8 @@ namespace Alltube\Controller;
use Alltube\VideoDownload;
use Alltube\Config;
use Symfony\Component\Process\ProcessBuilder;
use Chain\Chain;
/**
* Main controller
@ -115,7 +117,18 @@ class FrontController
try {
return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request);
} 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
ini_set(
@ -123,6 +136,33 @@ class FrontController
$video->http_headers->{'User-Agent'}
);
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();
header(
'Content-Disposition: attachment; filename="'.
@ -136,13 +176,22 @@ class FrontController
).'"'
);
header("Content-Type: audio/mpeg");
passthru(
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
' | '.$this->config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1'
);
passthru($chain->getProcess()->getCommandLine());
exit;
} 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();
header(
'Content-Disposition: attachment; filename="'.
@ -156,13 +205,7 @@ class FrontController
).'"'
);
header("Content-Type: audio/mpeg");
passthru(
'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'
);
passthru($chain->getProcess()->getCommandLine());
exit;
}
}