2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
2014-04-04 14:38:36 +00:00
|
|
|
*
|
2014-03-13 19:07:56 +00:00
|
|
|
* PHP Version 5.3.10
|
2014-04-04 14:38:36 +00:00
|
|
|
*
|
2014-03-13 19:07:56 +00:00
|
|
|
* @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"])) {
|
2015-01-07 09:23:48 +00:00
|
|
|
if (isset($_GET['audio'])) {
|
2014-03-18 14:08:16 +00:00
|
|
|
$video = VideoDownload::getJSON($_GET["url"], $_GET["format"]);
|
2014-04-04 14:38:36 +00:00
|
|
|
|
2014-03-13 19:07:56 +00:00
|
|
|
if (isset($video->url)) {
|
2015-01-07 09:12:54 +00:00
|
|
|
//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') {
|
2015-01-07 09:23:48 +00:00
|
|
|
header(
|
|
|
|
'Content-Disposition: attachment; filename="'.
|
|
|
|
html_entity_decode(
|
|
|
|
pathinfo(
|
2015-01-07 09:12:54 +00:00
|
|
|
VideoDownload::getFilename(
|
2015-01-07 09:23:48 +00:00
|
|
|
$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;
|
2015-01-07 09:12:54 +00:00
|
|
|
} else {
|
2015-01-07 09:23:48 +00:00
|
|
|
header(
|
|
|
|
'Content-Disposition: attachment; filename="'.
|
|
|
|
html_entity_decode(
|
|
|
|
pathinfo(
|
2015-01-07 09:12:54 +00:00
|
|
|
VideoDownload::getFilename(
|
2015-01-07 09:23:48 +00:00
|
|
|
$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;
|
2015-01-07 09:12:54 +00:00
|
|
|
}
|
2014-03-13 19:07:56 +00:00
|
|
|
} else {
|
|
|
|
$error=true;
|
|
|
|
}
|
|
|
|
} else {
|
2014-03-18 14:08:16 +00:00
|
|
|
$video = VideoDownload::getJSON($_GET["url"]);
|
2014-03-13 19:07:56 +00:00
|
|
|
if (isset($video->webpage_url)) {
|
|
|
|
include 'head.php';
|
|
|
|
?>
|
|
|
|
<body>
|
2014-11-18 17:20:17 +00:00
|
|
|
<div itemscope
|
|
|
|
itemtype="http://schema.org/VideoObject" class="wrapper">
|
2014-03-13 19:07:56 +00:00
|
|
|
<div class="main">
|
|
|
|
<?php
|
|
|
|
include 'logo.php';
|
|
|
|
?>
|
2014-05-23 17:33:52 +00:00
|
|
|
<p>You are going to download<i itemprop="name">
|
2014-11-18 17:20:17 +00:00
|
|
|
<a itemprop="url" id="video_link"
|
|
|
|
data-ext="<?php echo $video->ext; ?>"
|
2014-12-29 23:33:09 +00:00
|
|
|
data-video="<?php echo htmlentities($video->url); ?>"
|
2014-11-18 17:20:17 +00:00
|
|
|
href="<?php echo $video->webpage_url; ?>">
|
2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
|
|
|
echo $video->title;
|
2014-11-18 17:20:17 +00:00
|
|
|
?></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>
|
2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
2014-05-23 17:33:52 +00:00
|
|
|
echo '<img itemprop="image" class="thumb" src="',
|
2014-03-13 19:07:56 +00:00
|
|
|
$video->thumbnail, '" alt="" />';
|
|
|
|
?><br/>
|
|
|
|
<form action="api.php">
|
|
|
|
<input type="hidden" name="url"
|
|
|
|
value="<?php echo $video->webpage_url; ?>" />
|
|
|
|
<?php
|
|
|
|
if (isset($video->formats)) {
|
|
|
|
?>
|
2014-05-23 17:11:03 +00:00
|
|
|
<h3>Available formats:</h3>
|
|
|
|
<p>(You might have to do a <i>Right click > Save as</i>)</p>
|
|
|
|
<ul id="format" class="format">
|
2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
2014-11-18 17:20:17 +00:00
|
|
|
echo '<li class="best" itemprop="encoding" itemscope
|
|
|
|
itemtype="http://schema.org/VideoObject">';
|
2014-12-29 23:34:10 +00:00
|
|
|
echo '<a download="'.$video->_filename.'" itemprop="contentUrl"
|
2014-12-29 23:33:09 +00:00
|
|
|
href="', htmlentities($video->url) ,'">';
|
2014-11-18 17:20:17 +00:00
|
|
|
echo '<b>Best</b> (<span itemprop="encodingFormat">',
|
|
|
|
$video->ext, '</span>)';
|
2014-11-18 17:15:52 +00:00
|
|
|
echo '</a></li>';
|
2014-03-13 19:07:56 +00:00
|
|
|
foreach ($video->formats as $format) {
|
2014-11-18 17:20:17 +00:00
|
|
|
echo '<li itemprop="encoding"
|
|
|
|
itemscope itemtype="http://schema.org/VideoObject">';
|
2014-12-29 23:34:10 +00:00
|
|
|
echo '<a download="'.str_replace(
|
|
|
|
$video->ext, $format->ext, $video->_filename
|
|
|
|
).'" itemprop="contentUrl"
|
2014-12-29 23:33:09 +00:00
|
|
|
href="', htmlentities($format->url) ,'">';
|
2014-11-18 17:20:17 +00:00
|
|
|
echo '<span itemprop="videoQuality">', $format->format,
|
|
|
|
'</span> (<span itemprop="encodingFormat">',
|
|
|
|
$format->ext, '</span>)';
|
2014-05-23 17:11:03 +00:00
|
|
|
echo '</a></li>';
|
2014-03-13 19:07:56 +00:00
|
|
|
}
|
|
|
|
?>
|
2014-05-23 17:11:03 +00:00
|
|
|
</ul><br/><br/>
|
2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
<input type="hidden" name="format" value="best" />
|
|
|
|
<?php
|
|
|
|
}
|
2014-05-23 17:35:38 +00:00
|
|
|
if (!isset($video->formats)) {
|
2014-11-18 17:20:17 +00:00
|
|
|
?>
|
|
|
|
<a class="downloadBtn"
|
|
|
|
href="<?php echo $video->url; ?>">Download</a><br/>
|
|
|
|
<?php
|
2014-05-23 17:35:38 +00:00
|
|
|
}
|
|
|
|
?>
|
2014-03-13 19:07:56 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
include 'footer.php';
|
|
|
|
?>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
$error=true;
|
|
|
|
}
|
|
|
|
}
|
2014-04-04 14:38:36 +00:00
|
|
|
}
|
2014-03-13 19:07:56 +00:00
|
|
|
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.
|
|
|
|
If you think this is a bug, please report the following error
|
|
|
|
to <a href="mailto:contact@rudloff.pro"><i>contact@rudloff.pro</i></a>:
|
|
|
|
<p><i>
|
|
|
|
<?php
|
|
|
|
foreach ($video['error'] as $error) {
|
|
|
|
print $error;
|
|
|
|
?>
|
|
|
|
<br/>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</i></p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
include 'footer.php';
|
|
|
|
?>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|