Merge branch 'develop' into feature/stream
Conflicts: composer.lock
This commit is contained in:
commit
8e6c33c260
14 changed files with 288 additions and 64 deletions
|
@ -1,5 +1,7 @@
|
||||||
|
<ifmodule mod_expires.c>
|
||||||
AddType application/x-web-app-manifest+json .webapp
|
AddType application/x-web-app-manifest+json .webapp
|
||||||
Addtype font/truetype .ttf
|
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
|
AddOutputFilterByType DEFLATE text/css text/html application/javascript font/truetype
|
||||||
|
</ifmodule>
|
||||||
|
|
25
FAQ.md
25
FAQ.md
|
@ -12,15 +12,15 @@ You can ususally download the video by doing *File > Save to* or *ctrl + S*.
|
||||||
You need to create a YAML file called `config.yml` at the root of your project.
|
You need to create a YAML file called `config.yml` at the root of your project.
|
||||||
Here are the parameters that you can set:
|
Here are the parameters that you can set:
|
||||||
|
|
||||||
* youtubedl: path to your youtube-dl binary
|
* `youtubedl`: path to your youtube-dl binary
|
||||||
* python: path to your python binary
|
* `python`: path to your python binary
|
||||||
* params: an array of parameters to pass to youtube-dl
|
* `params`: an array of parameters to pass to youtube-dl
|
||||||
* curl_params: an array of parameters to pass to curl
|
* `curl_params`: an array of parameters to pass to curl
|
||||||
* convert: true to enable audio conversion
|
* `convert`: true to enable audio conversion
|
||||||
* avconv: path to your avconv or ffmpeg binary
|
* `avconv`: path to your avconv or ffmpeg binary
|
||||||
* rtmpdump: path to your rtmpdump binary
|
* `rtmpdump`: path to your rtmpdump binary
|
||||||
|
|
||||||
See [config.example.yml](config.example.yml) for default values.
|
See [`config.example.yml`](config.example.yml) for default values.
|
||||||
|
|
||||||
## How do I enable audio conversion?
|
## How do I enable audio conversion?
|
||||||
|
|
||||||
|
@ -71,3 +71,12 @@ You need to either:
|
||||||
|
|
||||||
* Use a [release package](https://github.com/Rudloff/alltube/releases)
|
* Use a [release package](https://github.com/Rudloff/alltube/releases)
|
||||||
* Run `npm install` (see detailed instructions in the [README](README.md#from-git))
|
* Run `npm install` (see detailed instructions in the [README](README.md#from-git))
|
||||||
|
|
||||||
|
## I get a 404 error on every page except the index
|
||||||
|
|
||||||
|
This is probably because your server does not have mod_rewrite or AllowOverride is disabled.
|
||||||
|
You can work around this by adding this to your `config.yml` file:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uglyUrls: true
|
||||||
|
```
|
||||||
|
|
|
@ -80,6 +80,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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,8 +21,9 @@
|
||||||
"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.14",
|
||||||
"rudloff/rtmpdump-bin": "~2.3"
|
"rudloff/rtmpdump-bin": "~2.3",
|
||||||
|
"heroku/heroku-buildpack-php": "*"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"paas": {
|
"paas": {
|
||||||
|
@ -36,10 +37,10 @@
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"package": {
|
"package": {
|
||||||
"name": "rg3/youtube-dl",
|
"name": "rg3/youtube-dl",
|
||||||
"version": "2016.12.22",
|
"version": "2017.01.14",
|
||||||
"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.14.zip"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
80
composer.lock
generated
80
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": "73c835f77628ac1e77dee70447711759",
|
"content-hash": "44b24b403652e1a7e450280e4643e37e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "aura/session",
|
"name": "aura/session",
|
||||||
|
@ -811,16 +811,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/process",
|
"name": "symfony/process",
|
||||||
"version": "v3.2.1",
|
"version": "v3.2.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/process.git",
|
"url": "https://github.com/symfony/process.git",
|
||||||
"reference": "02ea84847aad71be7e32056408bb19f3a616cdd3"
|
"reference": "350e810019fc52dd06ae844b6a6d382f8a0e8893"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/process/zipball/02ea84847aad71be7e32056408bb19f3a616cdd3",
|
"url": "https://api.github.com/repos/symfony/process/zipball/350e810019fc52dd06ae844b6a6d382f8a0e8893",
|
||||||
"reference": "02ea84847aad71be7e32056408bb19f3a616cdd3",
|
"reference": "350e810019fc52dd06ae844b6a6d382f8a0e8893",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -856,20 +856,20 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Process Component",
|
"description": "Symfony Process Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2016-11-24T10:40:28+00:00"
|
"time": "2017-01-02T20:32:22+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/yaml",
|
"name": "symfony/yaml",
|
||||||
"version": "v3.2.1",
|
"version": "v3.2.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/yaml.git",
|
"url": "https://github.com/symfony/yaml.git",
|
||||||
"reference": "a7095af4b97a0955f85c8989106c249fa649011f"
|
"reference": "50eadbd7926e31842893c957eca362b21592a97d"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/a7095af4b97a0955f85c8989106c249fa649011f",
|
"url": "https://api.github.com/repos/symfony/yaml/zipball/50eadbd7926e31842893c957eca362b21592a97d",
|
||||||
"reference": "a7095af4b97a0955f85c8989106c249fa649011f",
|
"reference": "50eadbd7926e31842893c957eca362b21592a97d",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -911,7 +911,7 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Yaml Component",
|
"description": "Symfony Yaml Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2016-12-10T10:07:06+00:00"
|
"time": "2017-01-03T13:51:32+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
@ -983,6 +983,50 @@
|
||||||
],
|
],
|
||||||
"type": "library"
|
"type": "library"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "heroku/heroku-buildpack-php",
|
||||||
|
"version": "v117",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/heroku/heroku-buildpack-php.git",
|
||||||
|
"reference": "960199a978308c75926fd9bb4775f7113bf1d777"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/heroku/heroku-buildpack-php/zipball/960199a978308c75926fd9bb4775f7113bf1d777",
|
||||||
|
"reference": "960199a978308c75926fd9bb4775f7113bf1d777",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/heroku-hhvm-apache2",
|
||||||
|
"bin/heroku-hhvm-nginx",
|
||||||
|
"bin/heroku-php-apache2",
|
||||||
|
"bin/heroku-php-nginx"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "David Zuelke",
|
||||||
|
"email": "dz@heroku.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP/HHVM and Apache2/Nginx as on Heroku",
|
||||||
|
"homepage": "https://github.com/heroku/heroku-buildpack-php",
|
||||||
|
"keywords": [
|
||||||
|
"apache",
|
||||||
|
"apache2",
|
||||||
|
"foreman",
|
||||||
|
"heroku",
|
||||||
|
"hhvm",
|
||||||
|
"nginx",
|
||||||
|
"php"
|
||||||
|
],
|
||||||
|
"time": "2016-12-09T19:37:38+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "myclabs/deep-copy",
|
"name": "myclabs/deep-copy",
|
||||||
"version": "1.5.5",
|
"version": "1.5.5",
|
||||||
|
@ -1621,10 +1665,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "rg3/youtube-dl",
|
"name": "rg3/youtube-dl",
|
||||||
"version": "2016.12.22",
|
"version": "2017.01.14",
|
||||||
"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.14.zip",
|
||||||
"reference": null,
|
"reference": null,
|
||||||
"shasum": null
|
"shasum": null
|
||||||
},
|
},
|
||||||
|
@ -2282,16 +2326,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/var-dumper",
|
"name": "symfony/var-dumper",
|
||||||
"version": "v3.2.1",
|
"version": "v3.2.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/var-dumper.git",
|
"url": "https://github.com/symfony/var-dumper.git",
|
||||||
"reference": "f722532b0966e9b6fc631e682143c07b2cf583a0"
|
"reference": "b54b23f9a19b465e76fdaac0f6732410467c83b2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/f722532b0966e9b6fc631e682143c07b2cf583a0",
|
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/b54b23f9a19b465e76fdaac0f6732410467c83b2",
|
||||||
"reference": "f722532b0966e9b6fc631e682143c07b2cf583a0",
|
"reference": "b54b23f9a19b465e76fdaac0f6732410467c83b2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2341,7 +2385,7 @@
|
||||||
"debug",
|
"debug",
|
||||||
"dump"
|
"dump"
|
||||||
],
|
],
|
||||||
"time": "2016-12-11T14:34:22+00:00"
|
"time": "2017-01-03T08:53:57+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webmozart/assert",
|
"name": "webmozart/assert",
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -80,13 +80,16 @@ class FrontController
|
||||||
*/
|
*/
|
||||||
public function index(Request $request, Response $response)
|
public function index(Request $request, Response $response)
|
||||||
{
|
{
|
||||||
|
$uri = $request->getUri();
|
||||||
$this->view->render(
|
$this->view->render(
|
||||||
$response,
|
$response,
|
||||||
'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.',
|
||||||
|
'domain' => $uri->getScheme().'://'.$uri->getAuthority(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.0",
|
"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">
|
||||||
|
@ -25,7 +28,7 @@
|
||||||
<a class="combatiblelink" href="{path_for name="extractors"}">See all supported websites</a>
|
<a class="combatiblelink" href="{path_for name="extractors"}">See all supported websites</a>
|
||||||
<div id="bookmarklet" class="bookmarklet_wrapper">
|
<div id="bookmarklet" class="bookmarklet_wrapper">
|
||||||
<p> Drag this to your bookmarks bar: </p>
|
<p> Drag this to your bookmarks bar: </p>
|
||||||
<a class="bookmarklet" href="javascript:window.location='{base_url|noscheme}{path_for name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
|
<a class="bookmarklet" href="javascript:window.location='{$domain}{path_for name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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">
|
<option value="best">
|
||||||
|
|
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', [], [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -79,12 +79,13 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
* @param string $url URL
|
* @param string $url URL
|
||||||
* @param string $format Format
|
* @param string $format Format
|
||||||
* @param string $filename Filename
|
* @param string $filename Filename
|
||||||
|
* @param string $extension File extension
|
||||||
* @param string $domain Domain
|
* @param string $domain Domain
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @dataProvider urlProvider
|
* @dataProvider urlProvider
|
||||||
*/
|
*/
|
||||||
public function testGetURL($url, $format, $filename, $domain)
|
public function testGetURL($url, $format, $filename, $extension, $domain)
|
||||||
{
|
{
|
||||||
$videoURL = $this->download->getURL($url, $format);
|
$videoURL = $this->download->getURL($url, $format);
|
||||||
$this->assertContains($domain, $videoURL);
|
$this->assertContains($domain, $videoURL);
|
||||||
|
@ -146,35 +147,34 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'https://www.youtube.com/watch?v=M7IpKCZ47pU', null,
|
'https://www.youtube.com/watch?v=M7IpKCZ47pU', null,
|
||||||
"It's Not Me, It's You - Hearts Under Fire-M7IpKCZ47pU.mp4",
|
"It's Not Me, It's You - Hearts Under Fire-M7IpKCZ47pU",
|
||||||
|
'mp4',
|
||||||
'googlevideo.com',
|
'googlevideo.com',
|
||||||
"It's Not Me, It's You - Hearts Under Fire-M7IpKCZ47pU.mp3",
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 22,
|
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 22,
|
||||||
"'Heart Attack' - Demi Lovato ".
|
"'Heart Attack' - Demi Lovato ".
|
||||||
'(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp4',
|
'(Sam Tsui & Against The Current)-RJJ6FCAXvKg',
|
||||||
|
'mp4',
|
||||||
'googlevideo.com',
|
'googlevideo.com',
|
||||||
"'Heart Attack' - Demi Lovato ".
|
|
||||||
'(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp3',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'https://vimeo.com/24195442', null,
|
'https://vimeo.com/24195442', null,
|
||||||
'Carving the Mountains-24195442.mp4',
|
'Carving the Mountains-24195442',
|
||||||
|
'mp4',
|
||||||
'vimeocdn.com',
|
'vimeocdn.com',
|
||||||
'Carving the Mountains-24195442.mp3',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'http://www.bbc.co.uk/programmes/b039g8p7', 'bestaudio/best',
|
'http://www.bbc.co.uk/programmes/b039g8p7', 'bestaudio/best',
|
||||||
'Leonard Cohen, Kaleidoscope - BBC Radio 4-b039d07m.flv',
|
'Leonard Cohen, Kaleidoscope - BBC Radio 4-b039d07m',
|
||||||
|
'flv',
|
||||||
'bbcodspdns.fcod.llnwd.net',
|
'bbcodspdns.fcod.llnwd.net',
|
||||||
'Leonard Cohen, Kaleidoscope - BBC Radio 4-b039d07m.mp3',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0', 'bestaudio/best',
|
'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0', 'bestaudio/best',
|
||||||
'GRIP sucht den Sommerkönig-folge-203-0.f4v',
|
'GRIP sucht den Sommerkönig-folge-203-0',
|
||||||
|
'f4v',
|
||||||
'edgefcs.net',
|
'edgefcs.net',
|
||||||
'GRIP sucht den Sommerkönig-folge-203-0.mp3',
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -249,15 +249,16 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
* @param string $url URL
|
* @param string $url URL
|
||||||
* @param string $format Format
|
* @param string $format Format
|
||||||
* @param string $filename Filename
|
* @param string $filename Filename
|
||||||
|
* @param string $extension File extension
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @dataProvider urlProvider
|
* @dataProvider urlProvider
|
||||||
* @dataProvider M3uUrlProvider
|
* @dataProvider M3uUrlProvider
|
||||||
*/
|
*/
|
||||||
public function testGetFilename($url, $format, $filename)
|
public function testGetFilename($url, $format, $filename, $extension)
|
||||||
{
|
{
|
||||||
$videoFilename = $this->download->getFilename($url, $format);
|
$videoFilename = $this->download->getFilename($url, $format);
|
||||||
$this->assertEquals($videoFilename, $filename);
|
$this->assertEquals($videoFilename, $filename.'.'.$extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,10 +288,10 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
* @dataProvider urlProvider
|
* @dataProvider urlProvider
|
||||||
* @dataProvider M3uUrlProvider
|
* @dataProvider M3uUrlProvider
|
||||||
*/
|
*/
|
||||||
public function testGetAudioFilename($url, $format, $filename, $domain, $audioFilename)
|
public function testGetAudioFilename($url, $format, $filename)
|
||||||
{
|
{
|
||||||
$videoFilename = $this->download->getAudioFilename($url, $format);
|
$videoFilename = $this->download->getAudioFilename($url, $format);
|
||||||
$this->assertEquals($videoFilename, $audioFilename);
|
$this->assertEquals($videoFilename, $filename.'.mp3');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue