2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
|
|
|
* Index page
|
2015-10-29 20:19:40 +00:00
|
|
|
*
|
2014-03-13 19:07:56 +00:00
|
|
|
* PHP Version 5.3.10
|
2015-10-29 20:19:40 +00:00
|
|
|
*
|
2014-03-13 19:07:56 +00:00
|
|
|
* @category Youtube-dl
|
|
|
|
* @package Youtubedl
|
2015-01-07 09:47:46 +00:00
|
|
|
* @author Pierre Rudloff <contact@rudloff.pro>
|
2014-03-13 19:07:56 +00:00
|
|
|
* @author Olivier Haquette <contact@olivierhaquette.fr>
|
|
|
|
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
|
|
|
* @link http://rudloff.pro
|
|
|
|
* */
|
2015-10-29 20:19:40 +00:00
|
|
|
use Alltube\VideoDownload;
|
2015-01-07 09:42:44 +00:00
|
|
|
require_once 'common.php';
|
2015-10-29 20:19:40 +00:00
|
|
|
|
2015-10-29 20:23:02 +00:00
|
|
|
$app = new \Slim\Slim(
|
|
|
|
array(
|
|
|
|
'view' => new \Slim\Views\Smarty()
|
|
|
|
)
|
|
|
|
);
|
2015-10-29 20:19:40 +00:00
|
|
|
$view = $app->view();
|
|
|
|
$view->parserExtensions = array(
|
|
|
|
dirname(__FILE__).'/vendor/slim/views/SmartyPlugins',
|
|
|
|
);
|
2015-10-29 20:23:02 +00:00
|
|
|
$app->get(
|
|
|
|
'/',
|
|
|
|
function () {
|
|
|
|
global $app;
|
|
|
|
$app->render(
|
|
|
|
'head.tpl',
|
|
|
|
array(
|
|
|
|
'class'=>'index'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$app->render(
|
|
|
|
'header.tpl'
|
|
|
|
);
|
|
|
|
$app->render(
|
|
|
|
'index.tpl',
|
|
|
|
array(
|
|
|
|
'convert'=>CONVERT
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$app->render('footer.tpl');
|
2015-10-29 20:19:40 +00:00
|
|
|
}
|
2015-10-29 20:23:02 +00:00
|
|
|
);
|
|
|
|
$app->get(
|
|
|
|
'/extractors',
|
|
|
|
function () {
|
|
|
|
global $app;
|
2015-10-29 20:19:40 +00:00
|
|
|
$app->render(
|
|
|
|
'head.tpl',
|
|
|
|
array(
|
2015-10-29 20:23:02 +00:00
|
|
|
'class'=>'extractors'
|
2015-10-29 20:19:40 +00:00
|
|
|
)
|
|
|
|
);
|
2015-10-29 20:23:02 +00:00
|
|
|
$app->render('header.tpl');
|
|
|
|
$app->render('logo.tpl');
|
2015-10-29 20:19:40 +00:00
|
|
|
$app->render(
|
2015-10-29 20:23:02 +00:00
|
|
|
'extractors.tpl',
|
2015-10-29 20:19:40 +00:00
|
|
|
array(
|
2015-10-29 20:23:02 +00:00
|
|
|
'extractors'=>VideoDownload::listExtractors()
|
2015-10-29 20:19:40 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$app->render('footer.tpl');
|
|
|
|
}
|
2015-10-29 20:23:02 +00:00
|
|
|
)->name('extractors');
|
|
|
|
$app->get(
|
|
|
|
'/video',
|
|
|
|
function () {
|
|
|
|
global $app;
|
|
|
|
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') {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
} 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');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)->name('video');
|
2015-10-29 20:19:40 +00:00
|
|
|
$app->run();
|