Merge branch 'develop' into feature/stream

Conflicts:
	composer.json
	composer.lock
	controllers/FrontController.php
This commit is contained in:
Pierre Rudloff 2016-07-27 02:31:47 +02:00
commit aba3d0c9f5
17 changed files with 283 additions and 255 deletions

View file

@ -41,7 +41,9 @@ module.exports = function (grunt) {
}, },
tests: { tests: {
src: ['tests/*.php'] src: ['tests/*.php']
}
}, },
jslint: {
js: { js: {
src: ['js/*.js'] src: ['js/*.js']
}, },
@ -72,9 +74,10 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-phpcs'); grunt.loadNpmTasks('grunt-phpcs');
grunt.loadNpmTasks('grunt-phpunit'); grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-contrib-compress'); grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-jslint');
grunt.registerTask('default', ['uglify', 'cssmin']); grunt.registerTask('default', ['uglify', 'cssmin']);
grunt.registerTask('lint', ['phpcs']); grunt.registerTask('lint', ['phpcs', 'jslint']);
grunt.registerTask('test', ['phpunit']); grunt.registerTask('test', ['phpunit']);
grunt.registerTask('release', ['default', 'githash', 'compress']); grunt.registerTask('release', ['default', 'githash', 'compress']);
}; };

View file

@ -6,6 +6,13 @@ HTML GUI for youtube-dl (http://alltubedownload.net/)
![Screenshot](img/screenshot.png "Alltube GUI screenshot") ![Screenshot](img/screenshot.png "Alltube GUI screenshot")
##Setup ##Setup
### From a release package
You can download the latest release package [here](https://github.com/Rudloff/alltube/releases).
You just have to unzip it on your server and it should be ready to use.
### From Git
In order to get AllTube working, you need to use [npm](https://www.npmjs.com/) and [Composer](https://getcomposer.org/): In order to get AllTube working, you need to use [npm](https://www.npmjs.com/) and [Composer](https://getcomposer.org/):
npm install npm install
@ -89,11 +96,11 @@ This software is available under the [GNU General Public License](http://www.gnu
__Please use a different name and logo if you run it on a public server.__ __Please use a different name and logo if you run it on a public server.__
##Other dependencies ##Other dependencies
You need [avconv](https://libav.org/avconv.html) and [rtmpdump](http://rtmpdump.mplayerhq.hu/) in order to enable conversions. You need [avconv](https://libav.org/avconv.html), [rtmpdump](http://rtmpdump.mplayerhq.hu/) and [curl](https://curl.haxx.se/) in order to enable conversions.
If you don't want to enable conversions, you can disable it in *config.yml*. If you don't want to enable conversions, you can disable it in *config.yml*.
On Debian-based systems: On Debian-based systems:
sudo apt-get install libav-tools rtmpdump sudo apt-get install libav-tools rtmpdump curl
You also probably need to edit the *avconv* variable in *config.yml* so that it points to your ffmpeg/avconv binary (*/usr/bin/avconv* on Debian/Ubuntu). You also probably need to edit the *avconv* variable in *config.yml* so that it points to your ffmpeg/avconv binary (*/usr/bin/avconv* on Debian/Ubuntu).

View file

@ -6,11 +6,11 @@
"type": "project", "type": "project",
"require": { "require": {
"smarty/smarty": "~3.1.29", "smarty/smarty": "~3.1.29",
"rg3/youtube-dl": "2016.04.13", "rg3/youtube-dl": "~2016.07.26",
"slim/slim": "3.x-dev", "slim/slim": "~3.5.0",
"mathmarques/smarty-view": "~1.1.0", "mathmarques/smarty-view": "~1.1.0",
"symfony/yaml": "~3.0.0", "symfony/yaml": "~3.1.0",
"symfony/process": "~3.0.0", "symfony/process": "~3.1.0",
"ptachoire/process-builder-chain": "~1.2.0", "ptachoire/process-builder-chain": "~1.2.0",
"ffmpeg/ffmpeg": "dev-release", "ffmpeg/ffmpeg": "dev-release",
"rudloff/smarty-plugin-noscheme": "~0.1.0", "rudloff/smarty-plugin-noscheme": "~0.1.0",
@ -19,7 +19,7 @@
"rudloff/psr7-process-stream": "~0.1.0" "rudloff/psr7-process-stream": "~0.1.0"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "~3.0.0" "symfony/var-dumper": "~3.1.0"
}, },
"extra": { "extra": {
"paas": { "paas": {
@ -32,11 +32,11 @@
"type": "package", "type": "package",
"package": { "package": {
"name": "rg3/youtube-dl", "name": "rg3/youtube-dl",
"version": "2016.04.13", "version": "2016.07.26",
"source": { "source": {
"url": "https://github.com/rg3/youtube-dl.git", "url": "https://github.com/rg3/youtube-dl.git",
"type": "git", "type": "git",
"reference": "9e285387260a019d7471c3bdbd52cc764c0e8700" "reference": "2016.07.26"
} }
} }
}, { }, {

124
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", "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": "962f54d3ada96f7d3289479b13812c1a", "hash": "19bf8d61960475e79792cb0718198f21",
"content-hash": "2dea64564c520577cb275f73d046ed75", "content-hash": "de1c44fd5ca25ea1b71d0252d3b68cd7",
"packages": [ "packages": [
{ {
"name": "container-interop/container-interop", "name": "container-interop/container-interop",
@ -50,27 +50,27 @@
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
"version": "6.2.0", "version": "6.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/guzzle/guzzle.git", "url": "https://github.com/guzzle/guzzle.git",
"reference": "d094e337976dff9d8e2424e8485872194e768662" "reference": "3f808fba627f2c5b69e2501217bf31af349c1427"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427",
"reference": "d094e337976dff9d8e2424e8485872194e768662", "reference": "3f808fba627f2c5b69e2501217bf31af349c1427",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"guzzlehttp/promises": "~1.0", "guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "~1.1", "guzzlehttp/psr7": "^1.3.1",
"php": ">=5.5.0" "php": ">=5.5"
}, },
"require-dev": { "require-dev": {
"ext-curl": "*", "ext-curl": "*",
"phpunit/phpunit": "~4.0", "phpunit/phpunit": "^4.0",
"psr/log": "~1.0" "psr/log": "^1.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -108,20 +108,20 @@
"rest", "rest",
"web service" "web service"
], ],
"time": "2016-03-21 20:02:09" "time": "2016-07-15 17:22:37"
}, },
{ {
"name": "guzzlehttp/promises", "name": "guzzlehttp/promises",
"version": "1.1.0", "version": "1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/guzzle/promises.git", "url": "https://github.com/guzzle/promises.git",
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8" "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8", "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8", "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -159,20 +159,20 @@
"keywords": [ "keywords": [
"promise" "promise"
], ],
"time": "2016-03-08 01:15:46" "time": "2016-05-18 16:56:05"
}, },
{ {
"name": "guzzlehttp/psr7", "name": "guzzlehttp/psr7",
"version": "1.3.0", "version": "1.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/guzzle/psr7.git", "url": "https://github.com/guzzle/psr7.git",
"reference": "31382fef2889136415751badebbd1cb022a4ed72" "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72", "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"reference": "31382fef2889136415751badebbd1cb022a4ed72", "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -188,7 +188,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0-dev" "dev-master": "1.4-dev"
} }
}, },
"autoload": { "autoload": {
@ -217,7 +217,7 @@
"stream", "stream",
"uri" "uri"
], ],
"time": "2016-04-13 19:56:01" "time": "2016-06-24 23:00:38"
}, },
{ {
"name": "jeremykendall/php-domain-parser", "name": "jeremykendall/php-domain-parser",
@ -397,16 +397,16 @@
}, },
{ {
"name": "nikic/fast-route", "name": "nikic/fast-route",
"version": "v0.6.0", "version": "v1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/FastRoute.git", "url": "https://github.com/nikic/FastRoute.git",
"reference": "31fa86924556b80735f98b294a7ffdfb26789f22" "reference": "8ea928195fa9b907f0d6e48312d323c1a13cc2af"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22", "url": "https://api.github.com/repos/nikic/FastRoute/zipball/8ea928195fa9b907f0d6e48312d323c1a13cc2af",
"reference": "31fa86924556b80735f98b294a7ffdfb26789f22", "reference": "8ea928195fa9b907f0d6e48312d323c1a13cc2af",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -436,7 +436,7 @@
"router", "router",
"routing" "routing"
], ],
"time": "2015-06-18 19:15:47" "time": "2016-06-12 19:08:51"
}, },
{ {
"name": "pimple/pimple", "name": "pimple/pimple",
@ -571,11 +571,11 @@
}, },
{ {
"name": "rg3/youtube-dl", "name": "rg3/youtube-dl",
"version": "2016.04.13", "version": "2016.07.26",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/rg3/youtube-dl.git", "url": "https://github.com/rg3/youtube-dl.git",
"reference": "9e285387260a019d7471c3bdbd52cc764c0e8700" "reference": "2016.07.26"
}, },
"type": "library" "type": "library"
}, },
@ -683,25 +683,28 @@
}, },
{ {
"name": "slim/slim", "name": "slim/slim",
"version": "3.x-dev", "version": "3.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/slimphp/Slim.git", "url": "https://github.com/slimphp/Slim.git",
"reference": "b2e82a75467c12d94f038d433363e4aa7e8bf603" "reference": "184352bc1913d7ba552ab4131d62f4730ddb0893"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/b2e82a75467c12d94f038d433363e4aa7e8bf603", "url": "https://api.github.com/repos/slimphp/Slim/zipball/184352bc1913d7ba552ab4131d62f4730ddb0893",
"reference": "b2e82a75467c12d94f038d433363e4aa7e8bf603", "reference": "184352bc1913d7ba552ab4131d62f4730ddb0893",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"container-interop/container-interop": "^1.1", "container-interop/container-interop": "^1.1",
"nikic/fast-route": "^0.6", "nikic/fast-route": "^1.0",
"php": ">=5.5.0", "php": ">=5.5.0",
"pimple/pimple": "^3.0", "pimple/pimple": "^3.0",
"psr/http-message": "^1.0" "psr/http-message": "^1.0"
}, },
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.0", "phpunit/phpunit": "^4.0",
"squizlabs/php_codesniffer": "^2.5" "squizlabs/php_codesniffer": "^2.5"
@ -746,7 +749,7 @@
"micro", "micro",
"router" "router"
], ],
"time": "2016-04-14 09:05:11" "time": "2016-07-26 15:12:13"
}, },
{ {
"name": "smarty/smarty", "name": "smarty/smarty",
@ -805,16 +808,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v3.0.4", "version": "v3.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776" "reference": "5c11a1a4d4016662eeaf0f8757958c7de069f9a0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/e6f1f98bbd355d209a992bfff45e7edfbd4a0776", "url": "https://api.github.com/repos/symfony/process/zipball/5c11a1a4d4016662eeaf0f8757958c7de069f9a0",
"reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776", "reference": "5c11a1a4d4016662eeaf0f8757958c7de069f9a0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -823,7 +826,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0-dev" "dev-master": "3.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -850,20 +853,20 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2016-03-30 10:41:14" "time": "2016-06-29 05:42:25"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.0.4", "version": "v3.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "0047c8366744a16de7516622c5b7355336afae96" "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/0047c8366744a16de7516622c5b7355336afae96", "url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de",
"reference": "0047c8366744a16de7516622c5b7355336afae96", "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -872,7 +875,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0-dev" "dev-master": "3.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -899,22 +902,22 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2016-03-04 07:55:57" "time": "2016-06-29 05:41:56"
} }
], ],
"packages-dev": [ "packages-dev": [
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.1.1", "version": "v1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "1289d16209491b584839022f29257ad859b8532d" "reference": "dff51f72b0706335131b00a7f49606168c582594"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594",
"reference": "1289d16209491b584839022f29257ad859b8532d", "reference": "dff51f72b0706335131b00a7f49606168c582594",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -926,7 +929,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.1-dev" "dev-master": "1.2-dev"
} }
}, },
"autoload": { "autoload": {
@ -960,20 +963,20 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2016-01-20 09:13:37" "time": "2016-05-18 14:26:46"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v3.0.4", "version": "v3.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "3841ed86527d18ee2c35fe4afb1b2fc60f8fae79" "reference": "39492b8b8fe514163e677bf154fd80f6cc995759"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/3841ed86527d18ee2c35fe4afb1b2fc60f8fae79", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/39492b8b8fe514163e677bf154fd80f6cc995759",
"reference": "3841ed86527d18ee2c35fe4afb1b2fc60f8fae79", "reference": "39492b8b8fe514163e677bf154fd80f6cc995759",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -989,7 +992,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0-dev" "dev-master": "3.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -1023,13 +1026,12 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2016-03-10 10:34:12" "time": "2016-06-29 05:41:56"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"slim/slim": 20,
"ffmpeg/ffmpeg": 20 "ffmpeg/ffmpeg": 20
}, },
"prefer-stable": false, "prefer-stable": false,

View file

@ -16,7 +16,9 @@ use Alltube\VideoDownload;
use Alltube\Config; use Alltube\Config;
use Symfony\Component\Process\ProcessBuilder; use Symfony\Component\Process\ProcessBuilder;
use Chain\Chain; use Chain\Chain;
use ProcessStream\PopenStream; use Slim\Http\Stream;
use Slim\Http\Request;
use Slim\Http\Response;
/** /**
* Main controller * Main controller
@ -31,10 +33,11 @@ use ProcessStream\PopenStream;
* */ * */
class FrontController class FrontController
{ {
public function __construct() public function __construct($container)
{ {
$this->config = Config::getInstance(); $this->config = Config::getInstance();
$this->download = new VideoDownload(); $this->download = new VideoDownload();
$this->container = $container;
} }
/** /**
@ -45,28 +48,28 @@ class FrontController
* *
* @return void * @return void
*/ */
public function index($request, $response) public function index(Request $request, Response $response)
{ {
global $container; $this->container->view->render(
$container->view->render(
$response, $response,
'head.tpl', 'head.tpl',
array( array(
'class'=>'index' 'class'=>'index',
'description'=>'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.'
) )
); );
$container->view->render( $this->container->view->render(
$response, $response,
'header.tpl' 'header.tpl'
); );
$container->view->render( $this->container->view->render(
$response, $response,
'index.tpl', 'index.tpl',
array( array(
'convert'=>$this->config->convert 'convert'=>$this->config->convert
) )
); );
$container->view->render($response, 'footer.tpl'); $this->container->view->render($response, 'footer.tpl');
} }
/** /**
@ -77,26 +80,28 @@ class FrontController
* *
* @return void * @return void
*/ */
public function extractors($request, $response) public function extractors(Request $request, Response $response)
{ {
global $container; $this->container->view->render(
$container->view->render(
$response, $response,
'head.tpl', 'head.tpl',
array( array(
'class'=>'extractors' 'class'=>'extractors',
'title'=>'Supported websites',
'description'
=>'List of all supported websites from which Alltube Download can extract video or audio files'
) )
); );
$container->view->render($response, 'header.tpl'); $this->container->view->render($response, 'header.tpl');
$container->view->render($response, 'logo.tpl'); $this->container->view->render($response, 'logo.tpl');
$container->view->render( $this->container->view->render(
$response, $response,
'extractors.tpl', 'extractors.tpl',
array( array(
'extractors'=>$this->download->listExtractors() 'extractors'=>$this->download->listExtractors()
) )
); );
$container->view->render($response, 'footer.tpl'); $this->container->view->render($response, 'footer.tpl');
} }
/** /**
@ -107,17 +112,20 @@ class FrontController
* *
* @return void * @return void
*/ */
public function video($request, $response) public function video(Request $request, Response $response)
{ {
global $container;
$params = $request->getQueryParams(); $params = $request->getQueryParams();
$this->config = Config::getInstance(); $this->config = Config::getInstance();
if (isset($params["url"])) { if (isset($params["url"])) {
if (isset($params['audio'])) { if (isset($params['audio'])) {
try { try {
return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request); return $this->getStream($params["url"], 'mp3[protocol^=http]', $response, $request);
} catch (\Exception $e) { } catch (\Exception $e) {
$video = $this->download->getJSON($params["url"], 'best'); $video = $this->download->getJSON($params["url"], 'bestaudio/best');
if (!shell_exec('which '.$this->config->avconv)) {
throw(new \Exception('Can\'t find avconv or ffmpeg'));
}
$avconvProc = ProcessBuilder::create( $avconvProc = ProcessBuilder::create(
array( array(
@ -151,6 +159,9 @@ class FrontController
$response = $response->withHeader('Content-Type', 'audio/mpeg'); $response = $response->withHeader('Content-Type', 'audio/mpeg');
if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') { if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') {
if (!shell_exec('which '.$this->config->rtmpdump)) {
throw(new \Exception('Can\'t find rtmpdump'));
}
$builder = new ProcessBuilder( $builder = new ProcessBuilder(
array( array(
$this->config->rtmpdump, $this->config->rtmpdump,
@ -179,6 +190,9 @@ class FrontController
$chain = new Chain($builder->getProcess()); $chain = new Chain($builder->getProcess());
$chain->add('|', $avconvProc); $chain->add('|', $avconvProc);
} else { } else {
if (!shell_exec('which curl')) {
throw(new \Exception('Can\'t find curl'));
}
$chain = new Chain( $chain = new Chain(
ProcessBuilder::create( ProcessBuilder::create(
array_merge( array_merge(
@ -195,50 +209,54 @@ class FrontController
$chain->add('|', $avconvProc); $chain->add('|', $avconvProc);
} }
if ($request->isGet()) { if ($request->isGet()) {
$response = $response->withBody(new PopenStream($chain->getProcess()->getCommandLine())); $response = $response->withBody(new Stream(popen($chain->getProcess()->getCommandLine(), 'r')));
} }
return $response; return $response;
} }
} else { } else {
$video = $this->download->getJSON($params["url"]); $video = $this->download->getJSON($params["url"]);
$container->view->render( $this->container->view->render(
$response, $response,
'head.tpl', 'head.tpl',
array( array(
'class'=>'video' 'class'=>'video',
'title'=>$video->title,
'description'=>'Download "'.$video->title.'" from '.$video->extractor_key
) )
); );
$container->view->render( $this->container->view->render(
$response, $response,
'video.tpl', 'video.tpl',
array( array(
'video'=>$video 'video'=>$video
) )
); );
$container->view->render($response, 'footer.tpl'); $this->container->view->render($response, 'footer.tpl');
} }
} else {
return $response->withRedirect($this->container->get('router')->pathFor('index'));
} }
} }
public function error($request, $response, $exception) public function error(Request $request, Response $response, \Exception $exception)
{ {
global $container; $this->container->view->render(
$container->view->render(
$response, $response,
'head.tpl', 'head.tpl',
array( array(
'class'=>'video' 'class'=>'video',
'title'=>'Error'
) )
); );
$container->view->render( $this->container->view->render(
$response, $response,
'error.tpl', 'error.tpl',
array( array(
'errors'=>$exception->getMessage() 'errors'=>$exception->getMessage()
) )
); );
$container->view->render($response, 'footer.tpl'); $this->container->view->render($response, 'footer.tpl');
return $response; return $response->withStatus(500);
} }
private function getStream($url, $format, $response, $request) private function getStream($url, $format, $response, $request)
@ -266,9 +284,8 @@ class FrontController
* *
* @return void * @return void
*/ */
public function redirect($request, $response) public function redirect(Request $request, Response $response)
{ {
global $app;
$params = $request->getQueryParams(); $params = $request->getQueryParams();
if (isset($params["url"])) { if (isset($params["url"])) {
try { try {
@ -288,9 +305,8 @@ class FrontController
* *
* @return void * @return void
*/ */
public function json($request, $response) public function json(Request $request, Response $response)
{ {
global $app;
$params = $request->getQueryParams(); $params = $request->getQueryParams();
if (isset($params["url"])) { if (isset($params["url"])) {
try { try {

View file

@ -570,6 +570,7 @@ h1 {
} }
@media (max-width: 640px) { @media (max-width: 640px) {
.formats,
.thumb { .thumb {
width:90%; width:90%;
} }
@ -657,3 +658,9 @@ h1 {
} }
} }
@media all and (display-mode: standalone) {
.bookmarklet_wrapper {
display: none;
}
}

View file

@ -1,5 +1,5 @@
<!Doctype HTML> <!Doctype HTML>
<html lang="en" itemscope itemtype="http://schema.org/WebApplication"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
@ -9,7 +9,7 @@
<body> <body>
<div class="wrapper"> <div class="wrapper">
<div class="main"> <div class="main">
<h1><img itemprop="image" class="logo" src="img/logo.png" <h1><img class="logo" src="img/logo.png"
alt="AllTube Download" width="328" height="284"></h1> alt="AllTube Download" width="328" height="284"></h1>
<div>An error occurred in the application and your page could not be served. Please try again in a few moments.</div> <div>An error occurred in the application and your page could not be served. Please try again in a few moments.</div>
</div> </div>

View file

@ -16,6 +16,11 @@ require_once __DIR__.'/vendor/autoload.php';
use Alltube\VideoDownload; use Alltube\VideoDownload;
use Alltube\Controller\FrontController; use Alltube\Controller\FrontController;
if (strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
header('Location: '.str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
die;
}
$app = new \Slim\App(); $app = new \Slim\App();
$container = $app->getContainer(); $container = $app->getContainer();
$container['view'] = function ($c) { $container['view'] = function ($c) {
@ -28,14 +33,14 @@ $container['view'] = function ($c) {
return $view; return $view;
}; };
$controller = new FrontController(); $controller = new FrontController($container);
$container['errorHandler'] = array($controller, 'error'); $container['errorHandler'] = array($controller, 'error');
$app->get( $app->get(
'/', '/',
array($controller, 'index') array($controller, 'index')
); )->setName('index');
$app->get( $app->get(
'/extractors', '/extractors',
array($controller, 'extractors') array($controller, 'extractors')

View file

@ -1,78 +1,69 @@
/*global chrome*/ /*global chrome*/
/*jslint devel: true, browser: true */ /*jslint browser: true, nomen: true */
var launchBtn, disabledBtn, stopBtn; var castModule = (function () {
var session, currentMedia;
function receiverListener(e)
{
'use strict'; 'use strict';
console.log('receiverListener', e); var launchBtn, disabledBtn, stopBtn, session;
}
function onMediaDiscovered(how, media) function receiverListener(e) {
{ return (e === chrome.cast.ReceiverAvailability.AVAILABLE);
'use strict'; }
console.log('onMediaDiscovered', how);
currentMedia = media; function onMediaDiscovered() {
if (launchBtn) { if (launchBtn) {
stopBtn.classList.remove('cast_hidden'); stopBtn.classList.remove('cast_hidden');
launchBtn.classList.add('cast_hidden'); launchBtn.classList.add('cast_hidden');
} }
} }
function sessionListener(e) function onStopCast() {
{ stopBtn.classList.add('cast_hidden');
'use strict'; launchBtn.classList.remove('cast_hidden');
}
function onStopCastError(e) {
onStopCast();
throw e.description;
}
function updateListener() {
if (session.status !== chrome.cast.SessionStatus.CONNECTED) {
onStopCast();
}
}
function sessionListener(e) {
session = e; session = e;
session.addMediaListener(onMediaDiscovered.bind(this, 'addMediaListener')); session.addMediaListener(onMediaDiscovered.bind(this, 'addMediaListener'));
session.addUpdateListener(updateListener.bind(this));
if (session.media.length !== 0) { if (session.media.length !== 0) {
onMediaDiscovered('onRequestSessionSuccess', session.media[0]); onMediaDiscovered('onRequestSessionSuccess', session.media[0]);
} }
} }
function onStopCast() function stopCast() {
{ session.stop(onStopCast, onStopCastError);
'use strict'; }
stopBtn.classList.add('cast_hidden');
launchBtn.classList.remove('cast_hidden');
}
function stopCast() function onMediaError(e) {
{
'use strict';
session.stop(onStopCast);
}
function onMediaError()
{
'use strict';
console.log('onMediaError');
stopCast(); stopCast();
} throw e.description;
}
function onRequestSessionSuccess(e) function onRequestSessionSuccess(e) {
{
'use strict';
session = e; session = e;
var videoLink = document.getElementById('video_link'), videoURL = videoLink.dataset.video, mediaInfo = new chrome.cast.media.MediaInfo(videoURL, 'video/' + videoLink.dataset.ext), request = new chrome.cast.media.LoadRequest(mediaInfo); var videoLink = document.getElementById('video_link'), videoURL = videoLink.dataset.video, mediaInfo = new chrome.cast.media.MediaInfo(videoURL, 'video/' + videoLink.dataset.ext), request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError); session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);
} }
function onLaunchError(e) function onLaunchError(e) {
{ throw e.description;
'use strict'; }
console.log('onLaunchError', e.description);
}
function launchCast() function launchCast() {
{
'use strict';
chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError); chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError);
} }
function onInitSuccess() function onInitSuccess() {
{
'use strict';
launchBtn = document.getElementById('cast_btn_launch'); launchBtn = document.getElementById('cast_btn_launch');
disabledBtn = document.getElementById('cast_disabled'); disabledBtn = document.getElementById('cast_disabled');
stopBtn = document.getElementById('cast_btn_stop'); stopBtn = document.getElementById('cast_btn_stop');
@ -82,29 +73,34 @@ function onInitSuccess()
launchBtn.addEventListener('click', launchCast, false); launchBtn.addEventListener('click', launchCast, false);
stopBtn.addEventListener('click', stopCast, false); stopBtn.addEventListener('click', stopCast, false);
} }
} }
function onError() function onError(e) {
{ throw e.code;
'use strict'; }
console.log('onError');
}
function initializeCastApi() function initializeCastApi() {
{
'use strict';
var sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID), apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, receiverListener, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED); var sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID), apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, receiverListener, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED);
chrome.cast.initialize(apiConfig, onInitSuccess, onError); chrome.cast.initialize(apiConfig, onInitSuccess, onError);
} }
function loadCastApi(loaded, errorInfo) function loadCastApi(loaded, errorInfo) {
{
'use strict';
if (loaded) { if (loaded) {
initializeCastApi(); initializeCastApi();
} else { } else {
console.log(errorInfo); throw errorInfo;
}
} }
}
window['__onGCastApiAvailable'] = loadCastApi; return {
init: function () {
var intro = document.getElementById('download_intro');
if (intro) {
intro.insertAdjacentHTML('beforeend', '<img class="cast_icon" id="cast_disabled" src="img/ic_media_route_disabled_holo_light.png" alt="" title="Google Cast is not supported on this browser." /> <img class="cast_btn cast_hidden cast_icon" id="cast_btn_launch" src="img/ic_media_route_off_holo_light.png" title="Cast to ChromeCast" alt="Google Cast™" /> <img src="img/ic_media_route_on_holo_light.png" alt="Casting to ChromeCast…" title="Stop casting" id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" />');
window.__onGCastApiAvailable = loadCastApi;
}
}
};
}());
window.addEventListener('load', castModule.init, false);

View file

@ -1,5 +1,5 @@
<!Doctype HTML> <!Doctype HTML>
<html lang="en" itemscope itemtype="http://schema.org/WebApplication"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
@ -9,7 +9,7 @@
<body> <body>
<div class="wrapper"> <div class="wrapper">
<div class="main"> <div class="main">
<h1><img itemprop="image" class="logo" src="img/logo.png" <h1><img class="logo" src="img/logo.png"
alt="AllTube Download" width="328" height="284"></h1> alt="AllTube Download" width="328" height="284"></h1>
<div>This application is undergoing maintenance right now. Please check back later.</div> <div>This application is undergoing maintenance right now. Please check back later.</div>
</div> </div>

View file

@ -1,7 +1,8 @@
{ {
"short_name": "AllTube", "short_name": "AllTube",
"name": "AllTube Download", "name": "AllTube Download",
"display": "minimal-ui", "description": "Easily download videos from Youtube, Dailymotion, Vimeo and other websites",
"display": "standalone",
"icons": [{ "icons": [{
"src": "img/favicon.png", "src": "img/favicon.png",
"sizes": "32x32", "sizes": "32x32",
@ -24,6 +25,7 @@
"type": "image/png" "type": "image/png"
}], }],
"lang": "en", "lang": "en",
"start_url": "./index.php", "start_url": "./",
"theme_color": "#4F4F4F" "theme_color": "#4F4F4F",
"orientation": "portrait"
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "alltube", "name": "alltube",
"version": "0.4.5", "version": "0.5.0",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"grunt": "~1.0.1", "grunt": "~1.0.1",
@ -10,9 +10,10 @@
"grunt-contrib-watch": "~1.0.0", "grunt-contrib-watch": "~1.0.0",
"grunt-phpcs": "~0.4.0", "grunt-phpcs": "~0.4.0",
"grunt-phpunit": "~0.3.6", "grunt-phpunit": "~0.3.6",
"grunt-contrib-compress": "~1.2.0", "grunt-contrib-compress": "~1.3.0",
"bower": "~1.7.1", "bower": "~1.7.1",
"grunt-githash": "~0.1.3" "grunt-githash": "~0.1.3",
"grunt-jslint": "~1.1.14"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -10,4 +10,3 @@
{/foreach} {/foreach}
</i></p> </i></p>
</div> </div>
</div>

View file

@ -1,10 +1,10 @@
</div> </div>
<footer> <footer>
<div class="footer_wrapper"> <div class="footer_wrapper">
Code by <a rel="author" target="blank" itemprop="author" Code by <a rel="author" target="blank"
href="http://rudloff.pro/">Pierre Rudloff</a> href="http://rudloff.pro/">Pierre Rudloff</a>
&middot; Design by &middot; Design by
<a rel="author" itemprop="author" target="blank" <a rel="author" target="blank"
href="http://olivierhaquette.fr">Olivier Haquette</a> href="http://olivierhaquette.fr">Olivier Haquette</a>
&middot; &middot;
<a target="_blank" <a target="_blank"

View file

@ -1,30 +1,24 @@
<!Doctype HTML> <!Doctype HTML>
<html lang="en" itemscope itemtype="http://schema.org/WebApplication"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name=viewport content="width=device-width, initial-scale=1"> <meta name=viewport content="width=device-width, initial-scale=1">
<meta name="description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." /> {if isset($description)}
<meta name="description" content="{$description|escape}" />
<meta name="twitter:description" content="{$description|escape}" />
<meta property="og:description" content="{$description|escape}" />
{/if}
<link rel="stylesheet" href="{base_url|noscheme}/dist/main.css" /> <link rel="stylesheet" href="{base_url|noscheme}/dist/main.css" />
<link rel="author" href="https://plus.google.com/110403274854419000481?rel=author" /> <title>AllTube Download{if isset($title)} - {$title|escape}{/if}</title>
<link rel="author" href="https://plus.google.com/103696815796116179392?rel=author" />
<link href="https://plus.google.com/108799967445657477255" rel="publisher" />
<title itemprop="name">AllTube Download</title>
<meta itemprop="url" content="{base_url|noscheme}" />
<link rel="canonical" href="//{$smarty.server.HTTP_HOST|cat:$smarty.server.REQUEST_URI|replace:{base_url|noscheme}:'http://www.alltubedownload.net'}" /> <link rel="canonical" href="//{$smarty.server.HTTP_HOST|cat:$smarty.server.REQUEST_URI|replace:{base_url|noscheme}:'http://www.alltubedownload.net'}" />
<link rel="icon" href="{base_url|noscheme}/img/favicon.png" /> <link rel="icon" href="{base_url|noscheme}/img/favicon.png" />
<meta property="og:url" content="{base_url|noscheme}" /> <meta property="og:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" />
<meta property="og:title" content="AllTube Download" /> <meta property="og:image" content="{base_url}/img/logo.png" />
<meta property="og:description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<meta property="og:image" content="{base_url|noscheme}/img/logo.png" />
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="AllTube Download" /> <meta name="twitter:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" />
<meta name="twitter:image" content="{base_url|noscheme}/img/logo.png" /> <meta name="twitter:image" content="{base_url}/img/logo.png" />
<meta name="twitter:creator" content="@Tael67" /> <meta name="twitter:creator" content="@Tael67" />
<meta name="twitter:description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script> <script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<meta itemprop="applicationCategory" content="Download" />
<meta itemprop="operatingSystem" content="Linux" />
<meta itemprop="operatingSystem" content="Mac OS X" />
<meta name="theme-color" content="#4F4F4F"> <meta name="theme-color" content="#4F4F4F">
<link rel="manifest" href="manifest.json" /> <link rel="manifest" href="manifest.json" />
</head> </head>

View file

@ -1,5 +1,5 @@
<div class="main"> <div class="main">
<div><img itemprop="image" class="logo" src="{base_url|noscheme}/img/logo.png" <div><img class="logo" src="{base_url|noscheme}/img/logo.png"
alt="AllTube Download" width="328" height="284"></div> alt="AllTube Download" width="328" height="284"></div>
<form action="{path_for name="video"}"> <form action="{path_for name="video"}">
<label class="labelurl" for="url"> <label class="labelurl" for="url">
@ -21,7 +21,7 @@
</div> </div>
</form> </form>
<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"> <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='{base_url|noscheme}{path_for name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
</div> </div>

View file

@ -2,31 +2,28 @@
<div itemscope itemtype="http://schema.org/VideoObject"> <div itemscope itemtype="http://schema.org/VideoObject">
<div class="main"> <div class="main">
{include file="logo.tpl"} {include file="logo.tpl"}
<p>You are going to download<i itemprop="name"> <p id="download_intro">You are going to download<i itemprop="name">
<a itemprop="url" id="video_link" <a itemprop="url" id="video_link"
data-ext="{$video->ext}" data-ext="{$video->ext}"
data-video="{$video->url|escape}" data-video="{$video->url|escape}"
href="{$video->webpage_url}"> href="{$video->webpage_url}">
{$video->title}</a></i>. {$video->title}</a></i>.
<img class="cast_icon" id="cast_disabled" </p>
src="{base_url|noscheme}/img/ic_media_route_disabled_holo_light.png"
alt="Google Cast™ is disabled"
title="Google Cast is not supported on this browser." />
<img class="cast_btn cast_hidden cast_icon" id="cast_btn_launch"
src="{base_url|noscheme}/img/ic_media_route_off_holo_light.png"
title="Cast to ChromeCast" alt="Google Cast™" />
<img src="{base_url|noscheme}/img/ic_media_route_on_holo_light.png"
alt="Casting to ChromeCast…" title="Stop casting"
id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" /></p>
{if isset($video->thumbnail)} {if isset($video->thumbnail)}
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" /> <img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt="" />
{/if}
{if isset($video->description)}
<meta itemprop="description" content="{$video->description|escape}" />
{/if}
{if isset($video->upload_date)}
<meta itemprop="uploadDate" content="{$video->upload_date}" />
{/if} {/if}
<br/> <br/>
{if isset($video->formats)} {if isset($video->formats)}
<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}" />
<select name="format" id="format" class="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]">
{strip} {strip}
@ -43,7 +40,6 @@
</optgroup> </optgroup>
<optgroup label="Detailed formats" class="monospace"> <optgroup label="Detailed formats" class="monospace">
{foreach $video->formats as $format} {foreach $video->formats as $format}
{$format->protocol}
{if $format->protocol|in_array:array('http', 'https')} {if $format->protocol|in_array:array('http', 'https')}
{strip} {strip}
<option value="{$format->format_id}"> <option value="{$format->format_id}">