Merge branch 'master' into maintenance

This commit is contained in:
Pierre Rudloff 2015-01-07 10:34:36 +01:00
commit 39f81c3674
16 changed files with 162 additions and 134 deletions

View File

@ -2,3 +2,17 @@ alltube
=======
HTML GUI for youtube-dl (http://alltubedownload.net/)
##Setup
The only thing you need to get Alltube working is to download [youtube-dl](https://rg3.github.io/youtube-dl/):
wget https://yt-dl.org/downloads/latest/youtube-dl
##License
This software is available under the [GNU General Public License](http://www.gnu.org/licenses/gpl.html).
__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*.

187
api.php
View File

@ -10,10 +10,9 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
$python="/usr/bin/python";
require_once 'download.php';
if (isset($_GET["url"])) {
if (isset($_GET["format"]) || isset($_GET['audio'])) {
if (isset($_GET['audio'])) {
$video = VideoDownload::getJSON($_GET["url"], $_GET["format"]);
if (isset($video->url)) {
@ -25,100 +24,40 @@ if (isset($_GET["url"])) {
);
$url_info = parse_url($video->url);
if ($url_info['scheme'] == 'rtmp') {
if (isset($_GET['audio'])) {
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).
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
);
exit;
} else {
header(
'Content-Disposition: attachment; filename="'.
html_entity_decode(
header(
'Content-Disposition: attachment; filename="'.
html_entity_decode(
pathinfo(
VideoDownload::getFilename(
$video->webpage_url, $video->format_id
), ENT_COMPAT, 'ISO-8859-1'
).'"'
);
header("Content-Type: application/octet-stream");
passthru(
'/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url)
);
exit;
}
$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).
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
);
exit;
} else {
if (isset($_GET['audio'])) {
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/wget -q --user-agent='.escapeshellarg($UA).
' -O - '.escapeshellarg($video->url).
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
);
exit;
} else if (pathinfo($video->url, PATHINFO_EXTENSION) == 'm3u8') {
header(
'Content-Disposition: attachment; filename="'.
html_entity_decode(
pathinfo(
VideoDownload::getFilename(
$video->webpage_url
), PATHINFO_FILENAME
).'.mp4', ENT_COMPAT, 'ISO-8859-1'
).'"'
);
header("Content-Type: video/mp4");
passthru(
'/usr/bin/avconv -v quiet -i '.
escapeshellarg($video->url).' -f h264 pipe:1'
);
exit;
} else {
$headers = get_headers($video->url, 1);
header(
'Content-Disposition: attachment; filename="'.
html_entity_decode(
header(
'Content-Disposition: attachment; filename="'.
html_entity_decode(
pathinfo(
VideoDownload::getFilename(
$video->webpage_url, $video->format_id
), ENT_COMPAT, 'ISO-8859-1'
).'"'
);
if (is_string($headers['Content-Type'])
&& isset($headers['Content-Type'])
) {
header("Content-Type: ".$headers['Content-Type']);
} else {
header("Content-Type: application/octet-stream");
}
if (is_string($headers['Content-Length'])
&& isset($headers['Content-Length'])
) {
header("Content-Length: ".$headers['Content-Length']);
}
readfile($video->url);
exit;
}
$video->webpage_url
), PATHINFO_FILENAME
).'.mp3', ENT_COMPAT, 'ISO-8859-1'
).'"'
);
header("Content-Type: audio/mpeg");
passthru(
'/usr/bin/wget -q --user-agent='.escapeshellarg($UA).
' -O - '.escapeshellarg($video->url).
' | /usr/bin/avconv -v quiet -i - -f mp3 pipe:1'
);
exit;
}
} else {
$error=true;
@ -129,18 +68,32 @@ if (isset($_GET["url"])) {
include 'head.php';
?>
<body>
<div class="wrapper">
<div itemscope
itemtype="http://schema.org/VideoObject" class="wrapper">
<div class="main">
<?php
include 'logo.php';
?>
<p>You are going to download<i>
<a id="video_link" data-ext="<?php echo $video->ext; ?>" data-video="<?php echo $video->url; ?>" href="<?php echo $video->webpage_url; ?>">
<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>
?></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 class="thumb" src="',
echo '<img itemprop="image" class="thumb" src="',
$video->thumbnail, '" alt="" />';
?><br/>
<form action="api.php">
@ -149,28 +102,44 @@ if (isset($_GET["url"])) {
<?php
if (isset($video->formats)) {
?>
<legend for="format">Select format</legend>
<select id="format" name="format">
<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 '<option value="', $format->format_id, '"';
if ($format->format_id == $video->format_id) {
echo ' selected ';
}
echo '>';
echo $format->format, ' (', $format->ext, ')';
echo '</option>';
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>';
}
?>
</select><br/><br/>
</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
}
?>
<input class="downloadBtn" type="submit" value="Download" /><br/>
</form>
</div>
</div>

18
config.php Normal file
View File

@ -0,0 +1,18 @@
<?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 <rudloff@strasweb.fr>
* @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');
define('CONVERT', true);
?>

View File

@ -174,10 +174,12 @@ margin-top:8px;
font-size:24px;
font-weight:800;
cursor:pointer;
-webkit-transition: all 0.1s ease-in;
-moz-transition: all 0.1s ease-in;
-o-transition: all 0.1s ease-in;
}
-webkit-transition: all 0.1s ease-in;
-moz-transition: all 0.1s ease-in;
-o-transition: all 0.1s ease-in;
text-decoration:none;
display:inline-block;
}
.downloadBtn:focus,
.downloadBtn:hover
@ -538,6 +540,14 @@ h1 {
vertical-align:middle;
}
.format {
text-align:left;
}
.best {
margin-bottom: 1em;
}
@media (max-width: 640px) {
.thumb {
width:90%;

View File

@ -11,7 +11,7 @@
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'config.php';
/**
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
* Main class
@ -26,9 +26,6 @@
* */
Class VideoDownload
{
static private $_python="/usr/bin/python";
static private $_params="--no-playlist";
/**
* Get version of youtube-dl
*
@ -37,7 +34,7 @@ Class VideoDownload
function getVersion ()
{
exec(
VideoDownload::$_python.' youtube-dl --version',
PYTHON.' '.YOUTUBE_DL.' --version',
$version, $code
);
return $version[0];
@ -50,7 +47,7 @@ Class VideoDownload
function getUA ()
{
exec(
VideoDownload::$_python.' youtube-dl --dump-user-agent',
PYTHON.' '.YOUTUBE_DL.' --dump-user-agent',
$version, $code
);
return $version[0];
@ -64,7 +61,7 @@ Class VideoDownload
function listExtractors ()
{
exec(
VideoDownload::$_python.' youtube-dl --list-extractors',
PYTHON.' '.YOUTUBE_DL.' --list-extractors',
$extractors, $code
);
return $extractors;
@ -80,7 +77,7 @@ Class VideoDownload
* */
function getFilename ($url, $format=null)
{
$cmd=VideoDownload::$_python.' youtube-dl';
$cmd=PYTHON.' youtube-dl';
if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format);
}
@ -102,7 +99,7 @@ Class VideoDownload
function getTitle ($url)
{
exec(
VideoDownload::$_python.' youtube-dl --get-title '.
PYTHON.' '.YOUTUBE_DL.' --get-title '.
escapeshellarg($url),
$title
);
@ -120,11 +117,11 @@ Class VideoDownload
* */
function getJSON ($url, $format=null)
{
$cmd=VideoDownload::$_python.' youtube-dl '.VideoDownload::$_params;
$cmd=PYTHON.' '.YOUTUBE_DL.' '.PARAMS;
if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format);
}
$cmd .=' --no-warnings --dump-json '.escapeshellarg($url)." 2>&1";
$cmd .=' --dump-json '.escapeshellarg($url)." 2>&1";
exec(
$cmd,
$json, $code
@ -146,7 +143,7 @@ Class VideoDownload
function getThumbnail ($url)
{
exec(
VideoDownload::$_python.' youtube-dl --get-thumbnail '.
PYTHON.' '.YOUTUBE_DL.' --get-thumbnail '.
escapeshellarg($url),
$thumb
);
@ -165,7 +162,7 @@ Class VideoDownload
function getAvailableFormats ($url)
{
exec(
VideoDownload::$_python.' youtube-dl -F '.
PYTHON.' '.YOUTUBE_DL.' -F '.
escapeshellarg($url),
$formats
);
@ -195,7 +192,7 @@ Class VideoDownload
* */
function getURL ($url, $format=null)
{
$cmd=VideoDownload::$_python.' youtube-dl';
$cmd=PYTHON.' '.YOUTUBE_DL;
if (isset($format)) {
$cmd .= ' -f '.escapeshellarg($format);
}

View File

@ -9,6 +9,7 @@
href="https://fonts.googleapis.com/css?family=Open+Sans:400,300" />
<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" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/logo_250.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 730 B

View File

@ -19,6 +19,7 @@ require 'head.php';
<?php
require 'header.php';
require 'config.php';
?>
<div class="wrapper">
@ -35,10 +36,17 @@ require 'head.php';
required placeholder="http://website.com/video" />
</span>
<input class="downloadBtn" type="submit" value="Download" /><br/>
<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
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>

View File

@ -1,6 +1,16 @@
<?php
$python="/usr/bin/python";
/**
* 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 <rudloff@strasweb.fr>
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
require_once 'download.php';
if (isset($_GET["url"])) {
header('Content-Type: application/json');

View File

@ -9,7 +9,8 @@
"32": "/img/favicon.png",
"60": "/img/logo_60.png",
"90": "/img/logo_90.png",
"243": "/img/logo_app.png"
"243": "/img/logo_app.png",
"250": "/img/logo_250.png"
},
"default_locale": "en",
"launch_path": "/index.php"