diff --git a/.dockerignore b/.dockerignore
new file mode 120000
index 0000000..3e4e48b
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+.gitignore
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 7b3d7a5..0fb6d93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ ffmpeg.tar.xz
ffmpeg-*/
alltube-release.zip
coverage/
+bower_components/
+config.yml
diff --git a/.travis.yml b/.travis.yml
index 89517de..fbe6512 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,3 +2,5 @@ language: php
install:
- composer install
- npm install
+before_install:
+ - composer selfupdate
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..74e03bb
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,15 @@
+FROM php:apache
+RUN apt-get update
+RUN apt-get install -y libicu-dev xz-utils git zlib1g-dev python npm nodejs-legacy
+RUN docker-php-ext-install mbstring
+RUN docker-php-ext-install intl
+RUN docker-php-ext-install zip
+RUN npm install -g bower grunt-cli
+RUN a2enmod rewrite
+COPY php.ini /usr/local/etc/php/
+COPY . /var/www/html/
+RUN curl -sS https://getcomposer.org/installer | php
+RUN php composer.phar install
+RUN npm install
+RUN bower --allow-root install
+RUN grunt
diff --git a/Gruntfile.js b/Gruntfile.js
index 3fba1ac..9998185 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -29,7 +29,7 @@ module.exports = function (grunt) {
},
phpcs: {
php: {
- src: ['*.php']
+ src: ['*.php', 'classes/*.php', 'controllers/*.php']
},
tests: {
src: ['tests/*.php']
@@ -51,7 +51,7 @@ module.exports = function (grunt) {
options: {
archive: 'alltube-release.zip'
},
- src: ['*.php', '!config.php', 'dist/**', 'fonts/**', '.htaccess', 'img/**', 'js/**', 'LICENSE', 'README.md', 'robots.txt', 'sitemap.xml', 'templates/**', 'templates_c/', 'vendor/**']
+ src: ['*.php', '!config.yml', 'dist/**', 'fonts/**', '.htaccess', 'img/**', 'js/**', 'LICENSE', 'README.md', 'robots.txt', 'sitemap.xml', 'templates/**', 'templates_c/', 'vendor/**', 'classes/**', 'controllers/**', 'bower_components/**', '!vendor/ffmpeg/**', '!vendor/bin/ffmpeg']
}
}
}
@@ -67,5 +67,5 @@ module.exports = function (grunt) {
grunt.registerTask('default', ['uglify', 'cssmin']);
grunt.registerTask('lint', ['phpcs']);
grunt.registerTask('test', ['phpunit']);
- grunt.registerTask('release', ['compress']);
+ grunt.registerTask('release', ['default', 'compress']);
};
diff --git a/README.md b/README.md
index 76fd9f9..ea68dbf 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ You should also ensure that the *templates_c* folder has the right permissions:
If you want to use a custom config, you need to create a config file:
- cp config.example.php config.php
+ cp config.example.yml config.yml
##License
@@ -33,7 +33,7 @@ __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.
-If you don't want to enable conversions, you can disable it in *config.php*.
+If you don't want to enable conversions, you can disable it in *config.yml*.
On Debian-based systems:
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..f367807
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,6 @@
+{
+ "name": "alltube",
+ "dependencies": {
+ "opensans-googlefont": "*"
+ }
+}
diff --git a/classes/Config.php b/classes/Config.php
new file mode 100644
index 0000000..8cca186
--- /dev/null
+++ b/classes/Config.php
@@ -0,0 +1,65 @@
+
+ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
+ * @link http://rudloff.pro
+ * */
+namespace Alltube;
+use Symfony\Component\Yaml\Yaml;
+/**
+ * Class to manage config parameters
+ *
+ * PHP Version 5.3.10
+ *
+ * @category Youtube-dl
+ * @package Youtubedl
+ * @author Pierre Rudloff
+ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
+ * @link http://rudloff.pro
+ * */
+Class Config
+{
+ private static $_instance;
+
+ public $youtubedl = 'vendor/rg3/youtube-dl/youtube_dl/__main__.py';
+ public $python = '/usr/bin/python';
+ public $params = '--no-playlist --no-warnings -f best';
+ public $convert = false;
+ public $avconv = 'vendor/bin/ffmpeg';
+
+ /**
+ * Config constructor
+ */
+ private function __construct()
+ {
+ $yaml = Yaml::parse(__DIR__.'/../config.yml');
+ if (isset($yaml) && is_array($yaml)) {
+ foreach ($yaml as $param=>$value) {
+ if (isset($this->$param)) {
+ $this->$param = $value;
+ }
+ }
+ }
+ if (getenv('CONVERT')) {
+ $this->convert = getenv('CONVERT');
+ }
+ }
+
+ /**
+ * Get singleton instance
+ * @return Config
+ */
+ public static function getInstance()
+ {
+ if (is_null(self::$_instance)) {
+ self::$_instance = new Config();
+ }
+ return self::$_instance;
+ }
+}
diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php
index 5c362e7..3d18990 100644
--- a/classes/VideoDownload.php
+++ b/classes/VideoDownload.php
@@ -1,7 +1,6 @@
python.' '.$config->youtubedl.' --dump-user-agent',
$version
);
return $version[0];
@@ -47,8 +46,9 @@ Class VideoDownload
* */
static function listExtractors()
{
+ $config = Config::getInstance();
exec(
- PYTHON.' '.YOUTUBE_DL.' --list-extractors',
+ $config->python.' '.$config->youtubedl.' --list-extractors',
$extractors
);
return $extractors;
@@ -64,7 +64,8 @@ Class VideoDownload
* */
static function getFilename($url, $format=null)
{
- $cmd=PYTHON.' '.YOUTUBE_DL;
+ $config = Config::getInstance();
+ $cmd=$config->python.' '.$config->youtubedl;
if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format);
}
@@ -86,7 +87,8 @@ Class VideoDownload
* */
static function getJSON($url, $format=null)
{
- $cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
+ $config = Config::getInstance();
+ $cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format);
}
@@ -111,7 +113,8 @@ Class VideoDownload
* */
static function getURL($url, $format=null)
{
- $cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
+ $config = Config::getInstance();
+ $cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format);
}
diff --git a/common.php b/common.php
deleted file mode 100644
index ad61333..0000000
--- a/common.php
+++ /dev/null
@@ -1,21 +0,0 @@
-
- * @author Olivier Haquette
- * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
- * @link http://rudloff.pro
- * */
-require_once __DIR__.'/vendor/autoload.php';
-if (is_file('config.php')) {
- include_once 'config.php';
-} else {
- include_once 'config.example.php';
-}
-define('FILENAME', basename($_SERVER["SCRIPT_FILENAME"]));
diff --git a/composer.json b/composer.json
index 37259f8..359ee66 100644
--- a/composer.json
+++ b/composer.json
@@ -8,10 +8,13 @@
"smarty/smarty": "~3.1",
"rg3/youtube-dl": "2015.12.06",
"slim/slim": "~2.6.2",
- "slim/views": "~0.1.3"
+ "slim/views": "~0.1.3",
+ "rudloff/smarty-plugin-noscheme": "~0.1.0",
+ "symfony/yaml": "~3.0.0",
+ "ffmpeg/ffmpeg": "~2.8.2"
},
"require-dev": {
- "symfony/var-dumper": "~2.7.6"
+ "symfony/var-dumper": "~3.0.0"
},
"extra": {
"paas": {
@@ -32,6 +35,20 @@
"reference": "2015.12.06"
}
}
+ },
+ {
+ "type": "package",
+ "package": {
+ "name": "ffmpeg/ffmpeg",
+ "version": "2.8.2",
+ "dist": {
+ "url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz",
+ "type": "xz"
+ },
+ "bin": [
+ "ffmpeg"
+ ]
+ }
}
],
"authors": [
diff --git a/composer.lock b/composer.lock
index 055078e..516e8e3 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,9 +4,199 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "ddee3cb49e77224263b84bcdab2a5cef",
- "content-hash": "edd3cd78a8d70a2c889bf867d611c950",
+ "hash": "c7b053d687208446a7f7456623d6e888",
+ "content-hash": "2ed45cb5e9f8cb491d41f4272a543c5c",
"packages": [
+ {
+ "name": "ffmpeg/ffmpeg",
+ "version": "2.8.2",
+ "dist": {
+ "type": "xz",
+ "url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz",
+ "reference": null,
+ "shasum": null
+ },
+ "bin": [
+ "ffmpeg"
+ ],
+ "type": "library"
+ },
+ {
+ "name": "jeremykendall/php-domain-parser",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/jeremykendall/php-domain-parser.git",
+ "reference": "896e7e70f02bd4fd77190052799bc61e4d779672"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/jeremykendall/php-domain-parser/zipball/896e7e70f02bd4fd77190052799bc61e4d779672",
+ "reference": "896e7e70f02bd4fd77190052799bc61e4d779672",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-intl": "*",
+ "ext-mbstring": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "jeremykendall/debug-die": "0.0.1.*",
+ "mikey179/vfsstream": "~1.4",
+ "phpunit/phpunit": "~4.4"
+ },
+ "bin": [
+ "bin/parse",
+ "bin/update-psl"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Pdp\\": "src/"
+ },
+ "files": [
+ "src/pdp-parse-url.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jeremy Kendall",
+ "homepage": "http://about.me/jeremykendall",
+ "role": "Developer"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/jeremykendall/php-domain-parser/graphs/contributors"
+ }
+ ],
+ "description": "Public Suffix List based URL parsing implemented in PHP.",
+ "homepage": "https://github.com/jeremykendall/php-domain-parser",
+ "keywords": [
+ "Public Suffix List",
+ "domain parsing",
+ "url parsing"
+ ],
+ "time": "2015-03-30 12:49:45"
+ },
+ {
+ "name": "league/uri",
+ "version": "4.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/uri.git",
+ "reference": "671150fbd1d4120746195d6bec1aa78b95b14104"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/uri/zipball/671150fbd1d4120746195d6bec1aa78b95b14104",
+ "reference": "671150fbd1d4120746195d6bec1aa78b95b14104",
+ "shasum": ""
+ },
+ "require": {
+ "ext-fileinfo": "*",
+ "ext-intl": "*",
+ "ext-mbstring": "*",
+ "jeremykendall/php-domain-parser": "^3.0",
+ "php": ">=5.5.9",
+ "psr/http-message": "^1.0"
+ },
+ "require-dev": {
+ "fabpot/php-cs-fixer": "^1.9",
+ "phpunit/phpunit": "^4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "League\\Uri\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ignace Nyamagana Butera",
+ "email": "nyamsprod@gmail.com",
+ "homepage": "https://github.com/nyamsprod/",
+ "role": "Developer"
+ }
+ ],
+ "description": "URI manipulation library",
+ "homepage": "http://url.thephpleague.com",
+ "keywords": [
+ "data",
+ "data-uri",
+ "ftp",
+ "http",
+ "parse_url",
+ "psr-7",
+ "rfc3986",
+ "uri",
+ "url",
+ "ws"
+ ],
+ "time": "2015-11-03 07:54:30"
+ },
+ {
+ "name": "psr/http-message",
+ "version": "1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "time": "2015-05-04 20:22:00"
+ },
{
"name": "rg3/youtube-dl",
"version": "2015.12.06",
@@ -17,6 +207,42 @@
},
"type": "library"
},
+ {
+ "name": "rudloff/smarty-plugin-noscheme",
+ "version": "0.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Rudloff/smarty-plugin-noscheme.git",
+ "reference": "537bcb2f7576252af70d8f9f817bfe050d873072"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Rudloff/smarty-plugin-noscheme/zipball/537bcb2f7576252af70d8f9f817bfe050d873072",
+ "reference": "537bcb2f7576252af70d8f9f817bfe050d873072",
+ "shasum": ""
+ },
+ "require": {
+ "league/uri": "~4.0"
+ },
+ "require-dev": {
+ "symfony/var-dumper": "~2.7.6"
+ },
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "Pierre Rudloff",
+ "email": "contact@rudloff.pro",
+ "homepage": "https://rudloff.pro/",
+ "role": "Developer"
+ }
+ ],
+ "description": "Smarty modifier that removes the scheme in URLs",
+ "time": "2015-10-31 10:25:47"
+ },
{
"name": "slim/slim",
"version": "2.6.2",
@@ -170,25 +396,134 @@
"templating"
],
"time": "2015-06-18 00:55:59"
+ },
+ {
+ "name": "symfony/yaml",
+ "version": "v3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/yaml.git",
+ "reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002",
+ "reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Yaml\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Yaml Component",
+ "homepage": "https://symfony.com",
+ "time": "2015-11-30 12:36:17"
}
],
"packages-dev": [
{
- "name": "symfony/var-dumper",
- "version": "v2.7.7",
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.0.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/var-dumper.git",
- "reference": "72bcb27411780eaee9469729aace73c0d46fb2b8"
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "0b6a8940385311a24e060ec1fe35680e17c74497"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/var-dumper/zipball/72bcb27411780eaee9469729aace73c0d46fb2b8",
- "reference": "72bcb27411780eaee9469729aace73c0d46fb2b8",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497",
+ "reference": "0b6a8940385311a24e060ec1fe35680e17c74497",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2015-11-04 20:28:58"
+ },
+ {
+ "name": "symfony/var-dumper",
+ "version": "v3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/var-dumper.git",
+ "reference": "737e07704cca83f9dd0af926d45ce27eedc25657"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/var-dumper/zipball/737e07704cca83f9dd0af926d45ce27eedc25657",
+ "reference": "737e07704cca83f9dd0af926d45ce27eedc25657",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5.9",
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "require-dev": {
+ "twig/twig": "~1.20|~2.0"
},
"suggest": {
"ext-symfony_debug": ""
@@ -196,7 +531,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.7-dev"
+ "dev-master": "3.0-dev"
}
},
"autoload": {
@@ -230,7 +565,7 @@
"debug",
"dump"
],
- "time": "2015-11-18 13:41:01"
+ "time": "2015-11-18 13:48:51"
}
],
"aliases": [],
diff --git a/composer.phar b/composer.phar
new file mode 100755
index 0000000..c136a25
Binary files /dev/null and b/composer.phar differ
diff --git a/config.example.php b/config.example.php
deleted file mode 100644
index f26c490..0000000
--- a/config.example.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
- * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
- * @link http://rudloff.pro
- * */
-define('YOUTUBE_DL', __DIR__.'/vendor/rg3/youtube-dl/youtube_dl/__main__.py');
-define('PYTHON', '/usr/bin/python');
-define('PARAMS', '--no-playlist --no-warnings -f best');
-if (getenv('CONVERT')) {
- define('CONVERT', getenv('CONVERT'));
-} else {
- define('CONVERT', false);
-}
-define('AVCONV', __DIR__.'/ffmpeg/ffmpeg');
-define('MAINTENANCE', false);
-define('DISABLED', false);
diff --git a/config.example.yml b/config.example.yml
new file mode 100644
index 0000000..b0c7301
--- /dev/null
+++ b/config.example.yml
@@ -0,0 +1,5 @@
+youtubedl: vendor/rg3/youtube-dl/youtube_dl/__main__.py
+python: /usr/bin/python
+params: --no-playlist --no-warnings -f best
+convert: false
+avconv: vendor/bin/ffmpeg
diff --git a/controllers/FrontController.php b/controllers/FrontController.php
index a7f27f0..de3a8c3 100644
--- a/controllers/FrontController.php
+++ b/controllers/FrontController.php
@@ -1,10 +1,40 @@
+ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
+ * @link http://rudloff.pro
+ * */
namespace Alltube\Controller;
use Alltube\VideoDownload;
+use Alltube\Config;
+/**
+ * Main controller
+ *
+ * PHP Version 5.3.10
+ *
+ * @category Youtube-dl
+ * @package Youtubedl
+ * @author Pierre Rudloff
+ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
+ * @link http://rudloff.pro
+ * */
+class FrontController
+{
-class FrontController {
- static function index() {
+ /**
+ * Display index page
+ * @return void
+ */
+ static function index()
+ {
global $app;
+ $config = Config::getInstance();
$app->render(
'head.tpl',
array(
@@ -17,13 +47,18 @@ class FrontController {
$app->render(
'index.tpl',
array(
- 'convert'=>CONVERT
+ 'convert'=>$config->convert
)
);
$app->render('footer.tpl');
}
- static function extractors() {
+ /**
+ * Display a list of extractors
+ * @return void
+ */
+ static function extractors()
+ {
global $app;
$app->render(
'head.tpl',
@@ -42,8 +77,14 @@ class FrontController {
$app->render('footer.tpl');
}
- static function video() {
+ /**
+ * Dislay information about the video
+ * @return void
+ */
+ static function video()
+ {
global $app;
+ $config = Config::getInstance();
if (isset($_GET["url"])) {
if (isset($_GET['audio'])) {
try {
@@ -71,7 +112,8 @@ class FrontController {
header("Content-Type: audio/mpeg");
passthru(
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
- ' | '.AVCONV.' -v quiet -i - -f mp3 -vn pipe:1'
+ ' | '.$config->avconv.
+ ' -v quiet -i - -f mp3 -vn pipe:1'
);
exit;
} else {
@@ -90,7 +132,8 @@ class FrontController {
passthru(
'curl --user-agent '.escapeshellarg($UA).
' '.escapeshellarg($video->url).
- ' | '.AVCONV.' -v quiet -i - -f mp3 -vn pipe:1'
+ ' | '.$config->avconv.
+ ' -v quiet -i - -f mp3 -vn pipe:1'
);
exit;
}
@@ -134,4 +177,40 @@ class FrontController {
$app->render('footer.tpl');
}
}
+
+ /**
+ * Redirect to video file
+ * @return void
+ */
+ static function redirect()
+ {
+ global $app;
+ if (isset($_GET["url"])) {
+ try {
+ $video = VideoDownload::getURL($_GET["url"]);
+ $app->redirect($video['url']);
+ } catch (\Exception $e) {
+ $app->response->headers->set('Content-Type', 'text/plain');
+ echo $e->getMessage().PHP_EOL;
+ }
+ }
+ }
+
+ /**
+ * Output JSON info about the video
+ * @return void
+ */
+ static function json()
+ {
+ global $app;
+ if (isset($_GET["url"])) {
+ $app->response->headers->set('Content-Type', 'application/json');
+ try {
+ $video = VideoDownload::getJSON($_GET["url"]);
+ echo json_encode($video);
+ } catch (\Exception $e) {
+ echo json_encode(array('success'=>false, 'error'=>$e->getMessage()));
+ }
+ }
+ }
}
diff --git a/css/fonts.css b/css/fonts.css
index eff928c..1eb4f61 100644
--- a/css/fonts.css
+++ b/css/fonts.css
@@ -2,11 +2,11 @@
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
- src: local('Open Sans Light'), local('OpenSans-Light'), url(../fonts/OpenSans-Light.ttf);
+ src: local('Open Sans Light'), local('OpenSans-Light'), url(../bower_components/opensans-googlefont/OpenSans-Light.ttf);
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
- src: local('Open Sans'), local('OpenSans'), url(../fonts/OpenSans-Regular.ttf);
+ src: local('Open Sans'), local('OpenSans'), url(../bower_components/opensans-googlefont/OpenSans-Regular.ttf);
}
diff --git a/ffmpeg/.gitignore b/ffmpeg/.gitignore
deleted file mode 100644
index d6b7ef3..0000000
--- a/ffmpeg/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
diff --git a/fonts/OpenSans-Light.ttf b/fonts/OpenSans-Light.ttf
deleted file mode 100644
index 0d38189..0000000
Binary files a/fonts/OpenSans-Light.ttf and /dev/null differ
diff --git a/fonts/OpenSans-Regular.ttf b/fonts/OpenSans-Regular.ttf
deleted file mode 100644
index db43334..0000000
Binary files a/fonts/OpenSans-Regular.ttf and /dev/null differ
diff --git a/index.php b/index.php
index 83f92fc..181ffa0 100644
--- a/index.php
+++ b/index.php
@@ -12,8 +12,8 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
+require_once __DIR__.'/vendor/autoload.php';
use Alltube\VideoDownload;
-require_once 'common.php';
$app = new \Slim\Slim(
array(
@@ -23,7 +23,7 @@ $app = new \Slim\Slim(
$view = $app->view();
$view->parserExtensions = array(
__DIR__.'/vendor/slim/views/SmartyPlugins',
- __DIR__.'/smarty'
+ __DIR__.'/vendor/rudloff/smarty-plugin-noscheme/'
);
$app->get(
'/',
@@ -37,4 +37,12 @@ $app->get(
'/video',
array('Alltube\Controller\FrontController', 'video')
)->name('video');
+$app->get(
+ '/redirect',
+ array('Alltube\Controller\FrontController', 'redirect')
+);
+$app->get(
+ '/json',
+ array('Alltube\Controller\FrontController', 'json')
+);
$app->run();
diff --git a/json.php b/json.php
deleted file mode 100644
index 025c2a6..0000000
--- a/json.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
- * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
- * @link http://rudloff.pro
- * */
-use Alltube\VideoDownload;
-require_once 'common.php';
-if (isset($_GET["url"])) {
- header('Content-Type: application/json');
- try {
- $video = VideoDownload::getJSON($_GET["url"]);
- echo json_encode($video);
- } catch (Exception $e) {
- echo json_encode(array('success'=>false, 'error'=>$e->getMessage()));
- }
-}
diff --git a/package.json b/package.json
index cdb4e6e..21fdae7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "alltube",
- "version": "0.3.2",
+ "version": "0.4.2",
"dependencies": {
"grunt": "~0.4.5",
"grunt-cli": "~0.1.13",
@@ -9,7 +9,8 @@
"grunt-contrib-watch": "~0.6.1",
"grunt-phpcs": "~0.4.0",
"grunt-phpunit": "~0.3.6",
- "grunt-contrib-compress": "~0.13.0"
+ "grunt-contrib-compress": "~0.13.0",
+ "bower": "~1.6.3"
},
"engines": {
"node": "~0.10.29"
@@ -19,6 +20,6 @@
"url": "https://github.com/Rudloff/alltube.git"
},
"scripts": {
- "postinstall": "./node_modules/grunt-cli/bin/grunt; curl http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz -o ffmpeg.tar.xz; tar xJf ffmpeg.tar.xz -C ffmpeg --strip-components=1"
+ "postinstall": "./node_modules/bower/bin/bower install; ./node_modules/grunt-cli/bin/grunt"
}
}
diff --git a/php.ini b/php.ini
new file mode 100644
index 0000000..c3d7967
--- /dev/null
+++ b/php.ini
@@ -0,0 +1 @@
+date.timezone = UTC
diff --git a/phpunit.xml b/phpunit.xml
index 32420be..0288925 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,7 +1,7 @@
-
+
- download.php
+ classes/
diff --git a/redirect.php b/redirect.php
deleted file mode 100644
index c43f141..0000000
--- a/redirect.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
- * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
- * @link http://rudloff.pro
- * */
-require_once 'common.php';
-require_once 'download.php';
-if (isset($_GET["url"])) {
- try {
- $video = VideoDownload::getURL($_GET["url"]);
- header('Location: '.$video['url']);
- } catch (Exception $e) {
- header('Content-Type: text/plain');
- echo $e->getMessage();
- }
-}
diff --git a/sitemap.xml b/sitemap.xml
index b7b9248..9d3433b 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -6,7 +6,7 @@
1
- http://alltubedownload.net/extractors.php
+ http://alltubedownload.net/extractors
weekly
diff --git a/smarty/modifier.noscheme.php b/smarty/modifier.noscheme.php
deleted file mode 100644
index b92adc1..0000000
--- a/smarty/modifier.noscheme.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
+
AllTube Download
-
-
-
+
+
+
+
-
+
-
+
diff --git a/templates/index.tpl b/templates/index.tpl
index 480cfef..ce0964d 100644
--- a/templates/index.tpl
+++ b/templates/index.tpl
@@ -1,5 +1,5 @@
diff --git a/templates/logo.tpl b/templates/logo.tpl
index dcf538c..517fb3d 100644
--- a/templates/logo.tpl
+++ b/templates/logo.tpl
@@ -1,4 +1,4 @@
diff --git a/templates/video.tpl b/templates/video.tpl
index 0142c8a..c899966 100644
--- a/templates/video.tpl
+++ b/templates/video.tpl
@@ -9,16 +9,18 @@
href="{$video->webpage_url}">
{$video->title}.
-
-
+{if isset($video->thumbnail)}
+
+{/if}
diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php
new file mode 100644
index 0000000..75b59e9
--- /dev/null
+++ b/tests/ConfigTest.php
@@ -0,0 +1,39 @@
+
+ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
+ * @link http://rudloff.pro
+ * */
+use Alltube\Config;
+
+/**
+ * Unit tests for the Config class
+ *
+ * PHP Version 5.3.10
+ *
+ * @category Youtube-dl
+ * @package Youtubedl
+ * @author Pierre Rudloff
+ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
+ * @link http://rudloff.pro
+ * */
+class ConfigTest extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Test the getInstance function
+ * @return void
+ */
+ public function testGetInstance()
+ {
+ putenv('CONVERT=1');
+ $config = Config::getInstance();
+ $this->assertEquals($config->convert, true);
+ }
+}
diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php
index 193cc2d..fc84cf7 100644
--- a/tests/VideoDownloadTest.php
+++ b/tests/VideoDownloadTest.php
@@ -11,7 +11,6 @@
* @link http://rudloff.pro
* */
use Alltube\VideoDownload;
-require_once __DIR__.'/../common.php';
/**
* Unit tests for the VideoDownload class
@@ -80,7 +79,7 @@ class VideoDownloadTest extends PHPUnit_Framework_TestCase
/**
* Provides URLs for tests
*
- * @return void
+ * @return array
*/
public function urlProvider()
{
@@ -104,7 +103,7 @@ class VideoDownloadTest extends PHPUnit_Framework_TestCase
/**
* Provides incorrect URLs for tests
*
- * @return void
+ * @return array
*/
public function errorUrlProvider()
{