This commit is contained in:
Pierre Rudloff 2015-04-11 22:08:24 +02:00
parent eeb506bdf7
commit 0b4e75547a
25 changed files with 276 additions and 331 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@ youtube-dl
dist/
node_modules/
config.php
vendor/
templates_c/

122
api.php
View file

@ -10,9 +10,8 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.example.php';
@include_once 'config.php';
require_once 'common.php';
$smarty->assign('class', 'video');
require_once 'download.php';
if (isset($_GET["url"])) {
if (isset($_GET['audio'])) {
@ -68,121 +67,18 @@ if (isset($_GET["url"])) {
} else {
$video = VideoDownload::getJSON($_GET["url"]);
if (isset($video->webpage_url)) {
include 'head.php';
?>
<body>
<div itemscope
itemtype="http://schema.org/VideoObject" class="wrapper">
<div class="main">
<?php
include 'logo.php';
?>
<p>You are going to download<i itemprop="name">
<a itemprop="url" id="video_link"
data-ext="<?php echo $video->ext; ?>"
data-video="<?php echo htmlentities($video->url); ?>"
href="<?php echo $video->webpage_url; ?>">
<?php
echo $video->title;
?></a></i>.
<img class="cast_icon" id="cast_disabled"
src="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"
title="Cast to ChromeCast" alt="Google Cast™" />
<img src="img/ic_media_route_on_holo_light.png"
alt="Casting to ChromeCast…" title="Stop casting"
id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" /></p>
<?php
echo '<img itemprop="image" class="thumb" src="',
$video->thumbnail, '" alt="" />';
?><br/>
<input type="hidden" name="url"
value="<?php echo $video->webpage_url; ?>" />
<?php
if (isset($video->formats)) {
?>
<h3>Available formats:</h3>
<p>(You might have to do a <i>Right click > Save as</i>)</p>
<ul id="format" class="format">
<?php
echo '<li class="best" itemprop="encoding" itemscope
itemtype="http://schema.org/VideoObject">';
echo '<a download="'.$video->_filename.'" itemprop="contentUrl"
href="', htmlentities($video->url) ,'">';
echo '<b>Best</b> (<span itemprop="encodingFormat">',
$video->ext, '</span>)';
echo '</a></li>';
foreach ($video->formats as $format) {
echo '<li itemprop="encoding"
itemscope itemtype="http://schema.org/VideoObject">';
echo '<a download="'.str_replace(
$video->ext, $format->ext, $video->_filename
).'" itemprop="contentUrl"
href="', htmlentities($format->url) ,'">';
echo '<span itemprop="videoQuality">', $format->format,
'</span> (<span itemprop="encodingFormat">',
$format->ext, '</span>)';
echo '</a></li>';
}
?>
</ul><br/><br/>
<?php
} else {
?>
<input type="hidden" name="format" value="best" />
<?php
}
if (!isset($video->formats)) {
?>
<a class="downloadBtn"
href="<?php echo $video->url; ?>">Download</a><br/>
<?php
}
?>
</div>
</div>
<?php
include 'footer.php';
?>
</body>
</html>
<?php
$smarty->display('head.tpl');
$smarty->assign('video', $video);
$smarty->display('video.tpl');
$smarty->display('footer.tpl');
} else {
$error=true;
}
}
}
if (isset($error)) {
include 'head.php';
?>
<body>
<div class="wrapper">
<div class="main error">
<?php
include 'logo.php';
?>
<h2>An error occured</h2>
Please check the URL of your video.
<p><i>
<?php
foreach ($video['error'] as $error) {
print htmlspecialchars($error);
?>
<br/>
<?php
}
?>
</i></p>
</div>
</div>
<?php
include 'footer.php';
?>
</body>
</html>
<?php
$smarty->display('head.tpl');
$smarty->assign('errors', $video['error']);
$smarty->display('error.tpl');
$smarty->display('footer.tpl');
}
?>

View file

@ -12,9 +12,22 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
if (DISABLED) {
require_once '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) {
} else if (MAINTENANCE && FILENAME != 'maintenance.php') {
header('Location: maintenance.php'); exit;
}
?>
$smarty = new Smarty();
$smarty->assign(
array(
'base_url'=>BASE_URL,
'convert'=>CONVERT
)
);

5
composer.json Normal file
View file

@ -0,0 +1,5 @@
{
"require": {
"smarty/smarty": "~3.1"
}
}

73
composer.lock generated Normal file
View file

@ -0,0 +1,73 @@
{
"_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",
"This file is @generated automatically"
],
"hash": "b48850b7da32d0f14515a15b400da402",
"packages": [
{
"name": "smarty/smarty",
"version": "v3.1.21",
"source": {
"type": "git",
"url": "https://github.com/smarty-php/smarty.git",
"reference": "1f878e6d746ecc8ec8d00d9c75044cf7d23ad94a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/1f878e6d746ecc8ec8d00d9c75044cf7d23ad94a",
"reference": "1f878e6d746ecc8ec8d00d9c75044cf7d23ad94a",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
}
},
"autoload": {
"classmap": [
"libs/Smarty.class.php",
"libs/SmartyBC.class.php",
"libs/sysplugins/smarty_security.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Monte Ohrt",
"email": "monte@ohrt.com"
},
{
"name": "Uwe Tews",
"email": "uwe.tews@googlemail.com"
},
{
"name": "Rodney Rehm",
"email": "rodney.rehm@medialize.de"
}
],
"description": "Smarty - the compiling PHP template engine",
"homepage": "http://www.smarty.net",
"keywords": [
"templating"
],
"time": "2014-10-31 04:22:20"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

View file

@ -18,4 +18,3 @@ define('CONVERT', false);
define('MAINTENANCE', false);
define('DISABLED', false);
define('BASE_URL', 'http://alltubedownload.net/');
?>

View file

@ -12,39 +12,11 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.php';
require_once 'common.php';
if (!DISABLED) {
header('Location: index.php'); exit;
}
require 'head.php';
?>
<body>
<?php
require 'header.php';
?>
<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>
<?php
require 'footer.php';
?>
</body>
</html>
$smarty->display('head.tpl');
$smarty->display('header.tpl');
$smarty->display('disabled.tpl');
$smarty->display('footer.tpl');

View file

@ -11,8 +11,7 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.example.php';
@include_once 'config.php';
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* Main class
@ -32,7 +31,7 @@ Class VideoDownload
*
* @return string Version
* */
function getVersion ()
function getVersion()
{
exec(
PYTHON.' '.YOUTUBE_DL.' --version',
@ -45,7 +44,7 @@ Class VideoDownload
*
* @return string UA
* */
function getUA ()
function getUA()
{
exec(
PYTHON.' '.YOUTUBE_DL.' --dump-user-agent',
@ -59,7 +58,7 @@ Class VideoDownload
*
* @return array Extractors
* */
function listExtractors ()
function listExtractors()
{
exec(
PYTHON.' '.YOUTUBE_DL.' --list-extractors',
@ -76,7 +75,7 @@ Class VideoDownload
*
* @return string Filename
* */
function getFilename ($url, $format=null)
function getFilename($url, $format=null)
{
$cmd=PYTHON.' youtube-dl';
if (isset($format)) {
@ -97,7 +96,7 @@ Class VideoDownload
*
* @return string Title
* */
function getTitle ($url)
function getTitle($url)
{
exec(
PYTHON.' '.YOUTUBE_DL.' --get-title '.
@ -116,7 +115,7 @@ Class VideoDownload
*
* @return string JSON
* */
function getJSON ($url, $format=null)
function getJSON($url, $format=null)
{
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
if (isset($format)) {
@ -141,7 +140,7 @@ Class VideoDownload
*
* @return string URL of image
* */
function getThumbnail ($url)
function getThumbnail($url)
{
exec(
PYTHON.' '.YOUTUBE_DL.' --get-thumbnail '.
@ -160,7 +159,7 @@ Class VideoDownload
*
* @return string Title
* */
function getAvailableFormats ($url)
function getAvailableFormats($url)
{
exec(
PYTHON.' '.YOUTUBE_DL.' -F '.
@ -191,7 +190,7 @@ Class VideoDownload
*
* @return string URL of video
* */
function getURL ($url, $format=null)
function getURL($url, $format=null)
{
$cmd=PYTHON.' '.YOUTUBE_DL;
if (isset($format)) {
@ -209,5 +208,3 @@ Class VideoDownload
}
}
?>

View file

@ -12,47 +12,12 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.example.php';
@include_once 'config.php';
require_once 'common.php';
require 'head.php';
?>
<body class="extractors">
<?php
require 'header.php';
?>
<div class="wrapper">
<?php
require 'logo.php';
?>
<h2 class="titre">Supported websites</h2>
<div class="tripleliste">
<ul>
<?php
require_once 'download.php';
$extractors=(VideoDownload::listExtractors());
foreach ($extractors as $extractor) {
echo '<li>'.$extractor.'</li>';
}
?>
</ul>
</div>
</div>
<?php
require 'footer.php';
?>
</body>
</html>
$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');

View file

@ -1,26 +0,0 @@
<?php
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* Header
*
* 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
* */
?>
<header>
<div class="social">
<a class="twitter" href="http://twitter.com/home?status=<?php
echo urlencode(BASE_URL);
?>" target="_blank">
Share on Twitter<div class="twittermask"></div></a>
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u=<?php
echo urlencode(BASE_URL);
?>" target="_blank">Share on Facebook<div class="facebookmask"></div></a>
</div>
</header>

View file

@ -12,53 +12,9 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.example.php';
@include_once 'config.php';
require_once 'common.php';
require 'head.php';
?>
<body>
<?php
require 'header.php';
?>
<div class="wrapper">
<div class="main">
<div><img itemprop="image" class="logo" src="img/logo.png"
alt="AllTube Download" width="328" height="284"></div>
<form action="api.php">
<label class="labelurl" for="url">
Copy here the URL of your video (Youtube, Dailymotion, etc.)
</label>
<div class="champs">
<span class="URLinput_wrapper">
<input class="URLinput" type="url" name="url" id="url"
required placeholder="http://website.com/video" />
</span>
<input class="downloadBtn" type="submit" value="Download" /><br/>
<?php
if (CONVERT) {
?>
<div class="mp3">
<p><input type="checkbox" id="audio" class="audio" name="audio">
<label for="audio"><span class="ui"></span>
Audio only (MP3)</label></p>
</div>
<?php
}
?>
</div>
</form>
<a class="combatiblelink" href="extractors.php">See all supported websites</a>
</div>
</div>
<?php
require 'footer.php';
?>
</body>
</html>
$smarty->assign('class', 'index');
$smarty->display('head.tpl');
$smarty->display('header.tpl');
$smarty->display('index.tpl');
$smarty->display('footer.tpl');

View file

@ -17,4 +17,3 @@ if (isset($_GET["url"])) {
$video = VideoDownload::getJSON($_GET["url"]);
echo json_encode($video);
}
?>

View file

@ -1,4 +0,0 @@
<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></h1>

View file

@ -12,33 +12,11 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.php';
require_once 'common.php';
if (!MAINTENANCE) {
header('Location: index.php'); exit;
}
require 'head.php';
?>
<body>
<?php
require 'header.php';
?>
<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>
<?php
require 'footer.php';
?>
</body>
</html>
$smarty->display('head.tpl');
$smarty->display('header.tpl');
$smarty->display('maintenance.tpl');
$smarty->display('footer.tpl');

15
templates/disabled.tpl Normal file
View file

@ -0,0 +1,15 @@
<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>

13
templates/error.tpl Normal file
View file

@ -0,0 +1,13 @@
<div class="wrapper">
<div class="main error">
{include file="logo.tpl"}
<h2>An error occured</h2>
Please check the URL of your video.
<p><i>
{foreach $errors as $error}
{$error|escape}
<br/>
{/foreach}
</i></p>
</div>
</div>

8
templates/extractors.tpl Normal file
View file

@ -0,0 +1,8 @@
<h2 class="titre">Supported websites</h2>
<div class="tripleliste">
<ul>
{foreach $extractors as $extractor}
<li>{$extractor}</li>
{/foreach}
</ul>
</div>

View file

@ -1,17 +1,4 @@
<?php
/**
* Footer
*
* 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
* */
?>
</div>
<footer>
<div class="footer_wrapper">
Code by <a rel="author" target="blank" itemprop="author"
@ -28,6 +15,8 @@
&middot;
Based on <a href="http://rg3.github.io/youtube-dl/">youtube-dl</a>
&middot;
<a href="javascript:window.location='<?php echo BASE_URL; ?>/api.php?url='+location.href;">Bookmarklet</a>
<a href="javascript:window.location='{$base_url}/api.php?url='+location.href;">Bookmarklet</a>
</div>
</footer>
</body>
</html>

View file

@ -26,5 +26,4 @@
<meta itemprop="operatingSystem" content="Linux" />
<meta itemprop="operatingSystem" content="Mac OS X" />
</head>
<body class="{$class}">

8
templates/header.tpl Normal file
View file

@ -0,0 +1,8 @@
<header>
<div class="social">
<a class="twitter" href="http://twitter.com/home?status={$base_url|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>
</div>
</header>
<div class="wrapper">

24
templates/index.tpl Normal file
View file

@ -0,0 +1,24 @@
<div class="main">
<div><img itemprop="image" class="logo" src="img/logo.png"
alt="AllTube Download" width="328" height="284"></div>
<form action="api.php">
<label class="labelurl" for="url">
Copy here the URL of your video (Youtube, Dailymotion, etc.)
</label>
<div class="champs">
<span class="URLinput_wrapper">
<input class="URLinput" type="url" name="url" id="url"
required placeholder="http://website.com/video" />
</span>
<input class="downloadBtn" type="submit" value="Download" /><br/>
{if $convert}
<div class="mp3">
<p><input type="checkbox" id="audio" class="audio" name="audio">
<label for="audio"><span class="ui"></span>
Audio only (MP3)</label></p>
</div>
{/if}
</div>
</form>
<a class="combatiblelink" href="extractors.php">See all supported websites</a>
</div>

4
templates/logo.tpl Normal file
View file

@ -0,0 +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></h1>

View file

@ -0,0 +1,9 @@
<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>

52
templates/video.tpl Normal file
View file

@ -0,0 +1,52 @@
<div class="wrapper">
<div itemscope itemtype="http://schema.org/VideoObject">
<div class="main">
{include file="logo.tpl"}
<p>You are going to download<i itemprop="name">
<a itemprop="url" id="video_link"
data-ext="{$video->ext}"
data-video="{$video->url|escape}"
href="{$video->webpage_url}">
{$video->title}</a></i>.
<img class="cast_icon" id="cast_disabled"
src="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"
title="Cast to ChromeCast" alt="Google Cast™" />
<img src="img/ic_media_route_on_holo_light.png"
alt="Casting to ChromeCast…" title="Stop casting"
id="cast_btn_stop" class="cast_btn cast_hidden cast_icon" /></p>
<img itemprop="image" class="thumb" src="{$video->thumbnail}" alt="" />
<br/>
<input type="hidden" name="url"
value="{$video->webpage_url}" />
{if $video->formats}
<h3>Available formats:</h3>
<p>(You might have to do a <i>Right click > Save as</i>)</p>
<ul id="format" class="format">
<li class="best" itemprop="encoding" itemscope
itemtype="http://schema.org/VideoObject">
<a download="{$video->_filename}" itemprop="contentUrl"
href="{$video->url|escape}">
<b>Best</b> (<span itemprop="encodingFormat">{$video->ext}</span>)
</a></li>
{foreach $video->formats as $format}
<li itemprop="encoding"
itemscope itemtype="http://schema.org/VideoObject">
<a download="{$video->ext|replace:$format->ext:$video->_filename}" itemprop="contentUrl"
href="{$format->url|escape}">
<span itemprop="videoQuality">{$format->format}</span> (<span itemprop="encodingFormat">{$format->ext}</span>)
</a></li>
{/foreach}
</ul><br/><br/>
{else}
<input type="hidden" name="format" value="best" />
{/if}
{if $video->formats}
<a class="downloadBtn"
href="{$video->url|escape}">Download</a><br/>
{/if}
</div>
</div>

View file

@ -12,4 +12,3 @@
* @link http://rudloff.pro
* */
header('Location: index.php');
?>