Merge branch 'develop' of github.com:Rudloff/alltube into develop

Conflicts:
	composer.json
	composer.lock
This commit is contained in:
Pierre Rudloff 2015-12-09 10:47:30 +01:00
commit 1bdc3383b9
34 changed files with 640 additions and 159 deletions

1
.dockerignore Symbolic link
View file

@ -0,0 +1 @@
.gitignore

2
.gitignore vendored
View file

@ -8,3 +8,5 @@ ffmpeg.tar.xz
ffmpeg-*/ ffmpeg-*/
alltube-release.zip alltube-release.zip
coverage/ coverage/
bower_components/
config.yml

View file

@ -2,3 +2,5 @@ language: php
install: install:
- composer install - composer install
- npm install - npm install
before_install:
- composer selfupdate

15
Dockerfile Normal file
View file

@ -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

View file

@ -29,7 +29,7 @@ module.exports = function (grunt) {
}, },
phpcs: { phpcs: {
php: { php: {
src: ['*.php'] src: ['*.php', 'classes/*.php', 'controllers/*.php']
}, },
tests: { tests: {
src: ['tests/*.php'] src: ['tests/*.php']
@ -51,7 +51,7 @@ module.exports = function (grunt) {
options: { options: {
archive: 'alltube-release.zip' 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('default', ['uglify', 'cssmin']);
grunt.registerTask('lint', ['phpcs']); grunt.registerTask('lint', ['phpcs']);
grunt.registerTask('test', ['phpunit']); grunt.registerTask('test', ['phpunit']);
grunt.registerTask('release', ['compress']); grunt.registerTask('release', ['default', 'compress']);
}; };

View file

@ -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: 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 ##License
@ -33,7 +33,7 @@ __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) 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: On Debian-based systems:

6
bower.json Normal file
View file

@ -0,0 +1,6 @@
{
"name": "alltube",
"dependencies": {
"opensans-googlefont": "*"
}
}

65
classes/Config.php Normal file
View file

@ -0,0 +1,65 @@
<?php
/**
* Config class
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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 <contact@rudloff.pro>
* @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;
}
}

View file

@ -1,7 +1,6 @@
<?php <?php
/** /**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/) * VideoDownload class
* Main class
* *
* PHP Version 5.3.10 * PHP Version 5.3.10
* *
@ -13,7 +12,6 @@
* */ * */
namespace Alltube; namespace Alltube;
/** /**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* Main class * Main class
* *
* PHP Version 5.3.10 * PHP Version 5.3.10
@ -33,8 +31,9 @@ Class VideoDownload
* */ * */
static function getUA() static function getUA()
{ {
$config = Config::getInstance();
exec( exec(
PYTHON.' '.YOUTUBE_DL.' --dump-user-agent', $config->python.' '.$config->youtubedl.' --dump-user-agent',
$version $version
); );
return $version[0]; return $version[0];
@ -47,8 +46,9 @@ Class VideoDownload
* */ * */
static function listExtractors() static function listExtractors()
{ {
$config = Config::getInstance();
exec( exec(
PYTHON.' '.YOUTUBE_DL.' --list-extractors', $config->python.' '.$config->youtubedl.' --list-extractors',
$extractors $extractors
); );
return $extractors; return $extractors;
@ -64,7 +64,8 @@ Class VideoDownload
* */ * */
static function getFilename($url, $format=null) static function getFilename($url, $format=null)
{ {
$cmd=PYTHON.' '.YOUTUBE_DL; $config = Config::getInstance();
$cmd=$config->python.' '.$config->youtubedl;
if (isset($format)) { if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format); $cmd .= ' -f '.escapeshellarg($format);
} }
@ -86,7 +87,8 @@ Class VideoDownload
* */ * */
static function getJSON($url, $format=null) static function getJSON($url, $format=null)
{ {
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS; $config = Config::getInstance();
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
if (isset($format)) { if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format); $cmd .= ' -f '.escapeshellarg($format);
} }
@ -111,7 +113,8 @@ Class VideoDownload
* */ * */
static function getURL($url, $format=null) static function getURL($url, $format=null)
{ {
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS; $config = Config::getInstance();
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
if (isset($format)) { if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format); $cmd .= ' -f '.escapeshellarg($format);
} }

View file

@ -1,21 +0,0 @@
<?php
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* PHP file included on all pages
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @author Olivier Haquette <contact@olivierhaquette.fr>
* @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"]));

View file

@ -8,10 +8,13 @@
"smarty/smarty": "~3.1", "smarty/smarty": "~3.1",
"rg3/youtube-dl": "2015.12.06", "rg3/youtube-dl": "2015.12.06",
"slim/slim": "~2.6.2", "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": { "require-dev": {
"symfony/var-dumper": "~2.7.6" "symfony/var-dumper": "~3.0.0"
}, },
"extra": { "extra": {
"paas": { "paas": {
@ -32,6 +35,20 @@
"reference": "2015.12.06" "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": [ "authors": [

357
composer.lock generated
View file

@ -4,9 +4,199 @@
"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": "ddee3cb49e77224263b84bcdab2a5cef", "hash": "c7b053d687208446a7f7456623d6e888",
"content-hash": "edd3cd78a8d70a2c889bf867d611c950", "content-hash": "2ed45cb5e9f8cb491d41f4272a543c5c",
"packages": [ "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", "name": "rg3/youtube-dl",
"version": "2015.12.06", "version": "2015.12.06",
@ -17,6 +207,42 @@
}, },
"type": "library" "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", "name": "slim/slim",
"version": "2.6.2", "version": "2.6.2",
@ -170,25 +396,134 @@
"templating" "templating"
], ],
"time": "2015-06-18 00:55:59" "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": [ "packages-dev": [
{ {
"name": "symfony/var-dumper", "name": "symfony/polyfill-mbstring",
"version": "v2.7.7", "version": "v1.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "72bcb27411780eaee9469729aace73c0d46fb2b8" "reference": "0b6a8940385311a24e060ec1fe35680e17c74497"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/72bcb27411780eaee9469729aace73c0d46fb2b8", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497",
"reference": "72bcb27411780eaee9469729aace73c0d46fb2b8", "reference": "0b6a8940385311a24e060ec1fe35680e17c74497",
"shasum": "" "shasum": ""
}, },
"require": { "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": { "suggest": {
"ext-symfony_debug": "" "ext-symfony_debug": ""
@ -196,7 +531,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.7-dev" "dev-master": "3.0-dev"
} }
}, },
"autoload": { "autoload": {
@ -230,7 +565,7 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2015-11-18 13:41:01" "time": "2015-11-18 13:48:51"
} }
], ],
"aliases": [], "aliases": [],

BIN
composer.phar Executable file

Binary file not shown.

View file

@ -1,24 +0,0 @@
<?php
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* Config file
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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);

5
config.example.yml Normal file
View file

@ -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

View file

@ -1,10 +1,40 @@
<?php <?php
/**
* FrontController class
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
namespace Alltube\Controller; namespace Alltube\Controller;
use Alltube\VideoDownload; use Alltube\VideoDownload;
use Alltube\Config;
/**
* Main controller
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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; global $app;
$config = Config::getInstance();
$app->render( $app->render(
'head.tpl', 'head.tpl',
array( array(
@ -17,13 +47,18 @@ class FrontController {
$app->render( $app->render(
'index.tpl', 'index.tpl',
array( array(
'convert'=>CONVERT 'convert'=>$config->convert
) )
); );
$app->render('footer.tpl'); $app->render('footer.tpl');
} }
static function extractors() { /**
* Display a list of extractors
* @return void
*/
static function extractors()
{
global $app; global $app;
$app->render( $app->render(
'head.tpl', 'head.tpl',
@ -42,8 +77,14 @@ class FrontController {
$app->render('footer.tpl'); $app->render('footer.tpl');
} }
static function video() { /**
* Dislay information about the video
* @return void
*/
static function video()
{
global $app; global $app;
$config = Config::getInstance();
if (isset($_GET["url"])) { if (isset($_GET["url"])) {
if (isset($_GET['audio'])) { if (isset($_GET['audio'])) {
try { try {
@ -71,7 +112,8 @@ class FrontController {
header("Content-Type: audio/mpeg"); header("Content-Type: audio/mpeg");
passthru( passthru(
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url). '/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; exit;
} else { } else {
@ -90,7 +132,8 @@ class FrontController {
passthru( passthru(
'curl --user-agent '.escapeshellarg($UA). 'curl --user-agent '.escapeshellarg($UA).
' '.escapeshellarg($video->url). ' '.escapeshellarg($video->url).
' | '.AVCONV.' -v quiet -i - -f mp3 -vn pipe:1' ' | '.$config->avconv.
' -v quiet -i - -f mp3 -vn pipe:1'
); );
exit; exit;
} }
@ -134,4 +177,40 @@ class FrontController {
$app->render('footer.tpl'); $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()));
}
}
}
} }

View file

@ -2,11 +2,11 @@
font-family: 'Open Sans'; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 300; 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-face {
font-family: 'Open Sans'; font-family: 'Open Sans';
font-style: normal; font-style: normal;
font-weight: 400; 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);
} }

2
ffmpeg/.gitignore vendored
View file

@ -1,2 +0,0 @@
*
!.gitignore

Binary file not shown.

Binary file not shown.

View file

@ -12,8 +12,8 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html * @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro * @link http://rudloff.pro
* */ * */
require_once __DIR__.'/vendor/autoload.php';
use Alltube\VideoDownload; use Alltube\VideoDownload;
require_once 'common.php';
$app = new \Slim\Slim( $app = new \Slim\Slim(
array( array(
@ -23,7 +23,7 @@ $app = new \Slim\Slim(
$view = $app->view(); $view = $app->view();
$view->parserExtensions = array( $view->parserExtensions = array(
__DIR__.'/vendor/slim/views/SmartyPlugins', __DIR__.'/vendor/slim/views/SmartyPlugins',
__DIR__.'/smarty' __DIR__.'/vendor/rudloff/smarty-plugin-noscheme/'
); );
$app->get( $app->get(
'/', '/',
@ -37,4 +37,12 @@ $app->get(
'/video', '/video',
array('Alltube\Controller\FrontController', 'video') array('Alltube\Controller\FrontController', 'video')
)->name('video'); )->name('video');
$app->get(
'/redirect',
array('Alltube\Controller\FrontController', 'redirect')
);
$app->get(
'/json',
array('Alltube\Controller\FrontController', 'json')
);
$app->run(); $app->run();

View file

@ -1,24 +0,0 @@
<?php
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* JSON API
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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()));
}
}

View file

@ -1,6 +1,6 @@
{ {
"name": "alltube", "name": "alltube",
"version": "0.3.2", "version": "0.4.2",
"dependencies": { "dependencies": {
"grunt": "~0.4.5", "grunt": "~0.4.5",
"grunt-cli": "~0.1.13", "grunt-cli": "~0.1.13",
@ -9,7 +9,8 @@
"grunt-contrib-watch": "~0.6.1", "grunt-contrib-watch": "~0.6.1",
"grunt-phpcs": "~0.4.0", "grunt-phpcs": "~0.4.0",
"grunt-phpunit": "~0.3.6", "grunt-phpunit": "~0.3.6",
"grunt-contrib-compress": "~0.13.0" "grunt-contrib-compress": "~0.13.0",
"bower": "~1.6.3"
}, },
"engines": { "engines": {
"node": "~0.10.29" "node": "~0.10.29"
@ -19,6 +20,6 @@
"url": "https://github.com/Rudloff/alltube.git" "url": "https://github.com/Rudloff/alltube.git"
}, },
"scripts": { "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"
} }
} }

1
php.ini Normal file
View file

@ -0,0 +1 @@
date.timezone = UTC

View file

@ -1,7 +1,7 @@
<phpunit> <phpunit bootstrap="vendor/autoload.php">
<filter> <filter>
<whitelist> <whitelist>
<file>download.php</file> <directory>classes/</directory>
</whitelist> </whitelist>
</filter> </filter>
<testsuites> <testsuites>

View file

@ -1,24 +0,0 @@
<?php
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* Redirect to video in best format
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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();
}
}

View file

@ -6,7 +6,7 @@
<priority>1</priority> <priority>1</priority>
</url> </url>
<url> <url>
<loc>http://alltubedownload.net/extractors.php</loc> <loc>http://alltubedownload.net/extractors</loc>
<changefreq>weekly</changefreq> <changefreq>weekly</changefreq>
</url> </url>
</urlset> </urlset>

View file

@ -1,5 +0,0 @@
<?php
function smarty_modifier_noscheme($url) {
$info = parse_url($url);
return '//'.$info['host'].$info['path'];
}

View file

@ -4,24 +4,25 @@
<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." /> <meta name="description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<link rel="stylesheet" href="{siteUrl url='dist/main.css'}" /> <link rel="stylesheet" href="{siteUrl|noscheme url='dist/main.css'}" />
<link rel="author" href="https://plus.google.com/110403274854419000481?rel=author" /> <link rel="author" href="https://plus.google.com/110403274854419000481?rel=author" />
<link rel="author" href="https://plus.google.com/103696815796116179392?rel=author" /> <link rel="author" href="https://plus.google.com/103696815796116179392?rel=author" />
<link href="https://plus.google.com/108799967445657477255" rel="publisher" /> <link href="https://plus.google.com/108799967445657477255" rel="publisher" />
<title itemprop="name">AllTube Download</title> <title itemprop="name">AllTube Download</title>
<meta itemprop="url" content="http://alltubedownload.net/" /> <meta itemprop="url" content="{siteUrl}" />
<link rel="icon" href="{siteUrl url='img/favicon.png'}" /> <link rel="canonical" href="{currentUrl|replace:{siteUrl}:'http://www.alltubedownload.net/'}" />
<meta property="og:url" content="http://www.alltubedownload.net/" /> <link rel="icon" href="{siteUrl|noscheme url='img/favicon.png'}" />
<meta property="og:url" content="{siteUrl}" />
<meta property="og:title" content="AllTube Download" /> <meta property="og:title" content="AllTube Download" />
<meta property="og:description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." /> <meta property="og:description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
<meta property="og:image" content="http://www.alltubedownload.net/img/logo.png" /> <meta property="og:image" content="{siteUrl url='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" />
<meta name="twitter:image" content="{siteUrl url='img/logo.png'}" /> <meta name="twitter:image" content="{siteUrl 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." /> <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>
<script src="dist/main.js"></script> <script src="{siteUrl|noscheme url='dist/main.js'}"></script>
<meta itemprop="applicationCategory" content="Download" /> <meta itemprop="applicationCategory" content="Download" />
<meta itemprop="operatingSystem" content="Linux" /> <meta itemprop="operatingSystem" content="Linux" />
<meta itemprop="operatingSystem" content="Mac OS X" /> <meta itemprop="operatingSystem" content="Mac OS X" />

View file

@ -1,5 +1,5 @@
<div class="main"> <div class="main">
<div><img itemprop="image" class="logo" src="{siteUrl url='img/logo.png'}" <div><img itemprop="image" class="logo" src="{siteUrl|noscheme url='img/logo.png'}"
alt="AllTube Download" width="328" height="284"></div> alt="AllTube Download" width="328" height="284"></div>
<form action="{urlFor name="video"}"> <form action="{urlFor name="video"}">
<label class="labelurl" for="url"> <label class="labelurl" for="url">
@ -23,7 +23,7 @@
<a class="combatiblelink" href="{urlFor name="extractors"}">See all supported websites</a> <a class="combatiblelink" href="{urlFor name="extractors"}">See all supported websites</a>
<div id="bookmarklet"> <div id="bookmarklet">
<p> Drag this to your bookmarks bar: </p> <p> Drag this to your bookmarks bar: </p>
<a class="bookmarklet" href="javascript:window.location='{siteUrl withUri=false url='img/logo.png'}{urlFor name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a> <a class="bookmarklet" href="javascript:window.location='{siteUrl withUri=false}{urlFor name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
</div> </div>
</div> </div>

View file

@ -1,4 +1,4 @@
<h1 class="logobis"> <h1 class="logobis">
<a class="logocompatible" href="{siteUrl}"> <a class="logocompatible" href="{siteUrl}">
AllTube Download<span class="logocompatiblemask"><img src="{siteUrl url='img/logocompatiblemask.png'}" width="447" height="107" alt="" /></span> AllTube Download<span class="logocompatiblemask"><img src="{siteUrl|noscheme url='img/logocompatiblemask.png'}" width="447" height="107" alt="" /></span>
</a></h1> </a></h1>

View file

@ -9,16 +9,18 @@
href="{$video->webpage_url}"> href="{$video->webpage_url}">
{$video->title}</a></i>. {$video->title}</a></i>.
<img class="cast_icon" id="cast_disabled" <img class="cast_icon" id="cast_disabled"
src="{siteUrl url='img/ic_media_route_disabled_holo_light.png'}" src="{siteUrl|noscheme url='img/ic_media_route_disabled_holo_light.png'}"
alt="Google Cast™ is disabled" alt="Google Cast™ is disabled"
title="Google Cast is not supported on this browser." /> title="Google Cast is not supported on this browser." />
<img class="cast_btn cast_hidden cast_icon" id="cast_btn_launch" <img class="cast_btn cast_hidden cast_icon" id="cast_btn_launch"
src="{siteUrl url='img/ic_media_route_off_holo_light.png'}" src="{siteUrl|noscheme url='img/ic_media_route_off_holo_light.png'}"
title="Cast to ChromeCast" alt="Google Cast™" /> title="Cast to ChromeCast" alt="Google Cast™" />
<img src="{siteUrl url='img/ic_media_route_on_holo_light.png'}" <img src="{siteUrl|noscheme url='img/ic_media_route_on_holo_light.png'}"
alt="Casting to ChromeCast…" title="Stop casting" alt="Casting to ChromeCast…" title="Stop casting"
id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" /></p> id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" /></p>
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" /> {if isset($video->thumbnail)}
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" />
{/if}
<br/> <br/>
<input type="hidden" name="url" <input type="hidden" name="url"
value="{$video->webpage_url}" /> value="{$video->webpage_url}" />

39
tests/ConfigTest.php Normal file
View file

@ -0,0 +1,39 @@
<?php
/**
* ConfigTest class
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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 <contact@rudloff.pro>
* @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);
}
}

View file

@ -11,7 +11,6 @@
* @link http://rudloff.pro * @link http://rudloff.pro
* */ * */
use Alltube\VideoDownload; use Alltube\VideoDownload;
require_once __DIR__.'/../common.php';
/** /**
* Unit tests for the VideoDownload class * Unit tests for the VideoDownload class
@ -80,7 +79,7 @@ class VideoDownloadTest extends PHPUnit_Framework_TestCase
/** /**
* Provides URLs for tests * Provides URLs for tests
* *
* @return void * @return array
*/ */
public function urlProvider() public function urlProvider()
{ {
@ -104,7 +103,7 @@ class VideoDownloadTest extends PHPUnit_Framework_TestCase
/** /**
* Provides incorrect URLs for tests * Provides incorrect URLs for tests
* *
* @return void * @return array
*/ */
public function errorUrlProvider() public function errorUrlProvider()
{ {