diff --git a/Gruntfile.js b/Gruntfile.js index 1d05fad..e18273a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -41,7 +41,9 @@ module.exports = function (grunt) { }, tests: { src: ['tests/*.php'] - }, + } + }, + jslint: { js: { src: ['js/*.js'] }, @@ -72,9 +74,10 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-phpcs'); grunt.loadNpmTasks('grunt-phpunit'); grunt.loadNpmTasks('grunt-contrib-compress'); + grunt.loadNpmTasks('grunt-jslint'); grunt.registerTask('default', ['uglify', 'cssmin']); - grunt.registerTask('lint', ['phpcs']); + grunt.registerTask('lint', ['phpcs', 'jslint']); grunt.registerTask('test', ['phpunit']); grunt.registerTask('release', ['default', 'githash', 'compress']); }; diff --git a/README.md b/README.md index 91fe057..d1c767d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ HTML GUI for youtube-dl (http://alltubedownload.net/) ![Screenshot](img/screenshot.png "Alltube GUI screenshot") ##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/): 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.__ ##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*. 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). diff --git a/composer.json b/composer.json index 4817834..d5549da 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,11 @@ "type": "project", "require": { "smarty/smarty": "~3.1.29", - "rg3/youtube-dl": "2016.04.13", - "slim/slim": "3.x-dev", + "rg3/youtube-dl": "~2016.07.26", + "slim/slim": "~3.5.0", "mathmarques/smarty-view": "~1.1.0", - "symfony/yaml": "~3.0.0", - "symfony/process": "~3.0.0", + "symfony/yaml": "~3.1.0", + "symfony/process": "~3.1.0", "ptachoire/process-builder-chain": "~1.2.0", "ffmpeg/ffmpeg": "dev-release", "rudloff/smarty-plugin-noscheme": "~0.1.0", @@ -19,7 +19,7 @@ "rudloff/psr7-process-stream": "~0.1.0" }, "require-dev": { - "symfony/var-dumper": "~3.0.0" + "symfony/var-dumper": "~3.1.0" }, "extra": { "paas": { @@ -32,11 +32,11 @@ "type": "package", "package": { "name": "rg3/youtube-dl", - "version": "2016.04.13", + "version": "2016.07.26", "source": { "url": "https://github.com/rg3/youtube-dl.git", "type": "git", - "reference": "9e285387260a019d7471c3bdbd52cc764c0e8700" + "reference": "2016.07.26" } } }, { diff --git a/composer.lock b/composer.lock index b7e5787..8e6f540 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "962f54d3ada96f7d3289479b13812c1a", - "content-hash": "2dea64564c520577cb275f73d046ed75", + "hash": "19bf8d61960475e79792cb0718198f21", + "content-hash": "de1c44fd5ca25ea1b71d0252d3b68cd7", "packages": [ { "name": "container-interop/container-interop", @@ -50,27 +50,27 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.2.0", + "version": "6.2.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "d094e337976dff9d8e2424e8485872194e768662" + "reference": "3f808fba627f2c5b69e2501217bf31af349c1427" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", - "reference": "d094e337976dff9d8e2424e8485872194e768662", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427", + "reference": "3f808fba627f2c5b69e2501217bf31af349c1427", "shasum": "" }, "require": { - "guzzlehttp/promises": "~1.0", - "guzzlehttp/psr7": "~1.1", - "php": ">=5.5.0" + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.3.1", + "php": ">=5.5" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" }, "type": "library", "extra": { @@ -108,20 +108,20 @@ "rest", "web service" ], - "time": "2016-03-21 20:02:09" + "time": "2016-07-15 17:22:37" }, { "name": "guzzlehttp/promises", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8" + "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8", - "reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8", + "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", + "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", "shasum": "" }, "require": { @@ -159,20 +159,20 @@ "keywords": [ "promise" ], - "time": "2016-03-08 01:15:46" + "time": "2016-05-18 16:56:05" }, { "name": "guzzlehttp/psr7", - "version": "1.3.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "31382fef2889136415751badebbd1cb022a4ed72" + "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72", - "reference": "31382fef2889136415751badebbd1cb022a4ed72", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", "shasum": "" }, "require": { @@ -188,7 +188,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -217,7 +217,7 @@ "stream", "uri" ], - "time": "2016-04-13 19:56:01" + "time": "2016-06-24 23:00:38" }, { "name": "jeremykendall/php-domain-parser", @@ -397,16 +397,16 @@ }, { "name": "nikic/fast-route", - "version": "v0.6.0", + "version": "v1.0.1", "source": { "type": "git", "url": "https://github.com/nikic/FastRoute.git", - "reference": "31fa86924556b80735f98b294a7ffdfb26789f22" + "reference": "8ea928195fa9b907f0d6e48312d323c1a13cc2af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/FastRoute/zipball/31fa86924556b80735f98b294a7ffdfb26789f22", - "reference": "31fa86924556b80735f98b294a7ffdfb26789f22", + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/8ea928195fa9b907f0d6e48312d323c1a13cc2af", + "reference": "8ea928195fa9b907f0d6e48312d323c1a13cc2af", "shasum": "" }, "require": { @@ -436,7 +436,7 @@ "router", "routing" ], - "time": "2015-06-18 19:15:47" + "time": "2016-06-12 19:08:51" }, { "name": "pimple/pimple", @@ -571,11 +571,11 @@ }, { "name": "rg3/youtube-dl", - "version": "2016.04.13", + "version": "2016.07.26", "source": { "type": "git", "url": "https://github.com/rg3/youtube-dl.git", - "reference": "9e285387260a019d7471c3bdbd52cc764c0e8700" + "reference": "2016.07.26" }, "type": "library" }, @@ -683,25 +683,28 @@ }, { "name": "slim/slim", - "version": "3.x-dev", + "version": "3.5.0", "source": { "type": "git", "url": "https://github.com/slimphp/Slim.git", - "reference": "b2e82a75467c12d94f038d433363e4aa7e8bf603" + "reference": "184352bc1913d7ba552ab4131d62f4730ddb0893" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim/zipball/b2e82a75467c12d94f038d433363e4aa7e8bf603", - "reference": "b2e82a75467c12d94f038d433363e4aa7e8bf603", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/184352bc1913d7ba552ab4131d62f4730ddb0893", + "reference": "184352bc1913d7ba552ab4131d62f4730ddb0893", "shasum": "" }, "require": { "container-interop/container-interop": "^1.1", - "nikic/fast-route": "^0.6", + "nikic/fast-route": "^1.0", "php": ">=5.5.0", "pimple/pimple": "^3.0", "psr/http-message": "^1.0" }, + "provide": { + "psr/http-message-implementation": "1.0" + }, "require-dev": { "phpunit/phpunit": "^4.0", "squizlabs/php_codesniffer": "^2.5" @@ -746,7 +749,7 @@ "micro", "router" ], - "time": "2016-04-14 09:05:11" + "time": "2016-07-26 15:12:13" }, { "name": "smarty/smarty", @@ -805,16 +808,16 @@ }, { "name": "symfony/process", - "version": "v3.0.4", + "version": "v3.1.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776" + "reference": "5c11a1a4d4016662eeaf0f8757958c7de069f9a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e6f1f98bbd355d209a992bfff45e7edfbd4a0776", - "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776", + "url": "https://api.github.com/repos/symfony/process/zipball/5c11a1a4d4016662eeaf0f8757958c7de069f9a0", + "reference": "5c11a1a4d4016662eeaf0f8757958c7de069f9a0", "shasum": "" }, "require": { @@ -823,7 +826,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -850,20 +853,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-03-30 10:41:14" + "time": "2016-06-29 05:42:25" }, { "name": "symfony/yaml", - "version": "v3.0.4", + "version": "v3.1.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0047c8366744a16de7516622c5b7355336afae96" + "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0047c8366744a16de7516622c5b7355336afae96", - "reference": "0047c8366744a16de7516622c5b7355336afae96", + "url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de", + "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de", "shasum": "" }, "require": { @@ -872,7 +875,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -899,22 +902,22 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-03-04 07:55:57" + "time": "2016-06-29 05:41:56" } ], "packages-dev": [ { "name": "symfony/polyfill-mbstring", - "version": "v1.1.1", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "1289d16209491b584839022f29257ad859b8532d" + "reference": "dff51f72b0706335131b00a7f49606168c582594" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", - "reference": "1289d16209491b584839022f29257ad859b8532d", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", + "reference": "dff51f72b0706335131b00a7f49606168c582594", "shasum": "" }, "require": { @@ -926,7 +929,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -960,20 +963,20 @@ "portable", "shim" ], - "time": "2016-01-20 09:13:37" + "time": "2016-05-18 14:26:46" }, { "name": "symfony/var-dumper", - "version": "v3.0.4", + "version": "v3.1.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "3841ed86527d18ee2c35fe4afb1b2fc60f8fae79" + "reference": "39492b8b8fe514163e677bf154fd80f6cc995759" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/3841ed86527d18ee2c35fe4afb1b2fc60f8fae79", - "reference": "3841ed86527d18ee2c35fe4afb1b2fc60f8fae79", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/39492b8b8fe514163e677bf154fd80f6cc995759", + "reference": "39492b8b8fe514163e677bf154fd80f6cc995759", "shasum": "" }, "require": { @@ -989,7 +992,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1023,13 +1026,12 @@ "debug", "dump" ], - "time": "2016-03-10 10:34:12" + "time": "2016-06-29 05:41:56" } ], "aliases": [], "minimum-stability": "stable", "stability-flags": { - "slim/slim": 20, "ffmpeg/ffmpeg": 20 }, "prefer-stable": false, diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 2908bfa..c4cc021 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -16,7 +16,9 @@ use Alltube\VideoDownload; use Alltube\Config; use Symfony\Component\Process\ProcessBuilder; use Chain\Chain; -use ProcessStream\PopenStream; +use Slim\Http\Stream; +use Slim\Http\Request; +use Slim\Http\Response; /** * Main controller @@ -31,10 +33,11 @@ use ProcessStream\PopenStream; * */ class FrontController { - public function __construct() + public function __construct($container) { $this->config = Config::getInstance(); $this->download = new VideoDownload(); + $this->container = $container; } /** @@ -45,28 +48,28 @@ class FrontController * * @return void */ - public function index($request, $response) + public function index(Request $request, Response $response) { - global $container; - $container->view->render( + $this->container->view->render( $response, 'head.tpl', array( - 'class'=>'index' + 'class'=>'index', + 'description'=>'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.' ) ); - $container->view->render( + $this->container->view->render( $response, 'header.tpl' ); - $container->view->render( + $this->container->view->render( $response, 'index.tpl', array( '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 */ - public function extractors($request, $response) + public function extractors(Request $request, Response $response) { - global $container; - $container->view->render( + $this->container->view->render( $response, 'head.tpl', 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'); - $container->view->render($response, 'logo.tpl'); - $container->view->render( + $this->container->view->render($response, 'header.tpl'); + $this->container->view->render($response, 'logo.tpl'); + $this->container->view->render( $response, 'extractors.tpl', array( '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 */ - public function video($request, $response) + public function video(Request $request, Response $response) { - global $container; $params = $request->getQueryParams(); $this->config = Config::getInstance(); if (isset($params["url"])) { if (isset($params['audio'])) { try { - return $this->getStream($params["url"], 'bestaudio[protocol^=http]', $response, $request); + return $this->getStream($params["url"], 'mp3[protocol^=http]', $response, $request); } 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( array( @@ -151,6 +159,9 @@ class FrontController $response = $response->withHeader('Content-Type', 'audio/mpeg'); 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( array( $this->config->rtmpdump, @@ -179,6 +190,9 @@ class FrontController $chain = new Chain($builder->getProcess()); $chain->add('|', $avconvProc); } else { + if (!shell_exec('which curl')) { + throw(new \Exception('Can\'t find curl')); + } $chain = new Chain( ProcessBuilder::create( array_merge( @@ -195,50 +209,54 @@ class FrontController $chain->add('|', $avconvProc); } if ($request->isGet()) { - $response = $response->withBody(new PopenStream($chain->getProcess()->getCommandLine())); + $response = $response->withBody(new Stream(popen($chain->getProcess()->getCommandLine(), 'r'))); } return $response; } } else { $video = $this->download->getJSON($params["url"]); - $container->view->render( + $this->container->view->render( $response, 'head.tpl', array( - 'class'=>'video' + 'class'=>'video', + 'title'=>$video->title, + 'description'=>'Download "'.$video->title.'" from '.$video->extractor_key ) ); - $container->view->render( + $this->container->view->render( $response, 'video.tpl', array( '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; - $container->view->render( + $this->container->view->render( $response, 'head.tpl', array( - 'class'=>'video' + 'class'=>'video', + 'title'=>'Error' ) ); - $container->view->render( + $this->container->view->render( $response, 'error.tpl', array( 'errors'=>$exception->getMessage() ) ); - $container->view->render($response, 'footer.tpl'); - return $response; + $this->container->view->render($response, 'footer.tpl'); + return $response->withStatus(500); } private function getStream($url, $format, $response, $request) @@ -266,9 +284,8 @@ class FrontController * * @return void */ - public function redirect($request, $response) + public function redirect(Request $request, Response $response) { - global $app; $params = $request->getQueryParams(); if (isset($params["url"])) { try { @@ -288,9 +305,8 @@ class FrontController * * @return void */ - public function json($request, $response) + public function json(Request $request, Response $response) { - global $app; $params = $request->getQueryParams(); if (isset($params["url"])) { try { diff --git a/css/style.css b/css/style.css index 028928e..1c5c8e7 100644 --- a/css/style.css +++ b/css/style.css @@ -570,6 +570,7 @@ h1 { } @media (max-width: 640px) { + .formats, .thumb { width:90%; } @@ -657,3 +658,9 @@ h1 { } } + +@media all and (display-mode: standalone) { + .bookmarklet_wrapper { + display: none; + } +} diff --git a/error.html b/error.html index 81b5d00..b3ac86c 100644 --- a/error.html +++ b/error.html @@ -1,5 +1,5 @@ - + @@ -9,7 +9,7 @@
-

An error occurred in the application and your page could not be served. Please try again in a few moments.
diff --git a/index.php b/index.php index 9a33cd7..e9cee6f 100644 --- a/index.php +++ b/index.php @@ -16,6 +16,11 @@ require_once __DIR__.'/vendor/autoload.php'; use Alltube\VideoDownload; 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(); $container = $app->getContainer(); $container['view'] = function ($c) { @@ -28,14 +33,14 @@ $container['view'] = function ($c) { return $view; }; -$controller = new FrontController(); +$controller = new FrontController($container); $container['errorHandler'] = array($controller, 'error'); $app->get( '/', array($controller, 'index') -); +)->setName('index'); $app->get( '/extractors', array($controller, 'extractors') diff --git a/js/cast.js b/js/cast.js index 22d6e7a..0cc0bd3 100644 --- a/js/cast.js +++ b/js/cast.js @@ -1,110 +1,106 @@ /*global chrome*/ -/*jslint devel: true, browser: true */ -var launchBtn, disabledBtn, stopBtn; -var session, currentMedia; - -function receiverListener(e) -{ +/*jslint browser: true, nomen: true */ +var castModule = (function () { 'use strict'; - console.log('receiverListener', e); -} + var launchBtn, disabledBtn, stopBtn, session; -function onMediaDiscovered(how, media) -{ - 'use strict'; - console.log('onMediaDiscovered', how); - currentMedia = media; - if (launchBtn) { - stopBtn.classList.remove('cast_hidden'); - launchBtn.classList.add('cast_hidden'); + function receiverListener(e) { + return (e === chrome.cast.ReceiverAvailability.AVAILABLE); } -} -function sessionListener(e) -{ - 'use strict'; - session = e; - session.addMediaListener(onMediaDiscovered.bind(this, 'addMediaListener')); - if (session.media.length !== 0) { - onMediaDiscovered('onRequestSessionSuccess', session.media[0]); + function onMediaDiscovered() { + if (launchBtn) { + stopBtn.classList.remove('cast_hidden'); + launchBtn.classList.add('cast_hidden'); + } } -} -function onStopCast() -{ - 'use strict'; - stopBtn.classList.add('cast_hidden'); - launchBtn.classList.remove('cast_hidden'); -} - -function stopCast() -{ - 'use strict'; - session.stop(onStopCast); -} - -function onMediaError() -{ - 'use strict'; - console.log('onMediaError'); - stopCast(); -} - -function onRequestSessionSuccess(e) -{ - 'use strict'; - 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); - session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError); -} - -function onLaunchError(e) -{ - 'use strict'; - console.log('onLaunchError', e.description); -} - -function launchCast() -{ - 'use strict'; - chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError); -} - -function onInitSuccess() -{ - 'use strict'; - launchBtn = document.getElementById('cast_btn_launch'); - disabledBtn = document.getElementById('cast_disabled'); - stopBtn = document.getElementById('cast_btn_stop'); - if (launchBtn) { - disabledBtn.classList.add('cast_hidden'); + function onStopCast() { + stopBtn.classList.add('cast_hidden'); launchBtn.classList.remove('cast_hidden'); - launchBtn.addEventListener('click', launchCast, false); - stopBtn.addEventListener('click', stopCast, false); } -} -function onError() -{ - 'use strict'; - console.log('onError'); -} - -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); - chrome.cast.initialize(apiConfig, onInitSuccess, onError); -} - -function loadCastApi(loaded, errorInfo) -{ - 'use strict'; - if (loaded) { - initializeCastApi(); - } else { - console.log(errorInfo); + function onStopCastError(e) { + onStopCast(); + throw e.description; } -} -window['__onGCastApiAvailable'] = loadCastApi; + function updateListener() { + if (session.status !== chrome.cast.SessionStatus.CONNECTED) { + onStopCast(); + } + } + + function sessionListener(e) { + session = e; + session.addMediaListener(onMediaDiscovered.bind(this, 'addMediaListener')); + session.addUpdateListener(updateListener.bind(this)); + if (session.media.length !== 0) { + onMediaDiscovered('onRequestSessionSuccess', session.media[0]); + } + } + + function stopCast() { + session.stop(onStopCast, onStopCastError); + } + + function onMediaError(e) { + stopCast(); + throw e.description; + } + + function onRequestSessionSuccess(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); + session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError); + } + + function onLaunchError(e) { + throw e.description; + } + + function launchCast() { + chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError); + } + + function onInitSuccess() { + launchBtn = document.getElementById('cast_btn_launch'); + disabledBtn = document.getElementById('cast_disabled'); + stopBtn = document.getElementById('cast_btn_stop'); + if (launchBtn) { + disabledBtn.classList.add('cast_hidden'); + launchBtn.classList.remove('cast_hidden'); + launchBtn.addEventListener('click', launchCast, false); + stopBtn.addEventListener('click', stopCast, false); + } + } + + function onError(e) { + throw e.code; + } + + function initializeCastApi() { + 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); + } + + function loadCastApi(loaded, errorInfo) { + if (loaded) { + initializeCastApi(); + } else { + throw errorInfo; + } + } + + return { + init: function () { + var intro = document.getElementById('download_intro'); + if (intro) { + intro.insertAdjacentHTML('beforeend', ' Google Cast™ Casting to ChromeCast…'); + window.__onGCastApiAvailable = loadCastApi; + } + } + }; +}()); + +window.addEventListener('load', castModule.init, false); diff --git a/maintenance.html b/maintenance.html index f7ba7a5..cae4766 100644 --- a/maintenance.html +++ b/maintenance.html @@ -1,5 +1,5 @@ - + @@ -9,7 +9,7 @@
-

This application is undergoing maintenance right now. Please check back later.
diff --git a/manifest.json b/manifest.json index 57256cf..9f08114 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,8 @@ { "short_name": "AllTube", "name": "AllTube Download", - "display": "minimal-ui", + "description": "Easily download videos from Youtube, Dailymotion, Vimeo and other websites", + "display": "standalone", "icons": [{ "src": "img/favicon.png", "sizes": "32x32", @@ -24,6 +25,7 @@ "type": "image/png" }], "lang": "en", - "start_url": "./index.php", - "theme_color": "#4F4F4F" + "start_url": "./", + "theme_color": "#4F4F4F", + "orientation": "portrait" } diff --git a/package.json b/package.json index 5e4480d..2620eab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alltube", - "version": "0.4.5", + "version": "0.5.0", "license": "GPL-3.0", "dependencies": { "grunt": "~1.0.1", @@ -10,9 +10,10 @@ "grunt-contrib-watch": "~1.0.0", "grunt-phpcs": "~0.4.0", "grunt-phpunit": "~0.3.6", - "grunt-contrib-compress": "~1.2.0", + "grunt-contrib-compress": "~1.3.0", "bower": "~1.7.1", - "grunt-githash": "~0.1.3" + "grunt-githash": "~0.1.3", + "grunt-jslint": "~1.1.14" }, "repository": { "type": "git", diff --git a/templates/error.tpl b/templates/error.tpl index 6756cf2..d000ab3 100644 --- a/templates/error.tpl +++ b/templates/error.tpl @@ -10,4 +10,3 @@ {/foreach}

-
diff --git a/templates/footer.tpl b/templates/footer.tpl index 8dcf4dd..cdbb327 100644 --- a/templates/footer.tpl +++ b/templates/footer.tpl @@ -1,10 +1,10 @@