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
|
||||
Addtype font/truetype .ttf
|
||||
<ifmodule mod_expires.c>
|
||||
AddType application/x-web-app-manifest+json .webapp
|
||||
Addtype font/truetype .ttf
|
||||
</ifmodule>
|
||||
|
||||
<ifmodule mod_expires.c>
|
||||
ExpiresActive On
|
||||
|
@ -21,7 +23,6 @@ RewriteRule ^(.*)$ https://www.alltubedownload.net/$1 [R=301,L]
|
|||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
|
||||
Redirect permanent /api.php /video
|
||||
Redirect permanent /extractors.php /extractors
|
||||
|
||||
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
|
||||
<ifmodule mod_filter.c>
|
||||
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
|
||||
</ifmodule>
|
||||
|
|
|
@ -75,6 +75,13 @@ class Config
|
|||
*/
|
||||
public $curl_params = [];
|
||||
|
||||
/**
|
||||
* Disable URL rewriting.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $uglyUrls = false;
|
||||
|
||||
/**
|
||||
* 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",
|
||||
"phpunit/phpunit": "~5.7.2",
|
||||
"ffmpeg/ffmpeg": "dev-release",
|
||||
"rg3/youtube-dl": "~2016.12.22",
|
||||
"rg3/youtube-dl": "~2017.01.10",
|
||||
"rudloff/rtmpdump-bin": "~2.3",
|
||||
"heroku/heroku-buildpack-php": "*"
|
||||
},
|
||||
|
@ -35,10 +35,10 @@
|
|||
"type": "package",
|
||||
"package": {
|
||||
"name": "rg3/youtube-dl",
|
||||
"version": "2016.12.22",
|
||||
"version": "2017.01.10",
|
||||
"dist": {
|
||||
"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",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "91e14c843bc92c4d5af1ec7abcddf15a",
|
||||
"content-hash": "16268cc5135ed42aedf75446f4e39bd7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aura/session",
|
||||
|
@ -1466,10 +1466,10 @@
|
|||
},
|
||||
{
|
||||
"name": "rg3/youtube-dl",
|
||||
"version": "2016.12.22",
|
||||
"version": "2017.01.10",
|
||||
"dist": {
|
||||
"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,
|
||||
"shasum": null
|
||||
},
|
||||
|
|
|
@ -11,3 +11,4 @@ convert: false
|
|||
avconv: vendor/bin/ffmpeg
|
||||
rtmpdump: vendor/bin/rtmpdump
|
||||
curl: /usr/bin/curl
|
||||
uglyUrls: false
|
||||
|
|
|
@ -84,9 +84,10 @@ class FrontController
|
|||
$response,
|
||||
'index.tpl',
|
||||
[
|
||||
'convert' => $this->config->convert,
|
||||
'class' => 'index',
|
||||
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
|
||||
'convert' => $this->config->convert,
|
||||
'uglyUrls' => $this->config->uglyUrls,
|
||||
'class' => 'index',
|
||||
'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/vendor/autoload.php';
|
||||
use Alltube\Config;
|
||||
use Alltube\Controller\FrontController;
|
||||
use Alltube\UglyRouter;
|
||||
|
||||
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
|
||||
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();
|
||||
$container = $app->getContainer();
|
||||
$config = Config::getInstance();
|
||||
if ($config->uglyUrls) {
|
||||
$container['router'] = new UglyRouter();
|
||||
}
|
||||
$container['view'] = function ($c) {
|
||||
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "alltube",
|
||||
"description": "HTML GUI for youtube-dl",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2-beta",
|
||||
"author": "Pierre Rudloff",
|
||||
"bugs": "https://github.com/Rudloff/alltube/issues",
|
||||
"dependencies": {
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<input class="URLinput" type="url" name="url" id="url"
|
||||
required autofocus placeholder="http://example.com/video" />
|
||||
</span>
|
||||
{if uglyUrls}
|
||||
<input type="hidden" name="page" value="video" />
|
||||
{/if}
|
||||
<input class="downloadBtn" type="submit" value="Download" /><br/>
|
||||
{if $convert}
|
||||
<div class="mp3">
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
<h3><label for="format">Available formats:</label></h3>
|
||||
<form action="{path_for name="redirect"}">
|
||||
<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">
|
||||
<optgroup label="Generic formats">
|
||||
<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