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

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');
}
?>