Merge branch 'release-0.4.0'
This commit is contained in:
commit
4b127599da
43 changed files with 1199 additions and 576 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -7,3 +7,6 @@ templates_c/
|
|||
ffmpeg.tar.xz
|
||||
ffmpeg-*/
|
||||
alltube-release.zip
|
||||
coverage/
|
||||
bower_components/
|
||||
config.yml
|
||||
|
|
17
.htaccess
17
.htaccess
|
@ -1,8 +1,13 @@
|
|||
AddType application/x-web-app-manifest+json .webapp
|
||||
ExpiresActive On
|
||||
ExpiresByType application/javascript "access plus 1 week"
|
||||
ExpiresByType text/css "access plus 1 week"
|
||||
ExpiresByType image/png "access plus 1 week"
|
||||
ExpiresByType image/jpeg "access plus 1 week"
|
||||
ExpiresByType image/svg+xml "access plus 1 week"
|
||||
<ifmodule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresByType application/javascript "access plus 1 week"
|
||||
ExpiresByType text/css "access plus 1 week"
|
||||
ExpiresByType image/png "access plus 1 week"
|
||||
ExpiresByType image/jpeg "access plus 1 week"
|
||||
ExpiresByType image/svg+xml "access plus 1 week"
|
||||
</ifmodule>
|
||||
FileETag None
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
language: php
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
install:
|
||||
- composer install
|
||||
- npm install
|
||||
script: phpunit tests/
|
||||
|
|
12
Gruntfile.js
12
Gruntfile.js
|
@ -29,7 +29,7 @@ module.exports = function (grunt) {
|
|||
},
|
||||
phpcs: {
|
||||
php: {
|
||||
src: ['*.php']
|
||||
src: ['*.php', 'classes/*.php', 'controllers/*.php']
|
||||
},
|
||||
tests: {
|
||||
src: ['tests/*.php']
|
||||
|
@ -45,6 +45,14 @@ module.exports = function (grunt) {
|
|||
classes: {
|
||||
dir: 'tests/'
|
||||
}
|
||||
},
|
||||
compress: {
|
||||
release: {
|
||||
options: {
|
||||
archive: 'alltube-release.zip'
|
||||
},
|
||||
src: ['*.php', '!config.yml', 'dist/**', 'fonts/**', '.htaccess', 'img/**', 'js/**', 'LICENSE', 'README.md', 'robots.txt', 'sitemap.xml', 'templates/**', 'templates_c/', 'vendor/**', 'classes/**', 'controllers/**', 'bower_components/**']
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -54,8 +62,10 @@ module.exports = function (grunt) {
|
|||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-phpcs');
|
||||
grunt.loadNpmTasks('grunt-phpunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-compress');
|
||||
|
||||
grunt.registerTask('default', ['uglify', 'cssmin']);
|
||||
grunt.registerTask('lint', ['phpcs']);
|
||||
grunt.registerTask('test', ['phpunit']);
|
||||
grunt.registerTask('release', ['default', 'compress']);
|
||||
};
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
84
api.php
84
api.php
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
*
|
||||
* 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';
|
||||
$smarty->assign('class', 'video');
|
||||
require_once 'download.php';
|
||||
if (isset($_GET["url"])) {
|
||||
if (isset($_GET['audio'])) {
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
|
||||
if (isset($video->url)) {
|
||||
//Vimeo needs a correct user-agent
|
||||
$UA = VideoDownload::getUA();
|
||||
ini_set(
|
||||
'user_agent',
|
||||
$UA
|
||||
);
|
||||
$url_info = parse_url($video->url);
|
||||
if ($url_info['scheme'] == 'rtmp') {
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="'.
|
||||
html_entity_decode(
|
||||
pathinfo(
|
||||
VideoDownload::getFilename(
|
||||
$video->webpage_url
|
||||
), PATHINFO_FILENAME
|
||||
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
||||
).'"'
|
||||
);
|
||||
header("Content-Type: audio/mpeg");
|
||||
passthru(
|
||||
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
|
||||
' | '.AVCONV.' -v quiet -i - -f mp3 -vn pipe:1'
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="'.
|
||||
html_entity_decode(
|
||||
pathinfo(
|
||||
VideoDownload::getFilename(
|
||||
$video->webpage_url
|
||||
), PATHINFO_FILENAME
|
||||
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
||||
).'"'
|
||||
);
|
||||
header("Content-Type: audio/mpeg");
|
||||
passthru(
|
||||
'curl --user-agent '.escapeshellarg($UA).
|
||||
' '.escapeshellarg($video->url).
|
||||
' | '.AVCONV.' -v quiet -i - -f mp3 -vn pipe:1'
|
||||
);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$error=true;
|
||||
}
|
||||
} else {
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
if (isset($video->webpage_url)) {
|
||||
$smarty->display('head.tpl');
|
||||
$smarty->assign('video', $video);
|
||||
$smarty->display('video.tpl');
|
||||
$smarty->display('footer.tpl');
|
||||
} else {
|
||||
$error=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($error)) {
|
||||
$smarty->display('head.tpl');
|
||||
$smarty->assign('errors', $video['error']);
|
||||
$smarty->display('error.tpl');
|
||||
$smarty->display('footer.tpl');
|
||||
}
|
6
bower.json
Normal file
6
bower.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "alltube",
|
||||
"dependencies": {
|
||||
"opensans-googlefont": "*"
|
||||
}
|
||||
}
|
65
classes/Config.php
Normal file
65
classes/Config.php
Normal 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 = 'ffmpeg/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;
|
||||
}
|
||||
}
|
132
classes/VideoDownload.php
Normal file
132
classes/VideoDownload.php
Normal file
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
/**
|
||||
* VideoDownload 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;
|
||||
/**
|
||||
* Main 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 VideoDownload
|
||||
{
|
||||
/**
|
||||
* Get the user agent used youtube-dl
|
||||
*
|
||||
* @return string UA
|
||||
* */
|
||||
static function getUA()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
exec(
|
||||
$config->python.' '.$config->youtubedl.' --dump-user-agent',
|
||||
$version
|
||||
);
|
||||
return $version[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all extractors
|
||||
*
|
||||
* @return array Extractors
|
||||
* */
|
||||
static function listExtractors()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
exec(
|
||||
$config->python.' '.$config->youtubedl.' --list-extractors',
|
||||
$extractors
|
||||
);
|
||||
return $extractors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename of video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string Filename
|
||||
* */
|
||||
static function getFilename($url, $format=null)
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$cmd=$config->python.' '.$config->youtubedl;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
$cmd .=' --get-filename '.escapeshellarg($url)." 2>&1";
|
||||
exec(
|
||||
$cmd,
|
||||
$filename
|
||||
);
|
||||
return end($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all information about a video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string JSON
|
||||
* */
|
||||
static function getJSON($url, $format=null)
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
$cmd .=' --dump-json '.escapeshellarg($url)." 2>&1";
|
||||
exec(
|
||||
$cmd, $result, $code
|
||||
);
|
||||
if ($code>0) {
|
||||
throw new \Exception(implode(PHP_EOL, $result));
|
||||
} else {
|
||||
return json_decode($result[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL of video from URL of page
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string URL of video
|
||||
* */
|
||||
static function getURL($url, $format=null)
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
$cmd .=' -g '.escapeshellarg($url)." 2>&1";
|
||||
exec(
|
||||
$cmd, $result, $code
|
||||
);
|
||||
if ($code>0) {
|
||||
throw new \Exception(implode(PHP_EOL, $result));
|
||||
} else {
|
||||
return array('success'=>true, 'url'=>end($result));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
33
common.php
33
common.php
|
@ -1,33 +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"]));
|
||||
if (DISABLED && FILENAME != 'disabled.php') {
|
||||
header('Location: disabled.php'); exit;
|
||||
} else if (MAINTENANCE && FILENAME != 'maintenance.php') {
|
||||
header('Location: maintenance.php'); exit;
|
||||
}
|
||||
$smarty = new Smarty();
|
||||
$smarty->assign(
|
||||
array(
|
||||
'base_url'=>BASE_URL,
|
||||
'convert'=>CONVERT
|
||||
)
|
||||
);
|
|
@ -5,7 +5,15 @@
|
|||
"homepage": "http://alltubedownload.net/",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"smarty/smarty": "~3.1"
|
||||
"smarty/smarty": "~3.1",
|
||||
"rg3/youtube-dl": "2015.10.24",
|
||||
"slim/slim": "~2.6.2",
|
||||
"slim/views": "~0.1.3",
|
||||
"rudloff/smarty-plugin-noscheme": "~0.1.0",
|
||||
"symfony/yaml": "~2.7.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/var-dumper": "~2.7.6"
|
||||
},
|
||||
"extra": {
|
||||
"paas": {
|
||||
|
@ -14,6 +22,20 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "rg3/youtube-dl",
|
||||
"version": "2015.10.24",
|
||||
"source": {
|
||||
"url": "https://github.com/rg3/youtube-dl.git",
|
||||
"type": "git",
|
||||
"reference": "2015.10.24"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Pierre Rudloff",
|
||||
|
@ -21,5 +43,11 @@
|
|||
"homepage": "https://rudloff.pro/",
|
||||
"role": "Developer"
|
||||
}
|
||||
]
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Alltube\\": "classes/",
|
||||
"Alltube\\Controller\\": "controllers/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
429
composer.lock
generated
429
composer.lock
generated
|
@ -1,11 +1,331 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://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"
|
||||
],
|
||||
"hash": "1d95265fc34ff6df149985554a8ba0d6",
|
||||
"hash": "a7e5944a818030d017d39d13b9ec0ffd",
|
||||
"content-hash": "2d61af9410d3e5f69fa0d6a956210a83",
|
||||
"packages": [
|
||||
{
|
||||
"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.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/uri.git",
|
||||
"reference": "a22120c5937814dbadaffccef32bf11040f46c0b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/uri/zipball/a22120c5937814dbadaffccef32bf11040f46c0b",
|
||||
"reference": "a22120c5937814dbadaffccef32bf11040f46c0b",
|
||||
"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": [
|
||||
"ftp",
|
||||
"http",
|
||||
"parse_url",
|
||||
"psr-7",
|
||||
"rfc3986",
|
||||
"uri",
|
||||
"url",
|
||||
"ws"
|
||||
],
|
||||
"time": "2015-09-23 11:09:45"
|
||||
},
|
||||
{
|
||||
"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.10.24",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rg3/youtube-dl.git",
|
||||
"reference": "2015.10.24"
|
||||
},
|
||||
"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",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slimphp/Slim.git",
|
||||
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim/zipball/20a02782f76830b67ae56a5c08eb1f563c351a37",
|
||||
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mcrypt": "Required for HTTP cookie encryption"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Slim": "."
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Josh Lockhart",
|
||||
"email": "info@joshlockhart.com",
|
||||
"homepage": "http://www.joshlockhart.com/"
|
||||
}
|
||||
],
|
||||
"description": "Slim Framework, a PHP micro framework",
|
||||
"homepage": "http://github.com/codeguy/Slim",
|
||||
"keywords": [
|
||||
"microframework",
|
||||
"rest",
|
||||
"router"
|
||||
],
|
||||
"time": "2015-03-08 18:41:17"
|
||||
},
|
||||
{
|
||||
"name": "slim/views",
|
||||
"version": "0.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slimphp/Slim-Views.git",
|
||||
"reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim-Views/zipball/8561c785e55a39df6cb6f95c3aba3281a60ed5b0",
|
||||
"reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"slim/slim": ">=2.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"smarty/smarty": "Smarty templating system",
|
||||
"twig/twig": "Twig templating system"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Slim\\Views\\": "./"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Josh Lockhart",
|
||||
"email": "info@joshlockhart.com",
|
||||
"homepage": "http://www.joshlockhart.com/"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Smith",
|
||||
"email": "a.smith@silentworks.co.uk",
|
||||
"homepage": "http://thoughts.silentworks.co.uk/"
|
||||
}
|
||||
],
|
||||
"description": "Smarty and Twig View Parser package for the Slim Framework",
|
||||
"homepage": "http://github.com/codeguy/Slim-Views",
|
||||
"keywords": [
|
||||
"extensions",
|
||||
"slimphp",
|
||||
"templating"
|
||||
],
|
||||
"time": "2014-12-09 23:48:51"
|
||||
},
|
||||
{
|
||||
"name": "smarty/smarty",
|
||||
"version": "v3.1.27",
|
||||
|
@ -60,9 +380,112 @@
|
|||
"templating"
|
||||
],
|
||||
"time": "2015-06-18 00:55:59"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.7.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d",
|
||||
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
"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-10-11 09:39:48"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v2.7.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "eb033050050916b6bfa51be71009ef67b16046c9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/eb033050050916b6bfa51be71009ef67b16046c9",
|
||||
"reference": "eb033050050916b6bfa51be71009ef67b16046c9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-symfony_debug": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"Resources/functions/dump.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\VarDumper\\": ""
|
||||
}
|
||||
},
|
||||
"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 mechanism for exploring and dumping PHP variables",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"dump"
|
||||
],
|
||||
"time": "2015-10-25 17:17:38"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
|
|
|
@ -1,25 +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', './youtube-dl');
|
||||
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);
|
||||
define('BASE_URL', 'http://alltubedownload.net/');
|
5
config.example.yml
Normal file
5
config.example.yml
Normal 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: ffmpeg/ffmpeg
|
216
controllers/FrontController.php
Normal file
216
controllers/FrontController.php
Normal file
|
@ -0,0 +1,216 @@
|
|||
<?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;
|
||||
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
|
||||
{
|
||||
|
||||
/**
|
||||
* Display index page
|
||||
* @return void
|
||||
*/
|
||||
static function index()
|
||||
{
|
||||
global $app;
|
||||
$config = Config::getInstance();
|
||||
$app->render(
|
||||
'head.tpl',
|
||||
array(
|
||||
'class'=>'index'
|
||||
)
|
||||
);
|
||||
$app->render(
|
||||
'header.tpl'
|
||||
);
|
||||
$app->render(
|
||||
'index.tpl',
|
||||
array(
|
||||
'convert'=>$config->convert
|
||||
)
|
||||
);
|
||||
$app->render('footer.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a list of extractors
|
||||
* @return void
|
||||
*/
|
||||
static function extractors()
|
||||
{
|
||||
global $app;
|
||||
$app->render(
|
||||
'head.tpl',
|
||||
array(
|
||||
'class'=>'extractors'
|
||||
)
|
||||
);
|
||||
$app->render('header.tpl');
|
||||
$app->render('logo.tpl');
|
||||
$app->render(
|
||||
'extractors.tpl',
|
||||
array(
|
||||
'extractors'=>VideoDownload::listExtractors()
|
||||
)
|
||||
);
|
||||
$app->render('footer.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dislay information about the video
|
||||
* @return void
|
||||
*/
|
||||
static function video()
|
||||
{
|
||||
global $app;
|
||||
$config = Config::getInstance();
|
||||
if (isset($_GET["url"])) {
|
||||
if (isset($_GET['audio'])) {
|
||||
try {
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
|
||||
//Vimeo needs a correct user-agent
|
||||
$UA = VideoDownload::getUA();
|
||||
ini_set(
|
||||
'user_agent',
|
||||
$UA
|
||||
);
|
||||
$url_info = parse_url($video->url);
|
||||
if ($url_info['scheme'] == 'rtmp') {
|
||||
ob_end_flush();
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="'.
|
||||
html_entity_decode(
|
||||
pathinfo(
|
||||
VideoDownload::getFilename(
|
||||
$video->webpage_url
|
||||
), PATHINFO_FILENAME
|
||||
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
||||
).'"'
|
||||
);
|
||||
header("Content-Type: audio/mpeg");
|
||||
passthru(
|
||||
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url).
|
||||
' | '.$config->avconv.
|
||||
' -v quiet -i - -f mp3 -vn pipe:1'
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
ob_end_flush();
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="'.
|
||||
html_entity_decode(
|
||||
pathinfo(
|
||||
VideoDownload::getFilename(
|
||||
$video->webpage_url
|
||||
), PATHINFO_FILENAME
|
||||
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
|
||||
).'"'
|
||||
);
|
||||
header("Content-Type: audio/mpeg");
|
||||
passthru(
|
||||
'curl --user-agent '.escapeshellarg($UA).
|
||||
' '.escapeshellarg($video->url).
|
||||
' | '.$config->avconv.
|
||||
' -v quiet -i - -f mp3 -vn pipe:1'
|
||||
);
|
||||
exit;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
$app->render(
|
||||
'head.tpl',
|
||||
array(
|
||||
'class'=>'video'
|
||||
)
|
||||
);
|
||||
$app->render(
|
||||
'video.tpl',
|
||||
array(
|
||||
'video'=>$video
|
||||
)
|
||||
);
|
||||
$app->render('footer.tpl');
|
||||
} catch (\Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($error)) {
|
||||
$app->render(
|
||||
'head.tpl',
|
||||
array(
|
||||
'class'=>'video'
|
||||
)
|
||||
);
|
||||
$app->render(
|
||||
'error.tpl',
|
||||
array(
|
||||
'errors'=>$error
|
||||
)
|
||||
);
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -248,7 +248,24 @@ color:#f2084a;
|
|||
-moz-transition: all 0.1s ease-in;
|
||||
-o-transition: all 0.1s ease-in;
|
||||
}
|
||||
|
||||
|
||||
#bookmarklet{
|
||||
padding:15px;
|
||||
}
|
||||
|
||||
.bookmarklet{
|
||||
position:relative;
|
||||
font-size:13px;
|
||||
color:gray;
|
||||
z-index:10;
|
||||
text-decoration:none;
|
||||
padding-left:30px;
|
||||
padding-right:30px;
|
||||
padding-top:10px;
|
||||
padding-bottom:10px;
|
||||
border: 2px dotted;
|
||||
}
|
||||
|
||||
.mp3
|
||||
{
|
||||
position:relative;
|
||||
|
|
22
disabled.php
22
disabled.php
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Index page
|
||||
*
|
||||
* 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 'common.php';
|
||||
if (!DISABLED) {
|
||||
header('Location: index.php'); exit;
|
||||
}
|
||||
$smarty->display('head.tpl');
|
||||
$smarty->display('header.tpl');
|
||||
$smarty->display('disabled.tpl');
|
||||
$smarty->display('footer.tpl');
|
210
download.php
210
download.php
|
@ -1,210 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Main 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
|
||||
* */
|
||||
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Main 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 VideoDownload
|
||||
{
|
||||
/**
|
||||
* Get version of youtube-dl
|
||||
*
|
||||
* @return string Version
|
||||
* */
|
||||
static function getVersion()
|
||||
{
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --version',
|
||||
$version, $code
|
||||
);
|
||||
return $version[0];
|
||||
}
|
||||
/**
|
||||
* Get the user agent used youtube-dl
|
||||
*
|
||||
* @return string UA
|
||||
* */
|
||||
static function getUA()
|
||||
{
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --dump-user-agent',
|
||||
$version, $code
|
||||
);
|
||||
return $version[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all extractors
|
||||
*
|
||||
* @return array Extractors
|
||||
* */
|
||||
static function listExtractors()
|
||||
{
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --list-extractors',
|
||||
$extractors, $code
|
||||
);
|
||||
return $extractors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename of video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string Filename
|
||||
* */
|
||||
static function getFilename($url, $format=null)
|
||||
{
|
||||
$cmd=PYTHON.' youtube-dl';
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
$cmd .=' --get-filename '.escapeshellarg($url)." 2>&1";
|
||||
exec(
|
||||
$cmd,
|
||||
$filename
|
||||
);
|
||||
return end($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title of video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
*
|
||||
* @return string Title
|
||||
* */
|
||||
static function getTitle($url)
|
||||
{
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --get-title '.
|
||||
escapeshellarg($url),
|
||||
$title
|
||||
);
|
||||
$title=$title[0];
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all information about a video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string JSON
|
||||
* */
|
||||
static function getJSON($url, $format=null)
|
||||
{
|
||||
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
$cmd .=' --dump-json '.escapeshellarg($url)." 2>&1";
|
||||
exec(
|
||||
$cmd,
|
||||
$json, $code
|
||||
);
|
||||
if ($code>0) {
|
||||
return array('success'=>false, 'error'=>$json);
|
||||
} else {
|
||||
return json_decode($json[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get thumbnail of video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
*
|
||||
* @return string URL of image
|
||||
* */
|
||||
static function getThumbnail($url)
|
||||
{
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' --get-thumbnail '.
|
||||
escapeshellarg($url),
|
||||
$thumb
|
||||
);
|
||||
if (isset($thumb[0])) {
|
||||
return $thumb[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list available formats for this video
|
||||
*
|
||||
* @param string $url URL of page
|
||||
*
|
||||
* @return string Title
|
||||
* */
|
||||
static function getAvailableFormats($url)
|
||||
{
|
||||
exec(
|
||||
PYTHON.' '.YOUTUBE_DL.' -F '.
|
||||
escapeshellarg($url),
|
||||
$formats
|
||||
);
|
||||
$return=array();
|
||||
foreach ($formats as $i=>$format) {
|
||||
if ($i > 4) {
|
||||
$return[]=(preg_split('/(\s\s+)|(\s+:?\s+)|(\s+\[)|\]/', $format));
|
||||
}
|
||||
}
|
||||
if (empty($return)) {
|
||||
foreach ($formats as $i=>$format) {
|
||||
if ($i > 3) {
|
||||
$return[]=preg_split('/(\s\s+)|(\s+:?\s+)|(\s+\[)|\]/', $format);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL of video from URL of page
|
||||
*
|
||||
* @param string $url URL of page
|
||||
* @param string $format Format to use for the video
|
||||
*
|
||||
* @return string URL of video
|
||||
* */
|
||||
static function getURL($url, $format=null)
|
||||
{
|
||||
$cmd=PYTHON.' '.YOUTUBE_DL;
|
||||
if (isset($format)) {
|
||||
$cmd .= ' -f '.escapeshellarg($format);
|
||||
}
|
||||
$cmd .=' -g '.escapeshellarg($url)." 2>&1";
|
||||
exec(
|
||||
$cmd, $url, $code
|
||||
);
|
||||
if ($code>0) {
|
||||
return array('success'=>false, 'error'=>$url);
|
||||
} else {
|
||||
return array('success'=>true, 'url'=>end($url));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
18
error.html
Normal file
18
error.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!Doctype HTML>
|
||||
<html lang="en" itemscope itemtype="http://schema.org/WebApplication">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>AllTube Download - Maintenance</title>
|
||||
<link rel="stylesheet" href="dist/main.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="main">
|
||||
<h1><img itemprop="image" class="logo" src="img/logo.png"
|
||||
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>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* List of all supported websites
|
||||
*
|
||||
* 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 'common.php';
|
||||
$smarty->assign('class', 'extractors');
|
||||
require_once 'download.php';
|
||||
$smarty->display('head.tpl');
|
||||
$smarty->display('header.tpl');
|
||||
$smarty->display('logo.tpl');
|
||||
$smarty->assign('extractors', VideoDownload::listExtractors());
|
||||
$smarty->display('extractors.tpl');
|
||||
$smarty->display('footer.tpl');
|
Binary file not shown.
Binary file not shown.
44
index.php
44
index.php
|
@ -2,9 +2,9 @@
|
|||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Index page
|
||||
*
|
||||
*
|
||||
* PHP Version 5.3.10
|
||||
*
|
||||
*
|
||||
* @category Youtube-dl
|
||||
* @package Youtubedl
|
||||
* @author Pierre Rudloff <contact@rudloff.pro>
|
||||
|
@ -12,9 +12,37 @@
|
|||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://rudloff.pro
|
||||
* */
|
||||
require_once 'common.php';
|
||||
$smarty->assign('class', 'index');
|
||||
$smarty->display('head.tpl');
|
||||
$smarty->display('header.tpl');
|
||||
$smarty->display('index.tpl');
|
||||
$smarty->display('footer.tpl');
|
||||
require_once __DIR__.'/vendor/autoload.php';
|
||||
use Alltube\VideoDownload;
|
||||
|
||||
$app = new \Slim\Slim(
|
||||
array(
|
||||
'view' => new \Slim\Views\Smarty()
|
||||
)
|
||||
);
|
||||
$view = $app->view();
|
||||
$view->parserExtensions = array(
|
||||
__DIR__.'/vendor/slim/views/SmartyPlugins',
|
||||
__DIR__.'/vendor/rudloff/smarty-plugin-noscheme/'
|
||||
);
|
||||
$app->get(
|
||||
'/',
|
||||
array('Alltube\Controller\FrontController', 'index')
|
||||
);
|
||||
$app->get(
|
||||
'/extractors',
|
||||
array('Alltube\Controller\FrontController', 'extractors')
|
||||
)->name('extractors');
|
||||
$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();
|
||||
|
|
20
json.php
20
json.php
|
@ -1,20 +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
|
||||
* */
|
||||
require_once 'common.php';
|
||||
require_once 'download.php';
|
||||
if (isset($_GET["url"])) {
|
||||
header('Content-Type: application/json');
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
echo json_encode($video);
|
||||
}
|
18
maintenance.html
Normal file
18
maintenance.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!Doctype HTML>
|
||||
<html lang="en" itemscope itemtype="http://schema.org/WebApplication">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>AllTube Download - Maintenance</title>
|
||||
<link rel="stylesheet" href="dist/main.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="main">
|
||||
<h1><img itemprop="image" class="logo" src="img/logo.png"
|
||||
alt="AllTube Download" width="328" height="284"></h1>
|
||||
<div>This application is undergoing maintenance right now. Please check back later.</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Index page
|
||||
*
|
||||
* 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 'common.php';
|
||||
if (!MAINTENANCE) {
|
||||
header('Location: index.php'); exit;
|
||||
}
|
||||
$smarty->display('head.tpl');
|
||||
$smarty->display('header.tpl');
|
||||
$smarty->display('maintenance.tpl');
|
||||
$smarty->display('footer.tpl');
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "alltube",
|
||||
"version": "0.3.2",
|
||||
"version": "0.4.0",
|
||||
"dependencies": {
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-cli": "~0.1.13",
|
||||
|
@ -8,7 +8,9 @@
|
|||
"grunt-contrib-uglify": "~0.6.0",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-phpcs": "~0.4.0",
|
||||
"grunt-phpunit": "~0.3.6"
|
||||
"grunt-phpunit": "~0.3.6",
|
||||
"grunt-contrib-compress": "~0.13.0",
|
||||
"bower": "~1.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "~0.10.29"
|
||||
|
@ -18,6 +20,6 @@
|
|||
"url": "https://github.com/Rudloff/alltube.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "./node_modules/grunt-cli/bin/grunt; curl -L https://yt-dl.org/downloads/latest/youtube-dl -o youtube-dl; 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; 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"
|
||||
}
|
||||
}
|
||||
|
|
15
phpunit.xml
Normal file
15
phpunit.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<phpunit bootstrap="vendor/autoload.php">
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>classes/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<logging>
|
||||
<log type="coverage-html" target="coverage/" />
|
||||
</logging>
|
||||
</phpunit>
|
23
redirect.php
23
redirect.php
|
@ -1,23 +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"])) {
|
||||
$video = VideoDownload::getURL($_GET["url"]);
|
||||
if (isset($video['url'])) {
|
||||
header('Location: '.$video['url']);
|
||||
} else {
|
||||
echo "Can't find video";
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
rm alltube-release.zip
|
||||
zip -r alltube-release.zip *.php dist/ fonts/ .htaccess img/ js/ LICENSE README.md robots.txt sitemap.xml templates/ templates_c/ vendor/ youtube-dl -x config.php
|
|
@ -6,7 +6,7 @@
|
|||
<priority>1</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>http://alltubedownload.net/extractors.php</loc>
|
||||
<loc>http://alltubedownload.net/extractors</loc>
|
||||
<changefreq>weekly</changefreq>
|
||||
</url>
|
||||
</urlset>
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<div class="wrapper">
|
||||
<div class="main">
|
||||
<h1><img itemprop="image" class="logo" src="img/logo.png"
|
||||
alt="AllTube Download" width="328" height="284"></h1>
|
||||
<div>
|
||||
Due to various technical reasons,
|
||||
we can no longer host an online version of AllTube.<br/>
|
||||
However, you are free to
|
||||
<a title="AllTube releases on GitHub"
|
||||
href="https://github.com/Rudloff/alltube/releases">
|
||||
download the code</a>
|
||||
and run it on your own server.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -15,7 +15,6 @@
|
|||
·
|
||||
Based on <a href="http://rg3.github.io/youtube-dl/">youtube-dl</a>
|
||||
·
|
||||
<a href="javascript:window.location='{$base_url}/api.php?url='+encodeURIComponent(location.href);">Bookmarklet</a>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
|
|
@ -4,24 +4,25 @@
|
|||
<meta charset="UTF-8" />
|
||||
<meta name=viewport content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="Easily download videos from Youtube, Dailymotion, Vimeo and other websites." />
|
||||
<link rel="stylesheet" href="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/103696815796116179392?rel=author" />
|
||||
<link href="https://plus.google.com/108799967445657477255" rel="publisher" />
|
||||
<title itemprop="name">AllTube Download</title>
|
||||
<meta itemprop="url" content="http://alltubedownload.net/" />
|
||||
<link rel="icon" href="img/favicon.png" />
|
||||
<meta property="og:url" content="http://www.alltubedownload.net/" />
|
||||
<meta itemprop="url" content="{siteUrl}" />
|
||||
<link rel="canonical" href="{currentUrl|replace:{siteUrl}:'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: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:title" content="AllTube Download" />
|
||||
<meta name="twitter:image" content="http://www.alltubedownload.net/img/logo.png" />
|
||||
<meta name="twitter:image" content="{siteUrl url='img/logo.png'}" />
|
||||
<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 src="dist/main.js"></script>
|
||||
<script src="{siteUrl|noscheme url='dist/main.js'}"></script>
|
||||
<meta itemprop="applicationCategory" content="Download" />
|
||||
<meta itemprop="operatingSystem" content="Linux" />
|
||||
<meta itemprop="operatingSystem" content="Mac OS X" />
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<header>
|
||||
<div class="social">
|
||||
<a class="twitter" href="http://twitter.com/home?status={$base_url|urlencode}" target="_blank">
|
||||
<a class="twitter" href="http://twitter.com/home?status={siteUrl|urlencode}" target="_blank">
|
||||
Share on Twitter<div class="twittermask"></div></a>
|
||||
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u={$base_url|urlencode}" target="_blank">Share on Facebook<div class="facebookmask"></div></a>
|
||||
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u={siteUrl|urlencode}" target="_blank">Share on Facebook<div class="facebookmask"></div></a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="wrapper">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="main">
|
||||
<div><img itemprop="image" class="logo" src="img/logo.png"
|
||||
<div><img itemprop="image" class="logo" src="{siteUrl|noscheme url='img/logo.png'}"
|
||||
alt="AllTube Download" width="328" height="284"></div>
|
||||
<form action="api.php">
|
||||
<form action="{urlFor name="video"}">
|
||||
<label class="labelurl" for="url">
|
||||
Copy here the URL of your video (Youtube, Dailymotion, etc.)
|
||||
</label>
|
||||
|
@ -20,5 +20,10 @@
|
|||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
<a class="combatiblelink" href="extractors.php">See all supported websites</a>
|
||||
<a class="combatiblelink" href="{urlFor name="extractors"}">See all supported websites</a>
|
||||
<div id="bookmarklet">
|
||||
<p> Drag this to your bookmarks bar: </p>
|
||||
<a class="bookmarklet" href="javascript:window.location='{siteUrl withUri=false}{urlFor name='video'}?url='+encodeURIComponent(location.href);">Bookmarklet</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1 class="logobis">
|
||||
<a class="logocompatible" href="index.php">
|
||||
AllTube Download<span class="logocompatiblemask"><img src="img/logocompatiblemask.png" width="447" height="107" alt="" /></span>
|
||||
<a class="logocompatible" href="{siteUrl}">
|
||||
AllTube Download<span class="logocompatiblemask"><img src="{siteUrl|noscheme url='img/logocompatiblemask.png'}" width="447" height="107" alt="" /></span>
|
||||
</a></h1>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<div class="wrapper">
|
||||
<div class="main">
|
||||
<h1><img itemprop="image" class="logo" src="img/logo.png"
|
||||
alt="AllTube Download" width="328" height="284"></h1>
|
||||
<div>Due to some issues with our server,
|
||||
we have to disable AllTube for a few days.
|
||||
Sorry for the inconvenience.</div>
|
||||
</div>
|
||||
</div>
|
|
@ -9,16 +9,18 @@
|
|||
href="{$video->webpage_url}">
|
||||
{$video->title}</a></i>.
|
||||
<img class="cast_icon" id="cast_disabled"
|
||||
src="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"
|
||||
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"
|
||||
src="{siteUrl|noscheme url='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"
|
||||
<img src="{siteUrl|noscheme url='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>
|
||||
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" />
|
||||
{if isset($video->thumbnail)}
|
||||
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" />
|
||||
{/if}
|
||||
<br/>
|
||||
<input type="hidden" name="url"
|
||||
value="{$video->webpage_url}" />
|
||||
|
|
39
tests/ConfigTest.php
Normal file
39
tests/ConfigTest.php
Normal 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);
|
||||
}
|
||||
}
|
|
@ -10,9 +10,7 @@
|
|||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://rudloff.pro
|
||||
* */
|
||||
|
||||
require_once __DIR__.'/../common.php';
|
||||
require_once __DIR__.'/../download.php';
|
||||
use Alltube\VideoDownload;
|
||||
|
||||
/**
|
||||
* Unit tests for the VideoDownload class
|
||||
|
@ -27,19 +25,9 @@ require_once __DIR__.'/../download.php';
|
|||
* */
|
||||
class VideoDownloadTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
static private $_testVideoURL = 'https://www.youtube.com/watch?v=RJJ6FCAXvKg';
|
||||
|
||||
/**
|
||||
* Test getVersion function
|
||||
* @return void
|
||||
*/
|
||||
public function testGetVersion()
|
||||
{
|
||||
$this->assertStringMatchesFormat('%i.%i.%i', VideoDownload::getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getUA function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetUA()
|
||||
|
@ -49,23 +37,128 @@ class VideoDownloadTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* Test listExtractors funtion
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testListExtractors()
|
||||
{
|
||||
$extractors = VideoDownload::listExtractors();
|
||||
$this->assertNotEmpty($extractors);
|
||||
$this->assertInternalType('array', $extractors);
|
||||
$this->assertContains('youtube', $extractors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getURL function
|
||||
* @return void
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider urlProvider
|
||||
*/
|
||||
public function testGetURL()
|
||||
public function testGetURL($url, $format)
|
||||
{
|
||||
$url = VideoDownload::getURL(self::$_testVideoURL);
|
||||
$this->assertArrayHasKey('success', $url);
|
||||
$this->assertArrayHasKey('url', $url);
|
||||
$videoURL = VideoDownload::getURL($url, $format);
|
||||
$this->assertArrayHasKey('success', $videoURL);
|
||||
$this->assertArrayHasKey('url', $videoURL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getURL function errors
|
||||
*
|
||||
* @param string $url URL
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
* @dataProvider ErrorUrlProvider
|
||||
*/
|
||||
public function testGetURLError($url)
|
||||
{
|
||||
$videoURL = VideoDownload::getURL($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides URLs for tests
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function urlProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'https://www.youtube.com/watch?v=M7IpKCZ47pU', null,
|
||||
"It's Not Me, It's You - Hearts Under Fire-M7IpKCZ47pU.mp4"
|
||||
),
|
||||
array(
|
||||
'https://www.youtube.com/watch?v=RJJ6FCAXvKg', 22,
|
||||
"'Heart Attack' - Demi Lovato ".
|
||||
"(Sam Tsui & Against The Current)-RJJ6FCAXvKg.mp4"
|
||||
),
|
||||
array(
|
||||
'https://vimeo.com/24195442', null,
|
||||
"Carving the Mountains-24195442.mp4"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides incorrect URLs for tests
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function errorUrlProvider()
|
||||
{
|
||||
return array(
|
||||
array('http://example.com/video')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getFilename function
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
* @param string $result Expected filename
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider URLProvider
|
||||
*/
|
||||
public function testGetFilename($url, $format, $result)
|
||||
{
|
||||
$filename = VideoDownload::getFilename($url, $format);
|
||||
$this->assertEquals($filename, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getJSON function
|
||||
*
|
||||
* @param string $url URL
|
||||
* @param string $format Format
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider URLProvider
|
||||
*/
|
||||
public function testGetJSON($url, $format)
|
||||
{
|
||||
$info = VideoDownload::getJSON($url, $format);
|
||||
$this->assertObjectHasAttribute('webpage_url', $info);
|
||||
$this->assertObjectHasAttribute('url', $info);
|
||||
$this->assertObjectHasAttribute('ext', $info);
|
||||
$this->assertObjectHasAttribute('title', $info);
|
||||
$this->assertObjectHasAttribute('formats', $info);
|
||||
$this->assertObjectHasAttribute('_filename', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getJSON function errors
|
||||
*
|
||||
* @param string $url URL
|
||||
*
|
||||
* @return void
|
||||
* @expectedException Exception
|
||||
* @dataProvider ErrorURLProvider
|
||||
*/
|
||||
public function testGetJSONError($url)
|
||||
{
|
||||
$videoURL = VideoDownload::getJSON($url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Old index file, now redirects to index.php
|
||||
*
|
||||
* 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
|
||||
* */
|
||||
header('Location: index.php');
|
Loading…
Reference in a new issue