Merge branch 'release-0.7.2-beta'
This commit is contained in:
commit
c8e8cacfef
12 changed files with 183 additions and 16 deletions
13
.htaccess
13
.htaccess
|
@ -1,5 +1,7 @@
|
||||||
AddType application/x-web-app-manifest+json .webapp
|
<ifmodule mod_expires.c>
|
||||||
Addtype font/truetype .ttf
|
AddType application/x-web-app-manifest+json .webapp
|
||||||
|
Addtype font/truetype .ttf
|
||||||
|
</ifmodule>
|
||||||
|
|
||||||
<ifmodule mod_expires.c>
|
<ifmodule mod_expires.c>
|
||||||
ExpiresActive On
|
ExpiresActive On
|
||||||
|
@ -21,7 +23,6 @@ RewriteRule ^(.*)$ https://www.alltubedownload.net/$1 [R=301,L]
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^ index.php [QSA,L]
|
RewriteRule ^ index.php [QSA,L]
|
||||||
|
|
||||||
Redirect permanent /api.php /video
|
<ifmodule mod_filter.c>
|
||||||
Redirect permanent /extractors.php /extractors
|
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
|
||||||
|
</ifmodule>
|
||||||
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
|
|
||||||
|
|
|
@ -75,6 +75,13 @@ class Config
|
||||||
*/
|
*/
|
||||||
public $curl_params = [];
|
public $curl_params = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable URL rewriting.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $uglyUrls = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* YAML config file path.
|
* YAML config file path.
|
||||||
*
|
*
|
||||||
|
|
61
classes/UglyRouter.php
Normal file
61
classes/UglyRouter.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* UglyRouter class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alltube;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Slim\Router;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend Slim's router class in order to disable URL rewriting.
|
||||||
|
*/
|
||||||
|
class UglyRouter extends Router
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Dispatch router for HTTP request.
|
||||||
|
*
|
||||||
|
* @param ServerRequestInterface $request The current HTTP request object
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
|
||||||
|
*/
|
||||||
|
public function dispatch(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
parse_str($request->getUri()->getQuery(), $args);
|
||||||
|
$uri = '/';
|
||||||
|
if (isset($args['page'])) {
|
||||||
|
$uri .= $args['page'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->createDispatcher()->dispatch(
|
||||||
|
$request->getMethod(),
|
||||||
|
$uri
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the path for a named route including the base path.
|
||||||
|
*
|
||||||
|
* @param string $name Route name
|
||||||
|
* @param array $data Named argument replacement data
|
||||||
|
* @param array $queryParams Optional query string parameters
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException If named route does not exist
|
||||||
|
* @throws \InvalidArgumentException If required data not provided
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function pathFor($name, array $data = [], array $queryParams = [])
|
||||||
|
{
|
||||||
|
$url = str_replace('/', '/?page=', $this->relativePathFor($name, $data, $queryParams));
|
||||||
|
|
||||||
|
if ($this->basePath) {
|
||||||
|
$url = $this->basePath.$url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
"squizlabs/php_codesniffer": "~2.7.0",
|
"squizlabs/php_codesniffer": "~2.7.0",
|
||||||
"phpunit/phpunit": "~5.7.2",
|
"phpunit/phpunit": "~5.7.2",
|
||||||
"ffmpeg/ffmpeg": "dev-release",
|
"ffmpeg/ffmpeg": "dev-release",
|
||||||
"rg3/youtube-dl": "~2016.12.22",
|
"rg3/youtube-dl": "~2017.01.10",
|
||||||
"rudloff/rtmpdump-bin": "~2.3",
|
"rudloff/rtmpdump-bin": "~2.3",
|
||||||
"heroku/heroku-buildpack-php": "*"
|
"heroku/heroku-buildpack-php": "*"
|
||||||
},
|
},
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"package": {
|
"package": {
|
||||||
"name": "rg3/youtube-dl",
|
"name": "rg3/youtube-dl",
|
||||||
"version": "2016.12.22",
|
"version": "2017.01.10",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://github.com/rg3/youtube-dl/archive/2016.12.22.zip"
|
"url": "https://github.com/rg3/youtube-dl/archive/2017.01.10.zip"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
6
composer.lock
generated
6
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"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"
|
||||||
],
|
],
|
||||||
"content-hash": "91e14c843bc92c4d5af1ec7abcddf15a",
|
"content-hash": "16268cc5135ed42aedf75446f4e39bd7",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "aura/session",
|
"name": "aura/session",
|
||||||
|
@ -1466,10 +1466,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rg3/youtube-dl",
|
"name": "rg3/youtube-dl",
|
||||||
"version": "2016.12.22",
|
"version": "2017.01.10",
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://github.com/rg3/youtube-dl/archive/2016.12.22.zip",
|
"url": "https://github.com/rg3/youtube-dl/archive/2017.01.10.zip",
|
||||||
"reference": null,
|
"reference": null,
|
||||||
"shasum": null
|
"shasum": null
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,3 +11,4 @@ convert: false
|
||||||
avconv: vendor/bin/ffmpeg
|
avconv: vendor/bin/ffmpeg
|
||||||
rtmpdump: vendor/bin/rtmpdump
|
rtmpdump: vendor/bin/rtmpdump
|
||||||
curl: /usr/bin/curl
|
curl: /usr/bin/curl
|
||||||
|
uglyUrls: false
|
||||||
|
|
|
@ -85,6 +85,7 @@ class FrontController
|
||||||
'index.tpl',
|
'index.tpl',
|
||||||
[
|
[
|
||||||
'convert' => $this->config->convert,
|
'convert' => $this->config->convert,
|
||||||
|
'uglyUrls' => $this->config->uglyUrls,
|
||||||
'class' => 'index',
|
'class' => 'index',
|
||||||
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
|
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__.'/vendor/autoload.php';
|
require_once __DIR__.'/vendor/autoload.php';
|
||||||
|
use Alltube\Config;
|
||||||
use Alltube\Controller\FrontController;
|
use Alltube\Controller\FrontController;
|
||||||
|
use Alltube\UglyRouter;
|
||||||
|
|
||||||
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
|
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
|
||||||
header('Location: '.str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
|
header('Location: '.str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
|
||||||
|
@ -10,6 +12,10 @@ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.ph
|
||||||
|
|
||||||
$app = new \Slim\App();
|
$app = new \Slim\App();
|
||||||
$container = $app->getContainer();
|
$container = $app->getContainer();
|
||||||
|
$config = Config::getInstance();
|
||||||
|
if ($config->uglyUrls) {
|
||||||
|
$container['router'] = new UglyRouter();
|
||||||
|
}
|
||||||
$container['view'] = function ($c) {
|
$container['view'] = function ($c) {
|
||||||
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
|
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "alltube",
|
"name": "alltube",
|
||||||
"description": "HTML GUI for youtube-dl",
|
"description": "HTML GUI for youtube-dl",
|
||||||
"version": "0.7.1",
|
"version": "0.7.2-beta",
|
||||||
"author": "Pierre Rudloff",
|
"author": "Pierre Rudloff",
|
||||||
"bugs": "https://github.com/Rudloff/alltube/issues",
|
"bugs": "https://github.com/Rudloff/alltube/issues",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
<input class="URLinput" type="url" name="url" id="url"
|
<input class="URLinput" type="url" name="url" id="url"
|
||||||
required autofocus placeholder="http://example.com/video" />
|
required autofocus placeholder="http://example.com/video" />
|
||||||
</span>
|
</span>
|
||||||
|
{if uglyUrls}
|
||||||
|
<input type="hidden" name="page" value="video" />
|
||||||
|
{/if}
|
||||||
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
||||||
{if $convert}
|
{if $convert}
|
||||||
<div class="mp3">
|
<div class="mp3">
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
<h3><label for="format">Available formats:</label></h3>
|
<h3><label for="format">Available formats:</label></h3>
|
||||||
<form action="{path_for name="redirect"}">
|
<form action="{path_for name="redirect"}">
|
||||||
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
<input type="hidden" name="url" value="{$video->webpage_url}" />
|
||||||
|
{if uglyUrls}
|
||||||
|
<input type="hidden" name="page" value="redirect" />
|
||||||
|
{/if}
|
||||||
<select name="format" id="format" class="formats monospace">
|
<select name="format" id="format" class="formats monospace">
|
||||||
<optgroup label="Generic formats">
|
<optgroup label="Generic formats">
|
||||||
<option value="best[protocol^=http]">
|
<option value="best[protocol^=http]">
|
||||||
|
|
84
tests/UglyRouterTest.php
Normal file
84
tests/UglyRouterTest.php
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* UglyRouterTest class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alltube\Test;
|
||||||
|
|
||||||
|
use Alltube\UglyRouter;
|
||||||
|
use Slim\Http\Environment;
|
||||||
|
use Slim\Http\Headers;
|
||||||
|
use Slim\Http\Request;
|
||||||
|
use Slim\Http\Stream;
|
||||||
|
use Slim\Http\Uri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for the UglyRouter class.
|
||||||
|
*/
|
||||||
|
class UglyRouterTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* UglyRouter instance.
|
||||||
|
*
|
||||||
|
* @var UglyRouter
|
||||||
|
*/
|
||||||
|
private $router;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare tests.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->router = new UglyRouter();
|
||||||
|
$this->router->map(['GET'], '/foo', 'print')->setName('foo');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the dispatch() function.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDispatch()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
[1, 'route0', []],
|
||||||
|
$this->router->dispatch(
|
||||||
|
new Request(
|
||||||
|
'GET',
|
||||||
|
Uri::createFromString('http://example.com/?page=foo'),
|
||||||
|
Headers::createFromEnvironment(new Environment()),
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
new Stream(fopen('php://temp', 'r'))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the pathFor() function.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testPathFor()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
'/?page=foo',
|
||||||
|
$this->router->pathFor('foo', [], [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the pathFor() function with a base path.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testPathForWithBasePath()
|
||||||
|
{
|
||||||
|
$this->router->setBasePath('/bar');
|
||||||
|
$this->assertEquals(
|
||||||
|
'/bar/?page=foo',
|
||||||
|
$this->router->pathFor('foo', [], [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue