diff --git a/api.php b/api.php index 6066621..3c94415 100644 --- a/api.php +++ b/api.php @@ -10,9 +10,9 @@ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html * @link http://rudloff.pro * */ +use Alltube\VideoDownload; require_once 'common.php'; $smarty->assign('class', 'video'); -require_once 'download.php'; if (isset($_GET["url"])) { if (isset($_GET['audio'])) { try { diff --git a/download.php b/classes/VideoDownload.php similarity index 95% rename from download.php rename to classes/VideoDownload.php index 6c20965..5c362e7 100644 --- a/download.php +++ b/classes/VideoDownload.php @@ -11,7 +11,7 @@ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html * @link http://rudloff.pro * */ - +namespace Alltube; /** * PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/) * Main class @@ -95,7 +95,7 @@ Class VideoDownload $cmd, $result, $code ); if ($code>0) { - throw new Exception(implode(PHP_EOL, $result)); + throw new \Exception(implode(PHP_EOL, $result)); } else { return json_decode($result[0]); } @@ -120,7 +120,7 @@ Class VideoDownload $cmd, $result, $code ); if ($code>0) { - throw new Exception(implode(PHP_EOL, $result)); + throw new \Exception(implode(PHP_EOL, $result)); } else { return array('success'=>true, 'url'=>end($result)); } diff --git a/composer.json b/composer.json index 869c8da..6b3040d 100644 --- a/composer.json +++ b/composer.json @@ -39,5 +39,10 @@ "homepage": "https://rudloff.pro/", "role": "Developer" } - ] + ], + "autoload": { + "psr-4": { + "Alltube\\": "classes/" + } + } } diff --git a/composer.lock b/composer.lock index a964a38..2dec5bb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "3dbe1326b363d56d544801b87ad0ee5e", + "hash": "b211e248137ada7cd1babc6c880fc4c5", "content-hash": "30052efb27250d4c6eb0a5bb39518987", "packages": [ { diff --git a/extractors.php b/extractors.php index f265363..e82168f 100644 --- a/extractors.php +++ b/extractors.php @@ -2,9 +2,9 @@ /** * PHP web interface for youtube-dl (http://rg3.github.com/youtube-dl/) * List of all supported websites - * + * * PHP Version 5.3.10 - * + * * @category Youtube-dl * @package Youtubedl * @author Pierre Rudloff @@ -12,9 +12,9 @@ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html * @link http://rudloff.pro * */ +use Alltube\VideoDownload; require_once 'common.php'; $smarty->assign('class', 'extractors'); -require_once 'download.php'; $smarty->display('head.tpl'); $smarty->display('header.tpl'); $smarty->display('logo.tpl'); diff --git a/json.php b/json.php index 0212e9d..025c2a6 100644 --- a/json.php +++ b/json.php @@ -11,8 +11,8 @@ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html * @link http://rudloff.pro * */ +use Alltube\VideoDownload; require_once 'common.php'; -require_once 'download.php'; if (isset($_GET["url"])) { header('Content-Type: application/json'); try { diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 95463f5..78bad0f 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -10,9 +10,8 @@ * @license GNU General Public License http://www.gnu.org/licenses/gpl.html * @link http://rudloff.pro * */ - +use Alltube\VideoDownload; require_once __DIR__.'/../common.php'; -require_once __DIR__.'/../download.php'; /** * Unit tests for the VideoDownload class