WIP stream
This commit is contained in:
parent
7eef219128
commit
df9f60339d
5 changed files with 216 additions and 35 deletions
|
@ -12,7 +12,8 @@
|
||||||
"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",
|
"ffmpeg/ffmpeg": "~2.8.2",
|
||||||
"rudloff/smarty-plugin-noscheme": "~0.1.0"
|
"rudloff/smarty-plugin-noscheme": "~0.1.0",
|
||||||
|
"guzzlehttp/guzzle": "~6.2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/var-dumper": "~3.0.0"
|
"symfony/var-dumper": "~3.0.0"
|
||||||
|
|
175
composer.lock
generated
175
composer.lock
generated
|
@ -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": "829ac07cae5bc43ef0ad3f5e5be618c5",
|
"hash": "6ef0d5dc0640824fef3033cba540c6fb",
|
||||||
"content-hash": "a7131399bb03f78ba0dcfd8ab7e98d59",
|
"content-hash": "dd3d8be96114267b553f77632c326e2c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "container-interop/container-interop",
|
"name": "container-interop/container-interop",
|
||||||
|
@ -48,6 +48,177 @@
|
||||||
],
|
],
|
||||||
"type": "library"
|
"type": "library"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "guzzlehttp/guzzle",
|
||||||
|
"version": "6.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/guzzle/guzzle.git",
|
||||||
|
"reference": "d094e337976dff9d8e2424e8485872194e768662"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
|
||||||
|
"reference": "d094e337976dff9d8e2424e8485872194e768662",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"guzzlehttp/promises": "~1.0",
|
||||||
|
"guzzlehttp/psr7": "~1.1",
|
||||||
|
"php": ">=5.5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"phpunit/phpunit": "~4.0",
|
||||||
|
"psr/log": "~1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "6.2-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Michael Dowling",
|
||||||
|
"email": "mtdowling@gmail.com",
|
||||||
|
"homepage": "https://github.com/mtdowling"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Guzzle is a PHP HTTP client library",
|
||||||
|
"homepage": "http://guzzlephp.org/",
|
||||||
|
"keywords": [
|
||||||
|
"client",
|
||||||
|
"curl",
|
||||||
|
"framework",
|
||||||
|
"http",
|
||||||
|
"http client",
|
||||||
|
"rest",
|
||||||
|
"web service"
|
||||||
|
],
|
||||||
|
"time": "2016-03-21 20:02:09"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "guzzlehttp/promises",
|
||||||
|
"version": "1.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/guzzle/promises.git",
|
||||||
|
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8",
|
||||||
|
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\Promise\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Michael Dowling",
|
||||||
|
"email": "mtdowling@gmail.com",
|
||||||
|
"homepage": "https://github.com/mtdowling"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Guzzle promises library",
|
||||||
|
"keywords": [
|
||||||
|
"promise"
|
||||||
|
],
|
||||||
|
"time": "2016-03-08 01:15:46"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "guzzlehttp/psr7",
|
||||||
|
"version": "1.2.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/guzzle/psr7.git",
|
||||||
|
"reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/guzzle/psr7/zipball/2e89629ff057ebb49492ba08e6995d3a6a80021b",
|
||||||
|
"reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0",
|
||||||
|
"psr/http-message": "~1.0"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/http-message-implementation": "1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\Psr7\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Michael Dowling",
|
||||||
|
"email": "mtdowling@gmail.com",
|
||||||
|
"homepage": "https://github.com/mtdowling"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PSR-7 message implementation",
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"message",
|
||||||
|
"stream",
|
||||||
|
"uri"
|
||||||
|
],
|
||||||
|
"time": "2016-02-18 21:54:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "jeremykendall/php-domain-parser",
|
"name": "jeremykendall/php-domain-parser",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
|
|
@ -103,11 +103,12 @@ class FrontController
|
||||||
public static function video($request, $response)
|
public static function video($request, $response)
|
||||||
{
|
{
|
||||||
global $container;
|
global $container;
|
||||||
|
$params = $request->getQueryParams();
|
||||||
$config = Config::getInstance();
|
$config = Config::getInstance();
|
||||||
if (isset($_GET["url"])) {
|
if (isset($params["url"])) {
|
||||||
if (isset($_GET['audio'])) {
|
if (isset($params['audio'])) {
|
||||||
try {
|
try {
|
||||||
$video = VideoDownload::getJSON($_GET["url"]);
|
$video = VideoDownload::getJSON($params["url"]);
|
||||||
|
|
||||||
//Vimeo needs a correct user-agent
|
//Vimeo needs a correct user-agent
|
||||||
$UA = VideoDownload::getUA();
|
$UA = VideoDownload::getUA();
|
||||||
|
@ -168,7 +169,7 @@ class FrontController
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$video = VideoDownload::getJSON($_GET["url"]);
|
$video = VideoDownload::getJSON($params["url"]);
|
||||||
$container->view->render(
|
$container->view->render(
|
||||||
$response,
|
$response,
|
||||||
'head.tpl',
|
'head.tpl',
|
||||||
|
@ -219,12 +220,22 @@ class FrontController
|
||||||
public static function redirect($request, $response)
|
public static function redirect($request, $response)
|
||||||
{
|
{
|
||||||
global $app;
|
global $app;
|
||||||
if (isset($_GET["url"])) {
|
$params = $request->getQueryParams();
|
||||||
|
if (isset($params["url"])) {
|
||||||
try {
|
try {
|
||||||
$video = VideoDownload::getURL($_GET["url"]);
|
$format = isset($params["format"]) ? $params["format"] : 'best';
|
||||||
return $response->withRedirect($video['url']);
|
$video = VideoDownload::getJSON($params["url"], $format);
|
||||||
|
$client = new \GuzzleHttp\Client();
|
||||||
|
$stream = $client->request('GET', $video->url, array('stream'=>true));
|
||||||
|
$response = $response->withHeader('Content-Disposition', 'inline; filename="'.$video->_filename.'"');
|
||||||
|
$response = $response->withHeader('Content-Type', $stream->getHeader('Content-Type'));
|
||||||
|
$response = $response->withHeader('Content-Length', $stream->getHeader('Content-Length'));
|
||||||
|
if ($request->isGet()) {
|
||||||
|
$response = $response->withBody($stream->getBody());
|
||||||
|
}
|
||||||
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
echo $e->getMessage().PHP_EOL;
|
$response->getBody()->write($e->getMessage().PHP_EOL);
|
||||||
return $response->withHeader('Content-Type', 'text/plain');
|
return $response->withHeader('Content-Type', 'text/plain');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,9 +252,10 @@ class FrontController
|
||||||
public static function json($request, $response)
|
public static function json($request, $response)
|
||||||
{
|
{
|
||||||
global $app;
|
global $app;
|
||||||
if (isset($_GET["url"])) {
|
$params = $request->getQueryParams();
|
||||||
|
if (isset($params["url"])) {
|
||||||
try {
|
try {
|
||||||
$video = VideoDownload::getJSON($_GET["url"]);
|
$video = VideoDownload::getJSON($params["url"]);
|
||||||
return $response->withJson($video);
|
return $response->withJson($video);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $response->withJson(
|
return $response->withJson(
|
||||||
|
|
|
@ -22,7 +22,7 @@ $container['view'] = function ($c) {
|
||||||
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
|
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
|
||||||
|
|
||||||
$view->addSlimPlugins($c['router'], $c['request']->getUri());
|
$view->addSlimPlugins($c['router'], $c['request']->getUri());
|
||||||
$view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
|
$view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
|
||||||
|
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
|
@ -43,7 +43,7 @@ $app->get(
|
||||||
$app->get(
|
$app->get(
|
||||||
'/redirect',
|
'/redirect',
|
||||||
array('Alltube\Controller\FrontController', 'redirect')
|
array('Alltube\Controller\FrontController', 'redirect')
|
||||||
);
|
)->setName('redirect');
|
||||||
$app->get(
|
$app->get(
|
||||||
'/json',
|
'/json',
|
||||||
array('Alltube\Controller\FrontController', 'json')
|
array('Alltube\Controller\FrontController', 'json')
|
||||||
|
|
|
@ -22,27 +22,24 @@
|
||||||
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" />
|
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" />
|
||||||
{/if}
|
{/if}
|
||||||
<br/>
|
<br/>
|
||||||
<input type="hidden" name="url"
|
|
||||||
value="{$video->webpage_url}" />
|
|
||||||
{if isset($video->formats)}
|
{if isset($video->formats)}
|
||||||
<h3>Available formats:</h3>
|
<h3><label for="format">Available formats:</label></h3>
|
||||||
<p>(You might have to do a <i>Right click > Save as</i>)</p>
|
<form action="{path_for name="redirect"}">
|
||||||
<ul id="format" class="format">
|
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
||||||
<li class="best" itemprop="encoding" itemscope
|
<select name="format" id="format">
|
||||||
itemtype="http://schema.org/VideoObject">
|
<option value="best">
|
||||||
<a download="{$video->_filename}" itemprop="contentUrl"
|
Best ({$video->ext})
|
||||||
href="{$video->url|escape}">
|
</option>
|
||||||
<b>Best</b> (<span itemprop="encodingFormat">{$video->ext}</span>)
|
<optgroup>
|
||||||
</a></li>
|
{foreach $video->formats as $format}
|
||||||
{foreach $video->formats as $format}
|
<option value="{$format->format_id}">
|
||||||
<li itemprop="encoding"
|
{$format->format} ({$format->ext})
|
||||||
itemscope itemtype="http://schema.org/VideoObject">
|
</option>
|
||||||
<a download="{$video->_filename|replace:$video->ext:$format->ext}" itemprop="contentUrl"
|
{/foreach}
|
||||||
href="{$format->url|escape}">
|
</optgroup>
|
||||||
<span itemprop="videoQuality">{$format->format}</span> (<span itemprop="encodingFormat">{$format->ext}</span>)
|
</select><br/><br/>
|
||||||
</a></li>
|
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
||||||
{/foreach}
|
</form>
|
||||||
</ul><br/><br/>
|
|
||||||
{else}
|
{else}
|
||||||
<input type="hidden" name="format" value="best" />
|
<input type="hidden" name="format" value="best" />
|
||||||
<a class="downloadBtn"
|
<a class="downloadBtn"
|
||||||
|
|
Loading…
Reference in a new issue