Use Slim for everything
This commit is contained in:
parent
78670d73a5
commit
51432dc53e
4 changed files with 34 additions and 48 deletions
|
@ -134,4 +134,30 @@ class FrontController {
|
|||
$app->render('footer.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
static function redirect() {
|
||||
global $app;
|
||||
if (isset($_GET["url"])) {
|
||||
try {
|
||||
$video = VideoDownload::getURL($_GET["url"]);
|
||||
$app->redirect($video['url']);
|
||||
} catch (\Exception $e) {
|
||||
$app->response->headers->set('Content-Type', 'text/plain');
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function json() {
|
||||
global $app;
|
||||
if (isset($_GET["url"])) {
|
||||
$app->response->headers->set('Content-Type', 'application/json');
|
||||
try {
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
echo json_encode($video);
|
||||
} catch (\Exception $e) {
|
||||
echo json_encode(array('success'=>false, 'error'=>$e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,4 +37,12 @@ $app->get(
|
|||
'/video',
|
||||
array('Alltube\Controller\FrontController', 'video')
|
||||
)->name('video');
|
||||
$app->get(
|
||||
'/redirect',
|
||||
array('Alltube\Controller\FrontController', 'redirect')
|
||||
);
|
||||
$app->get(
|
||||
'/json',
|
||||
array('Alltube\Controller\FrontController', 'json')
|
||||
);
|
||||
$app->run();
|
||||
|
|
24
json.php
24
json.php
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* 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 <contact@rudloff.pro>
|
||||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://rudloff.pro
|
||||
* */
|
||||
use Alltube\VideoDownload;
|
||||
require_once 'common.php';
|
||||
if (isset($_GET["url"])) {
|
||||
header('Content-Type: application/json');
|
||||
try {
|
||||
$video = VideoDownload::getJSON($_GET["url"]);
|
||||
echo json_encode($video);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(array('success'=>false, 'error'=>$e->getMessage()));
|
||||
}
|
||||
}
|
24
redirect.php
24
redirect.php
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/)
|
||||
* Redirect to video in best format
|
||||
*
|
||||
* PHP Version 5.3.10
|
||||
*
|
||||
* @category Youtube-dl
|
||||
* @package Youtubedl
|
||||
* @author Pierre Rudloff <contact@rudloff.pro>
|
||||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://rudloff.pro
|
||||
* */
|
||||
use Alltube\VideoDownload;
|
||||
require_once 'common.php';
|
||||
if (isset($_GET["url"])) {
|
||||
try {
|
||||
$video = VideoDownload::getURL($_GET["url"]);
|
||||
header('Location: '.$video['url']);
|
||||
} catch (Exception $e) {
|
||||
header('Content-Type: text/plain');
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue